X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/e0feb3b2e5b436a06bbb04fbc838d1cd6ec95399..b925718b4bf2dd47a8429f844d0a255ca6e35bd1:/wp-admin/setup-config.php?ds=sidebyside diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php index 7951e967..befa6937 100644 --- a/wp-admin/setup-config.php +++ b/wp-admin/setup-config.php @@ -46,15 +46,26 @@ if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) elseif ( file_exists( dirname( ABSPATH ) . '/wp-config-sample.php' ) ) $config_file = file( dirname( ABSPATH ) . '/wp-config-sample.php' ); else - wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' ) ); + wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file to your WordPress installation.' ) ); // Check if wp-config.php has been created if ( file_exists( ABSPATH . 'wp-config.php' ) ) - wp_die( '

' . sprintf( __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now." ), 'install.php' ) . '

' ); + wp_die( '

' . sprintf( + /* translators: %s: install.php */ + __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now." ), + 'install.php' + ) . '

' + ); // Check if wp-config.php exists above the root directory but is not part of another install -if ( file_exists(ABSPATH . '../wp-config.php' ) && ! file_exists( ABSPATH . '../wp-settings.php' ) ) - wp_die( '

' . sprintf( __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now."), 'install.php' ) . '

' ); +if ( @file_exists( ABSPATH . '../wp-config.php' ) && ! @file_exists( ABSPATH . '../wp-settings.php' ) ) { + wp_die( '

' . sprintf( + /* translators: %s: install.php */ + __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now." ), + 'install.php' + ) . '

' + ); +} $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : -1; @@ -83,11 +94,12 @@ function setup_config_display_header( $body_classes = array() ) { + <?php _e( 'WordPress › Setup Configuration File' ); ?> -

+ Select a default language'; echo '
'; wp_install_language_form( $languages ); echo '
'; @@ -128,7 +141,7 @@ switch($step) { $step_1 .= '&language=' . $loaded_language; } ?> - +

  1. @@ -137,12 +150,26 @@ switch($step) {
-

- wp-config.php file.' ); ?> - wp-config-sample.php in a text editor, fill in your information, and save it as wp-config.php." ); ?> - We got it." ); ?> -

-

+

wp-config.php' + ); + ?> + wp-config-sample.php', + 'wp-config.php' + ); + ?> + We got it.' ), + __( 'https://codex.wordpress.org/Editing_wp-config.php' ) + ); +?>

+

+

-

+

- + - + - + - + - + @@ -245,21 +276,34 @@ switch($step) { if ( ! empty( $wpdb->error ) ) wp_die( $wpdb->error->get_error_message() . $tryagain_link ); - // Fetch or generate keys and salts. - $no_api = isset( $_POST['noapi'] ); - if ( ! $no_api ) { - $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); - } - - if ( $no_api || is_wp_error( $secret_keys ) ) { - $secret_keys = array(); + // Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password(). + try { + $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|'; + $max = strlen($chars) - 1; for ( $i = 0; $i < 8; $i++ ) { - $secret_keys[] = wp_generate_password( 64, true, true ); + $key = ''; + for ( $j = 0; $j < 64; $j++ ) { + $key .= substr( $chars, random_int( 0, $max ), 1 ); + } + $secret_keys[] = $key; } - } else { - $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) ); - foreach ( $secret_keys as $k => $v ) { - $secret_keys[$k] = substr( $v, 28, 64 ); + } catch ( Exception $ex ) { + $no_api = isset( $_POST['noapi'] ); + + if ( ! $no_api ) { + $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); + } + + if ( $no_api || is_wp_error( $secret_keys ) ) { + $secret_keys = array(); + for ( $i = 0; $i < 8; $i++ ) { + $secret_keys[] = wp_generate_password( 64, true, true ); + } + } else { + $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) ); + foreach ( $secret_keys as $k => $v ) { + $secret_keys[$k] = substr( $v, 28, 64 ); + } } } @@ -306,10 +350,16 @@ switch($step) { if ( ! is_writable(ABSPATH) ) : setup_config_display_header(); ?> -

wp-config.php file." ); ?>

-

wp-config.php manually and paste the following text into it.' ); ?>

+

wp-config.php' ); +?>

+

wp-config.php' ); +?>

@@ -336,14 +386,15 @@ if ( ! /iPad|iPod|iPhone/.test( navigator.userAgent ) ) { $path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php'; $handle = fopen( $path_to_wp_config, 'w' ); - foreach( $config_file as $line ) { + foreach ( $config_file as $line ) { fwrite( $handle, $line ); } fclose( $handle ); chmod( $path_to_wp_config, 0666 ); setup_config_display_header(); ?> -

+

+

localhost does not work.' ); ?>localhost' ); + ?>