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