]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/install.php
Wordpress 2.0.4
[autoinstalls/wordpress.git] / wp-admin / install.php
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 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
10 $guessurl = str_replace('/wp-admin/install.php?step=2', '', $schema . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) );
11
12 if (isset($_GET['step']))
13         $step = $_GET['step'];
14 else
15         $step = 0;
16 header( 'Content-Type: text/html; charset=utf-8' );
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><?php _e('WordPress &rsaquo; Installation'); ?></title>
22         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
23         <style media="screen" type="text/css">
24         <!--
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 {
38                 color: #006;
39                 font-size: 18px;
40                 font-weight: lighter;
41         }
42         
43         h2 {
44                 font-size: 16px;
45         }
46         
47         p, li, dt {
48                 line-height: 140%;
49                 padding-bottom: 2px;
50         }
51
52         ul, ol {
53                 padding: 5px 5px 5px 20px;
54         }
55         #logo {
56                 margin-bottom: 2em;
57         }
58         .step a, .step input {
59                 font-size: 2em;
60         }
61         td input {
62                 font-size: 1.5em;
63         }
64         .step, th {
65                 text-align: right;
66         }
67         #footer {
68                 text-align: center; 
69                 border-top: 1px solid #ccc; 
70                 padding-top: 1em; 
71                 font-style: italic;
72         }
73         -->
74         </style>
75 </head>
76 <body>
77 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
78 <?php
79 // Let's check to make sure WP isn't already installed.
80 $wpdb->hide_errors();
81 $installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
82 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>');
83 $wpdb->show_errors();
84
85 switch($step) {
86
87         case 0:
88 ?>
89 <p><?php printf(__('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="%s">ReadMe documentation</a> at your leisure.'), '../readme.html'); ?></p>
90         <h2 class="step"><a href="install.php?step=1"><?php _e('First Step &raquo;'); ?></a></h2>
91 <?php
92         break;
93
94         case 1:
95
96 ?>
97 <h1><?php _e('First Step'); ?></h1>
98 <p><?php _e("Before we begin we need a little bit of information. Don't worry, you can always change these later."); ?></p>
99
100 <form id="setup" method="post" action="install.php?step=2">
101 <table width="100%">
102 <tr>
103 <th width="33%"><?php _e('Weblog title:'); ?></th>
104 <td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
105 </tr>
106 <tr>
107 <th><?php _e('Your e-mail:'); ?></th>
108         <td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
109 </tr>
110 </table>
111 <p><em><?php _e('Double-check that email address before continuing.'); ?></em></p>
112 <h2 class="step">
113 <input type="submit" name="Submit" value="<?php _e('Continue to Second Step &raquo;'); ?>" />
114 </h2>
115 </form>
116
117 <?php
118         break;
119         case 2:
120
121 // Fill in the data we gathered
122 $weblog_title = stripslashes($_POST['weblog_title']);
123 $admin_email = stripslashes($_POST['admin_email']);
124 // check e-mail address
125 if (empty($admin_email)) {
126         die (__("<strong>ERROR</strong>: please type your e-mail address"));
127 } else if (!is_email($admin_email)) {
128         die (__("<strong>ERROR</strong>: the e-mail address isn't correct"));
129 }
130         
131 ?>
132 <h1><?php _e('Second Step'); ?></h1>
133 <p><?php _e('Now we&#8217;re going to create the database tables and fill them with some default data.'); ?></p>
134
135
136 <?php
137 flush();
138
139 // Set everything up
140 wp_cache_flush();
141 make_db_current_silent();
142 populate_options();
143 populate_roles();
144
145 update_option('blogname', $weblog_title);
146 update_option('admin_email', $admin_email);
147
148 // Now drop in some default links
149 $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')");
150 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/', '');");
151 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/', '');");
152 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/', '');");
153 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/', '');");
154 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/', '');");
155 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php', '');");
156 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');");
157
158 // Default category
159 $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
160
161 // First post
162 $now = date('Y-m-d H:i:s');
163 $now_gmt = gmdate('Y-m-d H:i:s');
164 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
165
166 $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
167
168 // Default comment
169 $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('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.'))."')");
170
171 // First Page
172
173 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'static', '', '', '')");
174 $wp_rewrite->flush_rules();
175
176 // Set up admin user
177 $random_password = substr(md5(uniqid(microtime())), 0, 6);
178 $display_name_array = explode('@', $admin_email);
179 $display_name = $display_name_array[0];
180 $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', 'admin', MD5('$random_password'), '$admin_email', NOW(), '$display_name', 'admin')");
181 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}user_level', '10');");
182 $admin_caps = serialize(array('administrator' => true));
183 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}capabilities', '{$admin_caps}');");
184
185 $message_headers = 'From: ' . $weblog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
186 $message = sprintf(__("Your new WordPress blog has been successfully set up at:
187
188 %1\$s
189
190 You can log in to the administrator account with the following information:
191
192 Username: admin
193 Password: %2\$s
194
195 We hope you enjoy your new weblog. Thanks!
196
197 --The WordPress Team
198 http://wordpress.org/
199 "), $guessurl, $random_password);
200
201 @wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
202
203 wp_cache_flush();
204 ?>
205
206 <p><em><?php _e('Finished!'); ?></em></p>
207
208 <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>
209 <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:'); ?>
210 </p>
211 <dl>
212 <dt><?php _e('Username'); ?></dt>
213 <dd><code>admin</code></dd>
214 <dt><?php _e('Password'); ?></dt>
215 <dd><code><?php echo $random_password; ?></code></dd>
216         <dt><?php _e('Login address'); ?></dt>
217 <dd><a href="../wp-login.php">wp-login.php</a></dd>
218 </dl>
219 <p><?php _e('Were you expecting more steps? Sorry to disappoint. All done! :)'); ?></p>
220 <?php
221         break;
222 }
223 ?>
224 <p id="footer"><?php _e('<a href="http://wordpress.org/">WordPress</a>, personal publishing platform.'); ?></p>
225 </body>
226 </html>