Make WordPress Core


Ignore:
Timestamp:
03/31/2006 08:07:39 AM (19 years ago)
Author:
ryan
Message:

Pluggable install functions. fixes #2616

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/install.php

    r3604 r3670  
    66require_once('../wp-config.php');
    77require_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']) );
    118
    129if (isset($_GET['step']))
     
    7875<?php
    7976// 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();
     77if ( is_blog_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>');
    8478
    8579switch($step) {
     
    142136flush();
    143137
    144 // Set everything up
    145 wp_cache_flush();
    146 make_db_current_silent();
    147 populate_options();
    148 populate_roles();
    149 
    150 update_option('blogname', $weblog_title);
    151 update_option('admin_email', $admin_email);
    152 update_option('blog_public', $public);
    153 // If not a public blog, don't ping.
    154 if ( ! $public )
    155     update_option('default_pingback_flag', 0);
    156 
    157 // Default category
    158 $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', '')");
    159 
    160 // Default link category
    161 $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')");
    162 
    163 // Now drop in some default links
    164 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 0, 'http://blogs.linux.ie/xeer/feed/', '');");
    165 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" );
    166 
    167 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');");
    168 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" );
    169 
    170 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');");
    171 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" );
    172 
    173 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');");
    174 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" );
    175 
    176 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');");
    177 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" );
    178 
    179 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');");
    180 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" );
    181 
    182 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');");
    183 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" );
    184 
    185 // First post
    186 $now = date('Y-m-d H:i:s');
    187 $now_gmt = gmdate('Y-m-d H:i:s');
    188 $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', '', '', '')");
    189 
    190 $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
    191 
    192 // Default comment
    193 $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.'))."')");
    194 
    195 // First Page
    196 
    197 $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, post_type, 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', 'publish', 'page', '', '', '')");
    198 $wp_rewrite->flush_rules();
    199 
    200 // Set up admin user
    201 $random_password = substr(md5(uniqid(microtime())), 0, 6);
    202 $display_name_array = explode('@', $admin_email);
    203 $display_name = $display_name_array[0];
    204 $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')");
    205 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$wpdb->prefix}user_level', '10');");
    206 $admin_caps = serialize(array('administrator' => true));
    207 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$wpdb->prefix}capabilities', '{$admin_caps}');");
    208 
    209 $message_headers = 'From: ' . $weblog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
    210 $message = sprintf(__("Your new WordPress blog has been successfully set up at:
    211 
    212 %1\$s
    213 
    214 You can log in to the administrator account with the following information:
    215 
    216 Username: admin
    217 Password: %2\$s
    218 
    219 We hope you enjoy your new weblog. Thanks!
    220 
    221 --The WordPress Team
    222 http://wordpress.org/
    223 "), $guessurl, $random_password);
    224 
    225 @wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
    226 
    227 wp_cache_flush();
     138$result = wp_install($weblog_title, __('admin'), $admin_email, $public);
     139extract($result);
    228140?>
    229141
    230142<p><em><?php _e('Finished!'); ?></em></p>
    231143
    232 <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>
     144<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', $password); ?></p>
    233145<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:'); ?>
    234146</p>
    235147<dl>
    236148<dt><?php _e('Username'); ?></dt>
    237 <dd><code>admin</code></dd>
     149<dd><code><?php _e('admin') ?></code></dd>
    238150<dt><?php _e('Password'); ?></dt>
    239 <dd><code><?php echo $random_password; ?></code></dd>
     151<dd><code><?php echo $password; ?></code></dd>
    240152    <dt><?php _e('Login address'); ?></dt>
    241153<dd><a href="../wp-login.php">wp-login.php</a></dd>
Note: See TracChangeset for help on using the changeset viewer.