PageRenderTime 62ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/www/public/blog/__index-install.php

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