X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/0f29eadd474473203a1182f52af1aa82721cecbd..c81aba3d563f7459dc79140e4c5be67bcf506b92:/wp-admin/install.php?ds=sidebyside diff --git a/wp-admin/install.php b/wp-admin/install.php index eb635aa2..0e30ec0c 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -1,225 +1,383 @@ wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."); - -require_once('../wp-config.php'); -require_once('./upgrade-functions.php'); - -$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; -$guessurl = str_replace('/wp-admin/install.php?step=2', '', $schema . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ); - -if (isset($_GET['step'])) - $step = $_GET['step']; -else - $step = 0; -header( 'Content-Type: text/html; charset=utf-8' ); +/** + * WordPress Installer + * + * @package WordPress + * @subpackage Administration + */ + +// Sanity check. +if ( false ) { ?> - + - <?php _e('WordPress › Installation'); ?> - +?> + +> + + + + + <?php _e( 'WordPress › Installation' ); ?> + - -

WordPress

-hide_errors(); -$installed = $wpdb->get_results("SELECT * FROM $wpdb->users"); -if ($installed) die('

'.__('Already Installed').'

'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'

'); -$wpdb->show_errors(); - -switch($step) { + + - case 0: -?> -

ReadMe documentation at your leisure.'), '../readme.html'); ?>

-

prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->users ) ); + $user_table = ( $wpdb->get_var( $sql ) != null ); + + // Ensure that Blogs appear in search engines by default. + $blog_public = 1; + if ( isset( $_POST['weblog_title'] ) ) { + $blog_public = isset( $_POST['blog_public'] ); + } - case 1: + $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; + $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; + $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : ''; + if ( ! is_null( $error ) ) { ?> -

-

- -
- - - - - - - - - -
-

-

- -

+

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ '; + } else { + ?> +

+ +
+ + +
+ + + +
+
+

+ + +

+
+ + + +
+ +
+

+
+ + + /> +
+ /> + +

+ + +

+ +
+
+

'submit' ) ); ?>

+
- ERROR: please type your e-mail address")); -} else if (!is_email($admin_email)) { - die (__("ERROR: the e-mail address isn't correct")); +// Let's check to make sure WP isn't already installed. +if ( is_blog_installed() ) { + display_header(); + die( '

' . __( 'Already Installed' ) . '

' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '

' . __( 'Log In' ) . '

' ); } - -?> -

-

- - -query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')"); -$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/', '');"); -$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/', '');"); -$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/', '');"); -$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/', '');"); -$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/', '');"); -$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', '');"); -$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/', '');"); - -// Default category -$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', '')"); - -// First post -$now = date('Y-m-d H:i:s'); -$now_gmt = gmdate('Y-m-d H:i:s'); -$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', '', '', '')"); - -$wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" ); -// Default comment -$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.
To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.'))."')"); - -// First Page -$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', '', '', '')"); -$wp_rewrite->flush_rules(); - -// Set up admin user -$random_password = substr(md5(uniqid(microtime())), 0, 6); -$display_name_array = explode('@', $admin_email); -$display_name = $display_name_array[0]; -$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')"); -$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}user_level', '10');"); -$admin_caps = serialize(array('administrator' => true)); -$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}capabilities', '{$admin_caps}');"); +/** + * @global string $wp_version + * @global string $required_php_version + * @global string $required_mysql_version + * @global wpdb $wpdb + */ +global $wp_version, $required_php_version, $required_mysql_version; + +$php_version = phpversion(); +$mysql_version = $wpdb->db_version(); +$php_compat = version_compare( $php_version, $required_php_version, '>=' ); +$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); + +if ( !$mysql_compat && !$php_compat ) + $compat = sprintf( __( 'You cannot install because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ); +elseif ( !$php_compat ) + $compat = sprintf( __( 'You cannot install because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ); +elseif ( !$mysql_compat ) + $compat = sprintf( __( 'You cannot install because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version ); + +if ( !$mysql_compat || !$php_compat ) { + display_header(); + die( '

' . __( 'Insufficient Requirements' ) . '

' . $compat . '

' ); +} -$message_headers = 'From: "' . $weblog_title . '" '; -$message = sprintf(__("Your new WordPress blog has been successfully set up at: +if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) { + display_header(); + die( '

' . __( 'Configuration Error' ) . '

' . __( 'Your wp-config.php file has an empty database table prefix, which is not supported.' ) . '

' ); +} -%1\$s +// Set error message if DO_NOT_UPGRADE_GLOBAL_TABLES isn't set as it will break install. +if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { + display_header(); + die( '

' . __( 'Configuration Error' ) . '

' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when installing WordPress.' ) . '

' ); +} -You can log in to the administrator account with the following information: +/** + * @global string $wp_local_package + * @global WP_Locale $wp_locale + */ +$language = ''; +if ( ! empty( $_REQUEST['language'] ) ) { + $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] ); +} elseif ( isset( $GLOBALS['wp_local_package'] ) ) { + $language = $GLOBALS['wp_local_package']; +} -Username: admin -Password: %2\$s +switch($step) { + case 0: // Step 0 + + if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) { + display_header( 'language-chooser' ); + echo '
'; + wp_install_language_form( $languages ); + echo '
'; + break; + } + + // Deliberately fall through if we can't reach the translations API. + + case 1: // Step 1, direct link or from language chooser. + if ( ! empty( $language ) ) { + $loaded_language = wp_download_language_pack( $language ); + if ( $loaded_language ) { + load_default_textdomain( $loaded_language ); + $GLOBALS['wp_locale'] = new WP_Locale(); + } + } + + display_header(); +?> +

+

-We hope you enjoy your new weblog. Thanks! +

+

---The WordPress Team -http://wordpress.org/ -"), $guessurl, $random_password); +error ) ) + wp_die( $wpdb->error->get_error_message() ); + + display_header(); + // Fill in the data we gathered + $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; + $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; + $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : ''; + $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : ''; + $admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : ''; + $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 1; + + // Check email address. + $error = false; + if ( empty( $user_name ) ) { + // TODO: poka-yoke + display_setup_form( __( 'Please provide a valid username.' ) ); + $error = true; + } elseif ( $user_name != sanitize_user( $user_name, true ) ) { + display_setup_form( __( 'The username you provided has invalid characters.' ) ); + $error = true; + } elseif ( $admin_password != $admin_password_check ) { + // TODO: poka-yoke + display_setup_form( __( 'Your passwords do not match. Please try again.' ) ); + $error = true; + } elseif ( empty( $admin_email ) ) { + // TODO: poka-yoke + display_setup_form( __( 'You must provide an email address.' ) ); + $error = true; + } elseif ( ! is_email( $admin_email ) ) { + // TODO: poka-yoke + display_setup_form( __( 'Sorry, that isn’t a valid email address. Email addresses look like username@example.com.' ) ); + $error = true; + } + + if ( $error === false ) { + $wpdb->show_errors(); + $result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ), $loaded_language ); +?> -@wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers); +

+ +

+ + + + + + + + + + +
+
+ +

+
-wp_cache_flush(); -?> +

-

- -

log in with the username "admin" and password "%2$s".'), '../wp-login.php', $random_password); ?>

-

Note that password carefully! It is a random 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:'); ?> -

-
-
-
admin
-
-
-
-
wp-login.php
-
-

- + + + + +