wp/wp-admin/install.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * WordPress Installer
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Administration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
// Sanity check.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
if ( false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
<!DOCTYPE html>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
<html xmlns="http://www.w3.org/1999/xhtml">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
<head>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
	<title>Error: PHP is not running</title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
</head>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
<body class="wp-core-ui">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
	<h1 id="logo"><a href="https://wordpress.org/">WordPress</a></h1>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
	<h2>Error: PHP is not running</h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
	<p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
</body>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
</html>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
 * We are installing WordPress.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
 * @since 1.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
 * @var bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
define( 'WP_INSTALLING', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
/** Load WordPress Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
/** Load WordPress Administration Upgrade API */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
/** Load WordPress Translation Install API */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
/** Load wpdb */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
require_once( ABSPATH . WPINC . '/wp-db.php' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    47
nocache_headers();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
 * Display install header.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    56
function display_header( $body_classes = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
	header( 'Content-Type: text/html; charset=utf-8' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
	if ( is_rtl() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
		$body_classes .= 'rtl';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
	if ( $body_classes ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
		$body_classes = ' ' . $body_classes;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
<!DOCTYPE html>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
<head>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
	<meta name="viewport" content="width=device-width" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	<title><?php _e( 'WordPress &rsaquo; Installation' ); ?></title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	wp_admin_css( 'install', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
</head>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    75
<body class="wp-core-ui<?php echo $body_classes ?>">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    76
<h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
} // end display_header()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
 * Display installer setup form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
function display_setup_form( $error = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
	global $wpdb;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    88
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    89
	$sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->users ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    90
	$user_table = ( $wpdb->get_var( $sql ) != null );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    92
	// Ensure that Blogs appear in search engines by default.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
	$blog_public = 1;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
	if ( isset( $_POST['weblog_title'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
		$blog_public = isset( $_POST['blog_public'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    96
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
	$user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
	$admin_email  = isset( $_POST['admin_email']  ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
	if ( ! is_null( $error ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
<p class="message"><?php echo $error; ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
<?php } ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
<form id="setup" method="post" action="install.php?step=2" novalidate="novalidate">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
			<th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
			<td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
			<th scope="row"><label for="user_login"><?php _e('Username'); ?></label></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
			<td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
			if ( $user_table ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
				_e('User(s) already exists.');
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
				echo '<input name="user_name" type="hidden" value="admin" />';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
				?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" />
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
				<p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods, and the @ symbol.' ); ?></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
			<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
			} ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
			</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
		<?php if ( ! $user_table ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
			<th scope="row">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   129
				<label for="pass1"><?php _e('Password, twice'); ?></label>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
				<p><?php _e('A password will be automatically generated for you if you leave this blank.'); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
			</th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
			<td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
				<input name="admin_password" type="password" id="pass1" size="25" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
				<p><input name="admin_password2" type="password" id="pass2" size="25" value="" /></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
				<div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
				<p><?php echo wp_get_password_hint(); ?></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
			</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
			<th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   142
			<td><input name="admin_email" type="email" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
			<p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
		<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   146
			<th scope="row"><?php _e( 'Privacy' ); ?></th>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   147
			<td colspan="2"><label><input type="checkbox" name="blog_public" id="blog_public" value="1" <?php checked( $blog_public ); ?> /> <?php _e( 'Allow search engines to index this site.' ); ?></label></td>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
	</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
	<p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button button-large" /></p>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
	<input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
} // end display_setup_form()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
// Let's check to make sure WP isn't already installed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
if ( is_blog_installed() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
	display_header();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
	die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p><p class="step"><a href="../wp-login.php" class="button button-large">' . __( 'Log In' ) . '</a></p></body></html>' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   162
global $wp_version, $required_php_version, $required_mysql_version;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   163
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
$php_version    = phpversion();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
$mysql_version  = $wpdb->db_version();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
$mysql_compat   = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
if ( !$mysql_compat && !$php_compat )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   170
	$compat = sprintf( __( 'You cannot install because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> 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 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
elseif ( !$php_compat )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   172
	$compat = sprintf( __( 'You cannot install because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
elseif ( !$mysql_compat )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   174
	$compat = sprintf( __( 'You cannot install because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
if ( !$mysql_compat || !$php_compat ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
	display_header();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
	die( '<h1>' . __( 'Insufficient Requirements' ) . '</h1><p>' . $compat . '</p></body></html>' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
	display_header();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
	die( '<h1>' . __( 'Configuration Error' ) . '</h1><p>' . __( 'Your <code>wp-config.php</code> file has an empty database table prefix, which is not supported.' ) . '</p></body></html>' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
$language = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
if ( ! empty( $_REQUEST['language'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   188
	$language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   189
} elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   190
	$language = $GLOBALS['wp_local_package'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   191
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   192
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
switch($step) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   194
	case 0: // Step 0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   195
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   196
		if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   197
			display_header( 'language-chooser' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   198
			echo '<form id="setup" method="post" action="?step=1">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   199
			wp_install_language_form( $languages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   200
			echo '</form>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   201
			break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
		// Deliberately fall through if we can't reach the translations API.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
	case 1: // Step 1, direct link or from language chooser.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
		if ( ! empty( $language ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
			$loaded_language = wp_download_language_pack( $language );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
			if ( $loaded_language ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
				load_default_textdomain( $loaded_language );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   211
				$GLOBALS['wp_locale'] = new WP_Locale();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   213
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   214
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   215
		display_header();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
<h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   218
<p><?php _e( 'Welcome to the famous five-minute WordPress installation process! Just fill in the information below and you&#8217;ll be on your way to using the most extendable and powerful personal publishing platform in the world.' ); ?></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
<h1><?php _e( 'Information needed' ); ?></h1>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
<p><?php _e( 'Please provide the following information. Don&#8217;t worry, you can always change these settings later.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
		display_setup_form();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
	case 2:
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
		if ( ! empty( $language ) && load_default_textdomain( $language ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
			$loaded_language = $language;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   229
			$GLOBALS['wp_locale'] = new WP_Locale();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   230
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   231
			$loaded_language = 'en_US';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   232
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   233
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
		if ( ! empty( $wpdb->error ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
			wp_die( $wpdb->error->get_error_message() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
		display_header();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
		// Fill in the data we gathered
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
		$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		$user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
		$admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
		$admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   243
		$admin_email  = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   244
		$public       = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   245
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   246
		// Check e-mail address.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
		$error = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
		if ( empty( $user_name ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
			// TODO: poka-yoke
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
			display_setup_form( __( 'Please provide a valid username.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
			$error = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
		} elseif ( $user_name != sanitize_user( $user_name, true ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
			display_setup_form( __( 'The username you provided has invalid characters.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
			$error = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
		} elseif ( $admin_password != $admin_password_check ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
			// TODO: poka-yoke
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
			display_setup_form( __( 'Your passwords do not match. Please try again.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
			$error = true;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   259
		} elseif ( empty( $admin_email ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
			// TODO: poka-yoke
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
			display_setup_form( __( 'You must provide an email address.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
			$error = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
		} elseif ( ! is_email( $admin_email ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
			// TODO: poka-yoke
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
			display_setup_form( __( 'Sorry, that isn&#8217;t a valid email address. Email addresses look like <code>username@example.com</code>.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
			$error = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
		if ( $error === false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
			$wpdb->show_errors();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
			$result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ), $loaded_language );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
<h1><?php _e( 'Success!' ); ?></h1>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
<p><?php _e( 'WordPress has been installed. Were you expecting more steps? Sorry to disappoint.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
<table class="form-table install-success">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
		<th><?php _e( 'Username' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
		<td><?php echo esc_html( sanitize_user( $user_name, true ) ); ?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
	<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
		<th><?php _e( 'Password' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		<td><?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   286
		if ( ! empty( $result['password'] ) && empty( $admin_password_check ) ): ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   287
			<code><?php echo esc_html( $result['password'] ) ?></code><br />
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   288
		<?php endif ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   289
			<p><?php echo $result['password_message'] ?></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
		</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
<p class="step"><a href="../wp-login.php" class="button button-large"><?php _e( 'Log In' ); ?></a></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
if ( !wp_is_mobile() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
<script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
<?php } ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
<?php wp_print_scripts( 'user-profile' ); ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   305
<?php wp_print_scripts( 'language-chooser' ); ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
</body>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
</html>