diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php index ce3ffe55b7..d8ae356060 100644 --- a/wp-admin/setup-config.php +++ b/wp-admin/setup-config.php @@ -55,6 +55,9 @@ wp_load_translations_early(); // Turn register_globals off. wp_unregister_GLOBALS(); +// Standardize $_SERVER variables across setups. +wp_fix_server_vars(); + require_once(ABSPATH . WPINC . '/compat.php'); require_once(ABSPATH . WPINC . '/class-wp-error.php'); require_once(ABSPATH . WPINC . '/formatting.php'); @@ -198,12 +201,11 @@ switch($step) { if ( ! $no_api ) { require_once( ABSPATH . WPINC . '/class-http.php' ); require_once( ABSPATH . WPINC . '/http.php' ); - wp_fix_server_vars(); /**#@+ * @ignore */ function get_bloginfo() { - return ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . str_replace( $_SERVER['PHP_SELF'], '/wp-admin/setup-config.php', '' ) ); + return wp_guess_url(); } /**#@-*/ $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index fb7be8fdec..d957595e92 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3231,8 +3231,31 @@ function wp_guess_url() { if ( defined('WP_SITEURL') && '' != WP_SITEURL ) { $url = WP_SITEURL; } else { + // The request is for the admin + if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) { + $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] ); + + // The request is for a file in ABSPATH + } elseif ( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/' == ABSPATH ) { + // Strip off any file/query params in the path + $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); + + } else { + if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], ABSPATH ) ) { + // Request is hitting a file inside ABSPATH + $directory = str_replace( ABSPATH, '', dirname( $_SERVER['SCRIPT_FILENAME'] ) ); + // Strip off the sub directory, and any file/query paramss + $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ); + } else { + // Request is hitting a file above ABSPATH + $subdirectory = str_replace( dirname( $_SERVER['SCRIPT_FILENAME'] ), '', ABSPATH ); + // Strip off any file/query params from the path, appending the sub directory to the install + $path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory; + } + } + $schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet - $url = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + $url = $schema . $_SERVER['HTTP_HOST'] . $path; } return rtrim($url, '/'); diff --git a/wp-includes/load.php b/wp-includes/load.php index 6fb608b365..ae69b5c42a 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -445,12 +445,12 @@ function wp_not_installed() { if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) ) wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); } elseif ( ! is_blog_installed() && false === strpos( $_SERVER['PHP_SELF'], 'install.php' ) && !defined( 'WP_INSTALLING' ) ) { - - $link = wp_guess_url() . '/wp-admin/install.php'; - require( ABSPATH . WPINC . '/kses.php' ); require( ABSPATH . WPINC . '/pluggable.php' ); require( ABSPATH . WPINC . '/formatting.php' ); + + $link = wp_guess_url() . '/wp-admin/install.php'; + wp_redirect( $link ); die(); } diff --git a/wp-load.php b/wp-load.php index ef71aec3da..fb859533c3 100644 --- a/wp-load.php +++ b/wp-load.php @@ -50,15 +50,7 @@ if ( file_exists( ABSPATH . 'wp-config.php') ) { require_once( ABSPATH . WPINC . '/functions.php' ); - // Set a path for the link to the installer - if ( strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) !== false ) { - $path = 'setup-config.php'; - } elseif ( file_exists( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/wp-admin/setup-config.php' ) ) { - $path = 'wp-admin/setup-config.php'; - } else { - // WordPress files are in a sub directory, and the user is hitting the index.php in the parent directory - $path = str_replace( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/', '', dirname( __FILE__ ) . '/wp-admin/setup-config.php' ); - } + $path = wp_guess_url() . '/wp-admin/setup-config.php'; // Die with an error message $die = __( "There doesn't seem to be a wp-config.php file. I need this before we can get started." ) . '

';