home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-admin / install.php < prev    next >
Encoding:
PHP Script  |  2005-04-22  |  8.8 KB  |  215 lines

  1. <?php
  2. define('WP_INSTALLING', true);
  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.  
  6. require_once('../wp-config.php');
  7. require_once('./upgrade-functions.php');
  8.  
  9. $guessurl = str_replace('/wp-admin/install.php?step=2', '', 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) );
  10.  
  11. if (isset($_GET['step']))
  12.     $step = $_GET['step'];
  13. else
  14.     $step = 0;
  15. header( 'Content-Type: text/html; charset=utf-8' );
  16. ?>
  17. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  18. <html xmlns="http://www.w3.org/1999/xhtml">
  19. <head>
  20.     <title><?php _e('WordPress › Installation'); ?></title>
  21.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  22.     <style media="screen" type="text/css">
  23.     <!--
  24.     html {
  25.         background: #eee;
  26.     }
  27.     body {
  28.         background: #fff;
  29.         color: #000;
  30.         font-family: Georgia, "Times New Roman", Times, serif;
  31.         margin-left: 20%;
  32.         margin-right: 20%;
  33.         padding: .2em 2em;
  34.     }
  35.     
  36.     h1 {
  37.         color: #006;
  38.         font-size: 18px;
  39.         font-weight: lighter;
  40.     }
  41.     
  42.     h2 {
  43.         font-size: 16px;
  44.     }
  45.     
  46.     p, li, dt {
  47.         line-height: 140%;
  48.         padding-bottom: 2px;
  49.     }
  50.  
  51.     ul, ol {
  52.         padding: 5px 5px 5px 20px;
  53.     }
  54.     #logo {
  55.         margin-bottom: 2em;
  56.     }
  57.     .step a, .step input {
  58.         font-size: 2em;
  59.     }
  60.     td input {
  61.         font-size: 1.5em;
  62.     }
  63.     .step, th {
  64.         text-align: right;
  65.     }
  66.     #footer {
  67.         text-align: center; 
  68.         border-top: 1px solid #ccc; 
  69.         padding-top: 1em; 
  70.         font-style: italic;
  71.     }
  72.     -->
  73.     </style>
  74. </head>
  75. <body>
  76. <h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
  77. <?php
  78. // Let's check to make sure WP isn't already installed.
  79. $wpdb->hide_errors();
  80. $installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
  81. 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>');
  82. $wpdb->show_errors();
  83.  
  84. switch($step) {
  85.  
  86.     case 0:
  87. ?>
  88. <p><?php printf(__('Welcome to WordPress installation. We’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="%s">ReadMe documentation</a> at your leisure.'), '../readme.html'); ?></p>
  89.     <h2 class="step"><a href="install.php?step=1"><?php _e('First Step »'); ?></a></h2>
  90. <?php
  91.     break;
  92.  
  93.     case 1:
  94.  
  95. ?>
  96. <h1><?php _e('First Step'); ?></h1>
  97. <p><?php _e("Before we begin we need a little bit of information. Don't worry, you can always change these later."); ?></p>
  98.  
  99. <form id="setup" method="post" action="install.php?step=2">
  100. <table width="100%">
  101. <tr>
  102. <th width="33%"><?php _e('Weblog title:'); ?></th>
  103. <td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
  104. </tr>
  105. <tr>
  106. <th><?php _e('Your e-mail:'); ?></th>
  107.     <td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
  108. </tr>
  109. </table>
  110. <p><em><?php _e('Double-check that email address before continuing.'); ?></em></p>
  111. <h2 class="step">
  112. <input type="submit" name="Submit" value="<?php _e('Continue to Second Step »'); ?>" />
  113. </h2>
  114. </form>
  115.  
  116. <?php
  117.     break;
  118.     case 2:
  119.  
  120. // Fill in the data we gathered
  121. $weblog_title = $_POST['weblog_title'];
  122. $admin_email = $_POST['admin_email'];
  123. // check e-mail address
  124. if (empty($admin_email)) {
  125.     die (__("<strong>ERROR</strong>: please type your e-mail address"));
  126. } else if (!is_email($admin_email)) {
  127.     die (__("<strong>ERROR</strong>: the e-mail address isn't correct"));
  128. }
  129.     
  130. ?>
  131. <h1><?php _e('Second Step'); ?></h1>
  132. <p><?php _e('Now we’re going to create the database tables and fill them with some default data.'); ?></p>
  133.  
  134.  
  135. <?php
  136. flush();
  137.  
  138. // Set everything up
  139. make_db_current_silent();
  140. populate_options();
  141.  
  142. $wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'");
  143. $wpdb->query("UPDATE $wpdb->options SET option_value = '$admin_email' WHERE option_name = 'admin_email'");
  144.  
  145. // Now drop in some default links
  146. $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
  147. $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/');");
  148. $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/');");
  149. $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/');");
  150. $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
  151. $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/');");
  152. $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/');");
  153. $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');");
  154. $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/');");
  155.  
  156. // Default category
  157. $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
  158.  
  159. // First post
  160. $now = date('Y-m-d H:i:s');
  161. $now_gmt = gmdate('Y-m-d H:i:s');
  162. $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('1', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt')");
  163.  
  164. $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
  165.  
  166. // Default comment
  167. $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', '".addslashes(__('Mr WordPress'))."', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', '".addslashes(__('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.'))."')");
  168.  
  169. // Set up admin user
  170. $random_password = substr(md5(uniqid(microtime())), 0, 6);
  171. $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'), '".addslashes(__('Administrator'))."', '$admin_email', '10', 'nickname', NOW() )");
  172.  
  173. $message_headers = 'From: ' . stripslashes($_POST['weblog_title']) . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
  174. $message = sprintf(__("Your new WordPress blog has been successfully set up at:
  175.  
  176. %1\$s
  177.  
  178. You can log in to the administrator account with the following information:
  179.  
  180. Username: admin
  181. Password: %2\$s
  182.  
  183. We hope you enjoy your new weblog. Thanks!
  184.  
  185. --The WordPress Team
  186. http://wordpress.org/
  187. "), $guessurl, $random_password);
  188.  
  189. @mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
  190.  
  191. upgrade_all();
  192. ?>
  193.  
  194. <p><em><?php _e('Finished!'); ?></em></p>
  195.  
  196. <p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>admin</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $random_password); ?></p>
  197. <p><?php _e('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you. If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?>
  198. </p>
  199. <dl>
  200. <dt><?php _e('Username'); ?></dt>
  201. <dd><code>admin</code></dd>
  202. <dt><?php _e('Password'); ?></dt>
  203. <dd><code><?php echo $random_password; ?></code></dd>
  204.     <dt><?php _e('Login address'); ?></dt>
  205. <dd><a href="../wp-login.php">wp-login.php</a></dd>
  206. </dl>
  207. <p><?php _e('Were you expecting more steps? Sorry to disappoint. All done! :)'); ?></p>
  208. <?php
  209.     break;
  210. }
  211. ?>
  212. <p id="footer"><?php _e('<a href="http://wordpress.org/">WordPress</a>, personal publishing platform.'); ?></p>
  213. </body>
  214. </html>
  215.