PageRenderTime 53ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/index-install.php

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