PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/1.5/wp-admin/install.php

#
PHP | 209 lines | 177 code | 25 blank | 7 comment | 4 complexity | 28114ee6424a7011764bd89e4d1474fb MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. $_wp_installing = 1;
  3. if (!file_exists('../wp-config.php'))
  4. die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
  5. require_once('../wp-config.php');
  6. require_once('./upgrade-functions.php');
  7. $guessurl = str_replace('/wp-admin/install.php?step=2', '', 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) );
  8. if (isset($_GET['step']))
  9. $step = $_GET['step'];
  10. else
  11. $step = 0;
  12. ?>
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  14. <html xmlns="http://www.w3.org/1999/xhtml">
  15. <head>
  16. <title>WordPress &rsaquo; Installation</title>
  17. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  18. <style media="screen" type="text/css">
  19. <!--
  20. html {
  21. background: #eee;
  22. }
  23. body {
  24. background: #fff;
  25. color: #000;
  26. font-family: Georgia, "Times New Roman", Times, serif;
  27. margin-left: 20%;
  28. margin-right: 20%;
  29. padding: .2em 2em;
  30. }
  31. h1 {
  32. color: #006;
  33. font-size: 18px;
  34. font-weight: lighter;
  35. }
  36. h2 {
  37. font-size: 16px;
  38. }
  39. p, li, dt {
  40. line-height: 140%;
  41. padding-bottom: 2px;
  42. }
  43. ul, ol {
  44. padding: 5px 5px 5px 20px;
  45. }
  46. #logo {
  47. margin-bottom: 2em;
  48. }
  49. .step a, .step input {
  50. font-size: 2em;
  51. }
  52. td input {
  53. font-size: 1.5em;
  54. }
  55. .step, th {
  56. text-align: right;
  57. }
  58. #footer {
  59. text-align: center;
  60. border-top: 1px solid #ccc;
  61. padding-top: 1em;
  62. font-style: italic;
  63. }
  64. -->
  65. </style>
  66. </head>
  67. <body>
  68. <h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
  69. <?php
  70. // Let's check to make sure WP isn't already installed.
  71. $wpdb->hide_errors();
  72. $installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
  73. if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p></body></html>'));
  74. $wpdb->show_errors();
  75. switch($step) {
  76. case 0:
  77. ?>
  78. <p>Welcome to WordPress installation. We&#8217;re now going to go through a few steps to get you up and running with the latest in personal publishing platforms. You may want to peruse the <a href="../readme.html">ReadMe documentation</a> at your leisure.</p>
  79. <h2 class="step"><a href="install.php?step=1">First Step &raquo;</a></h2>
  80. <?php
  81. break;
  82. case 1:
  83. ?>
  84. <h1>First Step</h1>
  85. <p>Before we begin we need a little bit of information. Don't worry, you can always change these later. </p>
  86. <form id="setup" method="post" action="install.php?step=2">
  87. <table width="100%">
  88. <tr>
  89. <th width="33%">Weblog title:</th>
  90. <td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
  91. </tr>
  92. <tr>
  93. <th>Your e-mail:</th>
  94. <td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
  95. </tr>
  96. </table>
  97. <p><em>Double-check that email address before continuing.</em></p>
  98. <h2 class="step">
  99. <input type="submit" name="Submit" value="Continue to Second Step &raquo;" />
  100. </h2>
  101. </form>
  102. <?php
  103. break;
  104. case 2:
  105. ?>
  106. <h1>Second Step</h1>
  107. <p>Now we&#8217;re going to create the database tables and fill them with some default data.</p>
  108. <?php
  109. flush();
  110. // Set everything up
  111. make_db_current_silent();
  112. populate_options();
  113. // Fill in the data we gathered
  114. $weblog_title = addslashes(stripslashes(stripslashes($_POST['weblog_title'])));
  115. $admin_email = addslashes(stripslashes(stripslashes($_POST['admin_email'])));
  116. $wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'");
  117. $wpdb->query("UPDATE $wpdb->options SET option_value = '$admin_email' WHERE option_name = 'admin_email'");
  118. // Now drop in some default links
  119. $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, 'Blogroll')");
  120. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
  121. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/');");
  122. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/');");
  123. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
  124. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
  125. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/');");
  126. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php');");
  127. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/');");
  128. // Default category
  129. $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name) VALUES ('0', 'Uncategorized')");
  130. // First post
  131. $now = date('Y-m-d H:i:s');
  132. $now_gmt = gmdate('Y-m-d H:i:s');
  133. $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_modified, post_modified_gmt) VALUES ('1', '$now', '$now_gmt', 'Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!', 'Hello world!', '0', '$now', '$now_gmt')");
  134. $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
  135. // Default comment
  136. $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ('1', 'Mr WordPress', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', 'Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.')");
  137. // Set up admin user
  138. $random_password = substr(md5(uniqid(microtime())), 0, 6);
  139. $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_nickname, user_email, user_level, user_idmode, user_registered) VALUES ( '1', 'admin', MD5('$random_password'), 'Administrator', '$admin_email', '10', 'nickname', NOW() )");
  140. $from = 'From: '.$_POST['weblog_title'].' <wordpress@'.$_SERVER['SERVER_NAME'].'>';
  141. $message_headers = "$from";
  142. $message = "Your new WordPress blog has been successfully set up at:
  143. $guessurl
  144. You can log in to the administrator account with the following information:
  145. Username: admin
  146. Password: $random_password
  147. We hope you enjoy your new weblog. Thanks!
  148. --The WordPress Team
  149. http://wordpress.org/
  150. ";
  151. @mail($admin_email, 'New WordPress Blog', $message, $message_headers);
  152. upgrade_all();
  153. ?>
  154. <p><em>Finished!</em></p>
  155. <p>Now you can <a href="../wp-login.php">log in</a> with the <strong>login</strong>
  156. "<code>admin</code>" and <strong>password</strong> "<code><?php echo $random_password; ?></code>".</p>
  157. <p><strong><em>Note that password</em></strong> carefully! It is a <em>random</em>
  158. password that was generated just for you. If you lose it, you
  159. will have to delete the tables from the database yourself, and re-install WordPress. So to review:
  160. </p>
  161. <dl>
  162. <dt>Login</dt>
  163. <dd><code>admin</code></dd>
  164. <dt>Password</dt>
  165. <dd><code><?php echo $random_password; ?></code></dd>
  166. <dt>Login address</dt>
  167. <dd><a href="../wp-login.php">wp-login.php</a></dd>
  168. </dl>
  169. <p>Were you expecting more steps? Sorry to disappoint. All done! :)</p>
  170. <?php
  171. break;
  172. }
  173. ?>
  174. <p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p>
  175. </body>
  176. </html>