Changeset 843

Show
Ignore:
Timestamp:
01/14/07 21:10:03 (2 years ago)
Author:
donncha
Message:

spaces -> tabs
define VHOST during install. (fixes #216)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/index-install.php

    r747 r843  
    7171 
    7272function check_writeable_dir( $dir, $ret ) { 
    73     if( is_writeable( $dir  ) == false ) { 
    74         print $dir." : <b style='color: #f55'>FAILED</b><br />Quick Fix: <code>chmod 777 $dir</code><br />"; 
    75         return false; 
    76     } else { 
    77         if( $ret == true ) { 
    78             return true; 
    79         } else { 
    80             return false; 
    81        
    82    
     73       if( is_writeable( $dir  ) == false ) { 
     74               print $dir." : <b style='color: #f55'>FAILED</b><br />Quick Fix: <code>chmod 777 $dir</code><br />"; 
     75               return false; 
     76       } else { 
     77               if( $ret == true ) { 
     78                       return true; 
     79               } else { 
     80                       return false; 
     81               
     82       
    8383} 
    8484 
    8585function filestats( $err ) { 
    86     print "<h1>Server Summary</h1>"; 
    87     print "<p>If you post a message to the MU 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>"; 
    88  
    89     print "<blockquote style='background: #eee; border: 1px solid #333; padding: 5px;'>"; 
    90     print "<br /><strong>ERROR: $err</strong></br >"; 
    91     clearstatcache(); 
    92     $files = array( "htaccess.dist", ".htaccess" ); 
    93     while( list( $key, $val ) = each( $files ) ) {  
    94         $stats = @stat( $val ); 
    95         if( $stats ) { 
    96             print "<h2>$val</h2>"; 
    97             print "&nbsp;&nbsp;&nbsp;&nbsp;uid/gid: " . $stats[ 'uid' ] . "/" . $stats[ 'gid' ] . "<br />\n"; 
    98             print "&nbsp;&nbsp;&nbsp;&nbsp;size: " . $stats[ 'size' ] . "<br />"; 
    99             print "&nbsp;&nbsp;&nbsp;&nbsp;perms: " . substr( sprintf('%o', fileperms( $val ) ), -4 ) . "<br />"; 
    100             print "&nbsp;&nbsp;&nbsp;&nbsp;readable: "; 
    101             print is_readable( $val ) == true ? "yes" : "no"; 
    102             print "<br />"; 
    103             print "&nbsp;&nbsp;&nbsp;&nbsp;writeable: "; 
    104             print is_writeable( $val ) == true ? "yes" : "no"; 
    105             print "<br />"; 
    106              
    107         } elseif( file_exists( $val ) == false ) { 
    108             print "<h2>$val</h2>"; 
    109             print "&nbsp;&nbsp;&nbsp;&nbsp;FILE NOT FOUND: $val<br>"; 
    110         } 
    111     } 
    112     print "</blockquote>"; 
    113  
    114 
    115  
    116 function do_htaccess( $oldfilename, $newfilename, $base, $url ) 
    117 
    118     // remove ending slash from $base and $url 
    119     $htaccess = ''; 
    120     if( substr($base, -1 ) == '/') { 
    121         $base = substr($base, 0, -1); 
    122     } 
    123  
    124     if( substr($url, -1 ) == '/') { 
    125         $url = substr($url, 0, -1); 
    126     } 
    127     $err = ''; 
    128     if( is_file( $oldfilename ) ) { 
    129         $fp = @fopen( $oldfilename, "r" ); 
    130         if( $fp ) { 
    131             while( !feof( $fp ) ) 
    132             { 
    133                 $htaccess .= fgets( $fp, 4096 ); 
    134             } 
    135             fclose( $fp ); 
    136             $htaccess = str_replace( "BASE", $base, $htaccess ); 
    137             if( touch( $newfilename ) ) { 
    138                     $fp = fopen( $newfilename, "w" ); 
    139                     if( $fp ) { 
    140                             fwrite( $fp, $htaccess ); 
    141                             fclose( $fp ); 
    142                     } else { 
    143                             $err = "could not open $newfilename for writing"; 
    144                     } 
    145             } else { 
    146                     $err = "could not open $newfilename for writing"; 
    147             } 
    148         } else { 
    149             $err = "could not open $oldfilename for reading"; 
    150         } 
    151     } else { 
    152         $err = "$oldfilename not found"; 
    153     } 
    154  
    155     if( $err != '' ) { 
    156             print "<h1>Warning!</h1>"; 
    157             print "<p><strong>There was a problem creating the .htaccess file.</strong> </p>"; 
    158             print "<p style='color: #900'>Error: "; 
    159             if( $err == "could not open $newfilename for writing" ) { 
    160                 print "Could Not Write To $newfilename."; 
    161             } elseif( $err == "could not open $oldfilename for reading" ) { 
    162                 print "I could not read from $oldfilename. "; 
    163             } elseif( $err == "$oldfilename not found" ) { 
    164                 print "The file, $oldfilename, is missing."; 
    165             } 
    166             print "</p>"; 
    167             filestats( $err ); 
    168  
    169             print "<p>Please ensure that the webserver can write to this directory.</p>"; 
    170             print "<p>If you use Cpanel then read <a href='http://mu.wordpress.org/forums/topic/99'>this post</a>. Cpanel creates files that I need to overwrite and you have to fix that.</p>"; 
    171             print "<p>If all else fails then you'll have to create it by hand:"; 
    172             print "<ul><li> Download htaccess.dist to your computer and open it in your favourite text editor.</li> 
     86        print "<h1>Server Summary</h1>"; 
     87        print "<p>If you post a message to the MU 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>"; 
     88 
     89        print "<blockquote style='background: #eee; border: 1px solid #333; padding: 5px;'>"; 
     90        print "<br /><strong>ERROR: $err</strong></br >"; 
     91        clearstatcache(); 
     92        $files = array( "htaccess.dist", ".htaccess" ); 
     93        while( list( $key, $val ) = each( $files ) ) {  
     94                $stats = @stat( $val ); 
     95                if( $stats ) { 
     96                        print "<h2>$val</h2>"; 
     97                        print "&nbsp;&nbsp;&nbsp;&nbsp;uid/gid: " . $stats[ 'uid' ] . "/" . $stats[ 'gid' ] . "<br />\n"; 
     98                        print "&nbsp;&nbsp;&nbsp;&nbsp;size: " . $stats[ 'size' ] . "<br />"; 
     99                        print "&nbsp;&nbsp;&nbsp;&nbsp;perms: " . substr( sprintf('%o', fileperms( $val ) ), -4 ) . "<br />"; 
     100                        print "&nbsp;&nbsp;&nbsp;&nbsp;readable: "; 
     101                        print is_readable( $val ) == true ? "yes" : "no"; 
     102                        print "<br />"; 
     103                        print "&nbsp;&nbsp;&nbsp;&nbsp;writeable: "; 
     104                        print is_writeable( $val ) == true ? "yes" : "no"; 
     105                        print "<br />"; 
     106                } elseif( file_exists( $val ) == false ) { 
     107                        print "<h2>$val</h2>"; 
     108                        print "&nbsp;&nbsp;&nbsp;&nbsp;FILE NOT FOUND: $val<br>"; 
     109                } 
     110        } 
     111        print "</blockquote>"; 
     112
     113 
     114function do_htaccess( $oldfilename, $newfilename, $base, $url ) { 
     115        // remove ending slash from $base and $url 
     116        $htaccess = ''; 
     117        if( substr($base, -1 ) == '/') { 
     118                $base = substr($base, 0, -1); 
     119        } 
     120 
     121        if( substr($url, -1 ) == '/') { 
     122                $url = substr($url, 0, -1); 
     123        } 
     124        $err = ''; 
     125        if( is_file( $oldfilename ) ) { 
     126                $fp = @fopen( $oldfilename, "r" ); 
     127                if( $fp ) { 
     128                        while( !feof( $fp ) ) 
     129                        { 
     130                                $htaccess .= fgets( $fp, 4096 ); 
     131                        } 
     132                        fclose( $fp ); 
     133                        $htaccess = str_replace( "BASE", $base, $htaccess ); 
     134                        if( touch( $newfilename ) ) { 
     135                                $fp = fopen( $newfilename, "w" ); 
     136                                if( $fp ) { 
     137                                        fwrite( $fp, $htaccess ); 
     138                                        fclose( $fp ); 
     139                                } else { 
     140                                        $err = "could not open $newfilename for writing"; 
     141                                } 
     142                        } else { 
     143                                $err = "could not open $newfilename for writing"; 
     144                        } 
     145                } else { 
     146                        $err = "could not open $oldfilename for reading"; 
     147                } 
     148        } else { 
     149                $err = "$oldfilename not found"; 
     150        } 
     151 
     152        if( $err != '' ) { 
     153                print "<h1>Warning!</h1>"; 
     154                print "<p><strong>There was a problem creating the .htaccess file.</strong> </p>"; 
     155                print "<p style='color: #900'>Error: "; 
     156                if( $err == "could not open $newfilename for writing" ) { 
     157                        print "Could Not Write To $newfilename."; 
     158                } elseif( $err == "could not open $oldfilename for reading" ) { 
     159                        print "I could not read from $oldfilename. "; 
     160                } elseif( $err == "$oldfilename not found" ) { 
     161                        print "The file, $oldfilename, is missing."; 
     162                } 
     163                print "</p>"; 
     164                filestats( $err ); 
     165 
     166                print "<p>Please ensure that the webserver can write to this directory.</p>"; 
     167                print "<p>If you use Cpanel then read <a href='http://mu.wordpress.org/forums/topic/99'>this post</a>. Cpanel creates files that I need to overwrite and you have to fix that.</p>"; 
     168                print "<p>If all else fails then you'll have to create it by hand:"; 
     169                print "<ul><li> Download htaccess.dist to your computer and open it in your favourite text editor.</li> 
    173170                <li> Replace the following text:<ul><li>BASE by '$base'</li><li>HOST by '$url'</li></li> 
    174171                <li> Rename htaccess.dist to .htaccess and upload it back to the same directory.</li></ul>"; 
    175             die( "Installation Aborted!" ); 
    176    
     172               die( "Installation Aborted!" ); 
     173       
    177174} 
    178175 
    179176function checkdirs() { 
    180     $ret = true; 
    181     $ret = check_writeable_dir( dirname(__FILE__), $ret ); 
    182     $ret = check_writeable_dir( dirname(__FILE__) . "/wp-content/", $ret ); 
    183  
    184     if( $ret == false ) 
    185     { 
    186         print "<h2>Warning!</h2>"; 
    187         print "<div style='border: 1px solid #ccc'>"; 
    188         print "<p style='font-weight: bold; padding-left: 10px'>One or more of the above directories must be made writeable by the webserver.<br>"; 
    189         print "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>"; 
    190         print "Refresh this page when you're done!<br></p>"; 
    191         print "</div>"; 
    192     } 
    193     if( file_exists( "./.htaccess" ) && is_writeable( "./.htaccess" ) == false ) { 
    194             $ret = false; 
    195             print "<h2>Warning! .htaccess already exists.</h2>"; 
    196             print "<div style='border: 1px solid #ccc'>"; 
    197             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 />"; 
    198             print "Offending file: " . realpath( '.htaccess' ) . "</p>"; 
    199             print "</div>"; 
    200     } 
    201  
    202  
    203     return $ret; 
     177        $ret = true; 
     178        $ret = check_writeable_dir( dirname(__FILE__), $ret ); 
     179        $ret = check_writeable_dir( dirname(__FILE__) . "/wp-content/", $ret ); 
     180 
     181        if( $ret == false ) { 
     182                print "<h2>Warning!</h2>"; 
     183                print "<div style='border: 1px solid #ccc'>"; 
     184                print "<p style='font-weight: bold; padding-left: 10px'>One or more of the above directories must be made writeable by the webserver.<br>"; 
     185                print "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>"; 
     186                print "Refresh this page when you're done!<br></p>"; 
     187                print "</div>"; 
     188        } 
     189        if( file_exists( "./.htaccess" ) && is_writeable( "./.htaccess" ) == false ) { 
     190                $ret = false; 
     191                print "<h2>Warning! .htaccess already exists.</h2>"; 
     192                print "<div style='border: 1px solid #ccc'>"; 
     193                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 />"; 
     194                print "Offending file: " . realpath( '.htaccess' ) . "</p>"; 
     195                print "</div>"; 
     196        } 
     197        return $ret; 
    204198} 
    205199 
     
    207201        print "<h2>Installing WP&micro;</h2>"; 
    208202        $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>"; 
    209     if( function_exists( "apache_get_modules" ) ) { 
    210             $modules = apache_get_modules(); 
     203       if( function_exists( "apache_get_modules" ) ) { 
     204               $modules = apache_get_modules(); 
    211205                if( in_array( "mod_rewrite", $modules ) == false ) { 
    212206                        echo "<p><strong>Warning!</strong> It looks like mod_rewrite is not installed.</p>" . $mod_rewrite_msg; 
     
    214208        } else { 
    215209                ?><p>Please make sure <code>mod_rewrite</code> is installed as it will be activated at the end of this install.</p><?php 
    216                         echo $mod_rewrite_msg; 
    217     } 
    218     if( checkdirs() == false ) { 
    219         return false; 
    220     } 
    221  
    222     // Create Blogs living area. 
    223     @mkdir( dirname(__FILE__) . "/wp-content/blogs.dir", 0777 ); 
    224  
    225  
    226     $url = stripslashes( "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] ) ); 
    227     if( substr( $url, -1 ) == '/' ) 
    228         $url = substr( $url, 0, -1 ); 
    229     $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) ); 
    230     if( $base != "/") 
    231     { 
    232            $base .= "/"; 
    233     }  
    234     $realpath = dirname(__FILE__); 
    235  
    236     return true; 
     210                echo $mod_rewrite_msg; 
     211        } 
     212        if( checkdirs() == false ) { 
     213                return false; 
     214        } 
     215 
     216        // Create Blogs living area. 
     217        @mkdir( dirname(__FILE__) . "/wp-content/blogs.dir", 0777 ); 
     218 
     219        $url = stripslashes( "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] ) ); 
     220        if( substr( $url, -1 ) == '/' ) 
     221        $url = substr( $url, 0, -1 ); 
     222        $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) ); 
     223        if( $base != "/") { 
     224                $base .= "/"; 
     225        }  
     226        $realpath = dirname(__FILE__); 
     227 
     228        return true; 
    237229} 
    238230 
     
    291283function step2() { 
    292284        global $wpdb, $table_prefix, $base, $blog_id; 
    293     $dbname  = $_POST['dbname']; 
    294     $uname   = $_POST['uname']; 
    295     $passwrd = $_POST['pwd']; 
    296     $dbhost  = $_POST['dbhost']; 
    297     $vhost   = $_POST['vhost' ];  
    298     $prefix  = 'wp_'; 
    299     $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) ); 
    300     if( $base != "/") { 
    301            $base .= "/"; 
    302     }  
    303  
    304     // Test the db connection. 
    305     define('DB_NAME', $dbname); 
    306     define('DB_USER', $uname); 
    307     define('DB_PASSWORD', $passwrd); 
    308     define('DB_HOST', $dbhost); 
    309  
    310     if (!file_exists('wp-config-sample.php')) 
    311         die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); 
    312  
    313     $configFile = file('wp-config-sample.php'); 
    314     // We'll fail here if the values are no good. 
    315     require_once('wp-includes/wp-db.php'); 
    316     printheader(); 
    317  
    318     print "Creating Database Config File: "; 
    319      
    320     $handle = fopen('wp-config.php', 'w'); 
    321  
    322     foreach ($configFile as $line_num => $line) { 
    323         switch (trim( substr($line,0,16) )) { 
    324             case "define('DB_NAME'": 
    325                 fwrite($handle, str_replace("wordpress", $dbname, $line))
    326             break; 
    327             case "define('DB_USER'": 
    328                 fwrite($handle, str_replace("'username'", "'$uname'", $line))
    329             break; 
    330             case "define('DB_PASSW": 
    331                 fwrite($handle, str_replace("'password'", "'$passwrd'", $line))
    332             break; 
    333             case "define('DB_HOST'": 
    334                 fwrite($handle, str_replace("localhost", $dbhost, $line))
    335             break; 
    336             case "define('VHOST',": 
    337                 fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line))
    338             break; 
    339             case '$table_prefix  =': 
    340             fwrite($handle, str_replace('wp_', $prefix, $line))
    341             break; 
    342             case '$base = \'BASE\';': 
    343             fwrite($handle, str_replace('BASE', $base, $line))
    344             break; 
    345             default: 
    346             fwrite($handle, $line)
    347             break; 
    348         } 
    349     } 
    350     fclose($handle); 
    351     chmod('wp-config.php', 0644)
    352     print "<b style='color: #00aa00; font-weight: bold'>DONE</b><br />"
     285       $dbname  = $_POST['dbname']; 
     286       $uname   = $_POST['uname']; 
     287       $passwrd = $_POST['pwd']; 
     288       $dbhost  = $_POST['dbhost']; 
     289       $vhost   = $_POST['vhost' ];  
     290       $prefix  = 'wp_'; 
     291       $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) ); 
     292        if( $base != "/") 
     293               $base .= "/"; 
     294 
     295        // Test the db connection. 
     296        define('DB_NAME', $dbname); 
     297       define('DB_USER', $uname); 
     298       define('DB_PASSWORD', $passwrd); 
     299       define('DB_HOST', $dbhost); 
     300 
     301        if (!file_exists('wp-config-sample.php')) 
     302                die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); 
     303 
     304        $configFile = file('wp-config-sample.php'); 
     305        // We'll fail here if the values are no good. 
     306        require_once('wp-includes/wp-db.php'); 
     307       printheader(); 
     308 
     309        print "Creating Database Config File: "; 
     310 
     311        $handle = fopen('wp-config.php', 'w'); 
     312 
     313        foreach ($configFile as $line_num => $line) { 
     314               switch (trim( substr($line,0,16) )) { 
     315                       case "define('DB_NAME'": 
     316                               fwrite($handle, str_replace("wordpress", $dbname, $line)); 
     317                               break
     318                       case "define('DB_USER'": 
     319                               fwrite($handle, str_replace("'username'", "'$uname'", $line)); 
     320                               break
     321                       case "define('DB_PASSW": 
     322                               fwrite($handle, str_replace("'password'", "'$passwrd'", $line)); 
     323                               break
     324                       case "define('DB_HOST'": 
     325                               fwrite($handle, str_replace("localhost", $dbhost, $line)); 
     326                               break
     327                       case "define('VHOST',": 
     328                               fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line)); 
     329                               break
     330                       case '$table_prefix  =': 
     331                               fwrite($handle, str_replace('wp_', $prefix, $line)); 
     332                               break
     333                       case '$base = \'BASE\';': 
     334                               fwrite($handle, str_replace('BASE', $base, $line)); 
     335                               break
     336                       default: 
     337                               fwrite($handle, $line); 
     338                               break
     339               } 
     340        } 
     341        fclose($handle); 
     342       chmod('wp-config.php', 0644); 
     343       print "<b style='color: #00aa00; font-weight: bold'>DONE</b><br />"
     344       define( 'VHOST', $vhost )
    353345} 
    354346 
     
    366358 
    367359function step3() { 
    368     global $wpdb, $current_site; 
    369     $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) ); 
    370     if( $base != "/") { 
    371            $base .= "/"; 
    372     }  
    373     $domain =   $wpdb->escape( $_POST[ 'basedomain' ] ); 
    374     if( substr( $domain, 0, 4 ) == 'www.' ) 
     360       global $wpdb, $current_site; 
     361       $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) ); 
     362       if( $base != "/") { 
     363               $base .= "/"; 
     364       }  
     365       $domain =   $wpdb->escape( $_POST[ 'basedomain' ] ); 
     366       if( substr( $domain, 0, 4 ) == 'www.' ) 
    375367        $domain = substr( $domain, 4 ); 
    376368 
    377     $email = $wpdb->escape( $_POST[ 'email' ] ); 
    378     $weblog_title = $wpdb->escape( $_POST[ 'weblog_title' ] ); 
    379  
    380     // set up site tables 
    381     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_email', '".$email."')" ); 
    382     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_user_id', '1')" ); 
    383     $wpdb->query( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( NULL, '$domain', '$base' )" ); 
    384     $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " VALUES (1, 'Uncategorized', 'uncategorized', NOW())" ); 
    385     $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " VALUES (2, 'Blogroll', 'blogroll', NOW())" ); 
    386     $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' )" ); 
    387     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'blog_upload_space', '10' )" ); 
    388     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'fileupload_maxk', '1500' )" ); 
    389     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_admins', '" . serialize( array( 'admin' ) ) . "' )" ); 
    390     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'allowed_themes', '" . serialize( array( 'WordPress Classic', 'WordPress Default' ) ) . "' )" ); 
    391     $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" ) ) . "' )" ); 
    392     $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'welcome_email', 'Dear User, 
     369       $email = $wpdb->escape( $_POST[ 'email' ] ); 
     370       $weblog_title = $wpdb->escape( $_POST[ 'weblog_title' ] ); 
     371 
     372       // set up site tables 
     373       $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_email', '".$email."')" ); 
     374       $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_user_id', '1')" ); 
     375       $wpdb->query( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( NULL, '$domain', '$base' )" ); 
     376       $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " VALUES (1, 'Uncategorized', 'uncategorized', NOW())" ); 
     377       $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " 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, 'allowed_themes', '" . serialize( array( 'WordPress Classic', 'WordPress Default' ) ) . "' )" ); 
     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, 
    393385 
    394386Your new SITE_NAME blog has been successfully set up at: 
     
    404396 
    405397--The Team @ SITE_NAME')" ); 
    406     $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!' )" ); 
     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!' )" ); 
    407399 
    408400        $pass = substr( md5( rand() ), 5, 12 ); 
     
    412404        $current_site->path = $base; 
    413405        $current_site->site_name = ucfirst( $domain ); 
    414          
     406 
    415407        wpmu_create_blog( $domain, $base, $weblog_title, $user_id, array() ); 
    416408        update_blog_option( 1, 'template', 'home');