Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r4307 r3373  
    11<?php
    22define('WP_INSTALLING', true);
    3 if (!file_exists('../wp-config.php')) {
    4   require_once('../wp-includes/functions.php');
    5   wp_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://codex.wordpress.org/Installing_WordPress#Step_3:_Set_up_wp-config.php'>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.", "WordPress &rsaquo; Error");
    6 }
     3if (!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.");
    75
    86require_once('../wp-config.php');
    97require_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']) );
    1011
    1112if (isset($_GET['step']))
     
    1617?>
    1718<!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" <?php language_attributes(); ?>>
     19<html xmlns="http://www.w3.org/1999/xhtml">
    1920<head>
     21    <title><?php _e('WordPress &rsaquo; Installation'); ?></title>
    2022    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    21     <title><?php _e('WordPress &rsaquo; Installation'); ?></title>
    22     <link rel="stylesheet" href="install.css?version=<?php bloginfo('version'); ?>" type="text/css" />
    23     <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
    24     <link rel="stylesheet" href="install-rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
    25     <?php endif; ?>
     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>
    2675</head>
    2776<body>
     
    2978<?php
    3079// Let's check to make sure WP isn't already installed.
    31 if ( 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>');
     80$wpdb->hide_errors();
     81$installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
     82if ($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();
    3284
    3385switch($step) {
     86
    3487    case 0:
    3588?>
    3689<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>
    37 <h2 class="step"><a href="install.php?step=1"><?php _e('First Step &raquo;'); ?></a></h2>
    38 <?php
    39         break;
     90    <h2 class="step"><a href="install.php?step=1"><?php _e('First Step &raquo;'); ?></a></h2>
     91<?php
     92    break;
     93
    4094    case 1:
     95
    4196?>
    4297<h1><?php _e('First Step'); ?></h1>
     
    4499
    45100<form id="setup" method="post" action="install.php?step=2">
    46     <table width="100%">
    47         <tr>
    48             <th width="33%"><?php _e('Weblog title:'); ?></th>
    49             <td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
    50         </tr>
    51         <tr>
    52             <th><?php _e('Your e-mail:'); ?></th>
    53             <td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
    54         </tr>
    55         <tr>
    56             <th scope="row"  valign="top"> <?php __('Privacy:'); ?></th>
    57             <td><label><input type="checkbox" name="blog_public" value="1" checked="checked" /> <?php _e('I would like my blog to appear in search engines like Google and Technorati.'); ?></label></td>
    58         </tr>
    59     </table>
    60     <p><em><?php _e('Double-check that email address before continuing.'); ?></em></p>
    61     <h2 class="step"><input type="submit" name="Submit" value="<?php _e('Continue to Second Step &raquo;'); ?>" /></h2>
     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>
    62115</form>
    63116
    64117<?php
    65         break;
     118    break;
    66119    case 2:
    67         // Fill in the data we gathered
    68         $weblog_title = stripslashes($_POST['weblog_title']);
    69         $admin_email = stripslashes($_POST['admin_email']);
    70         $public = (int) $_POST['blog_public'];
    71         // check e-mail address
    72         if (empty($admin_email)) {
    73             die(__("<strong>ERROR</strong>: please type your e-mail address"));
    74         } else if (!is_email($admin_email)) {
    75             die(__("<strong>ERROR</strong>: the e-mail address isn't correct"));
    76         }
    77 
     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
     125if (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   
    78131?>
    79132<h1><?php _e('Second Step'); ?></h1>
     
    82135
    83136<?php
    84     $result = wp_install($weblog_title, __('admin'), $admin_email, $public);
    85     extract($result);
     137flush();
     138
     139// Set everything up
     140wp_cache_flush();
     141make_db_current_silent();
     142populate_options();
     143populate_roles();
     144
     145update_option('blogname', $weblog_title);
     146update_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
     190You can log in to the administrator account with the following information:
     191
     192Username: admin
     193Password: %2\$s
     194
     195We hope you enjoy your new weblog. Thanks!
     196
     197--The WordPress Team
     198http://wordpress.org/
     199"), $guessurl, $random_password);
     200
     201@wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
     202
     203wp_cache_flush();
    86204?>
    87205
    88206<p><em><?php _e('Finished!'); ?></em></p>
    89207
    90 <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>
    91 <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:'); ?></p>
    92 
     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>
    93211<dl>
    94     <dt><?php _e('Username'); ?></dt>
    95         <dd><code><?php _e('admin') ?></code></dd>
    96     <dt><?php _e('Password'); ?></dt>
    97         <dd><code><?php echo $password; ?></code></dd>
     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>
    98216    <dt><?php _e('Login address'); ?></dt>
    99         <dd><a href="../wp-login.php">wp-login.php</a></dd>
     217<dd><a href="../wp-login.php">wp-login.php</a></dd>
    100218</dl>
    101219<p><?php _e('Were you expecting more steps? Sorry to disappoint. All done! :)'); ?></p>
    102 
    103 <?php
    104         break;
     220<?php
     221    break;
    105222}
    106223?>
    107 
    108224<p id="footer"><?php _e('<a href="http://wordpress.org/">WordPress</a>, personal publishing platform.'); ?></p>
    109225</body>
Note: See TracChangeset for help on using the changeset viewer.