X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/41578db67d72562346e4dbb2a14889b23d522813..9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f:/wp-includes/ms-load.php diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php index ee99398d..a202034b 100644 --- a/wp-includes/ms-load.php +++ b/wp-includes/ms-load.php @@ -92,7 +92,7 @@ function ms_site_check() { if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) return WP_CONTENT_DIR . '/blog-deleted.php'; else - wp_die( __( 'This user has elected to delete their account and the content is no longer available.' ), '', array( 'response' => 410 ) ); + wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) ); } if ( '2' == $blog->deleted ) { @@ -125,7 +125,7 @@ function ms_site_check() { function get_network_by_path( $domain, $path, $segments = null ) { global $wpdb; - $domains = $exact_domains = array( $domain ); + $domains = array( $domain ); $pieces = explode( '.', $domain ); /* @@ -348,13 +348,30 @@ function get_site_by_path( $domain, $path, $segments = null ) { * then cache whether we can just always ignore paths. */ + // Either www or non-www is supported, not both. If a www domain is requested, + // query for both to provide the proper redirect. + $domains = array( $domain ); + if ( 'www.' === substr( $domain, 0, 4 ) ) { + $domains[] = substr( $domain, 4 ); + $search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'"; + } + if ( count( $paths ) > 1 ) { - $paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'"; - $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain ); - $sql .= " AND path IN ($paths) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1"; + $search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'"; + } + + if ( count( $domains ) > 1 && count( $paths ) > 1 ) { + $site = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE domain IN ($search_domains) AND path IN ($search_paths) ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC LIMIT 1" ); + } elseif ( count( $domains ) > 1 ) { + $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE path = %s", $paths[0] ); + $sql .= " AND domain IN ($search_domains) ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1"; + $site = $wpdb->get_row( $sql ); + } elseif ( count( $paths ) > 1 ) { + $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domains[0] ); + $sql .= " AND path IN ($search_paths) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1"; $site = $wpdb->get_row( $sql ); } else { - $site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s and path = %s", $domain, $paths[0] ) ); + $site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domains[0], $paths[0] ) ); } if ( $site ) { @@ -380,14 +397,17 @@ function ms_not_installed() { $title = __( 'Error establishing a database connection' ); $msg = '

' . $title . '

'; - if ( ! is_admin() ) + if ( ! is_admin() ) { die( $msg ); + } $msg .= '

' . __( 'If your site does not display, please contact the owner of this network.' ) . ''; $msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '

'; - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ) + $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) ); + if ( ! $wpdb->get_var( $query ) ) { $msg .= '

' . sprintf( __( 'Database tables are missing. This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.' ), $wpdb->site ) . '

'; - else + } else { $msg .= '

' . sprintf( __( 'Could not find site %1$s. Searched for table %2$s in database %3$s. Is that right?' ), rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '

'; + } $msg .= '

' . __( 'What do I do now?' ) . ' '; $msg .= __( 'Read the bug report page. Some of the guidelines there may help you figure out what went wrong.' ); $msg .= ' ' . __( 'If you’re still stuck with this message, then check that your database contains the following tables:' ) . '