Ticket #14913: console-multisite.diff

File console-multisite.diff, 3.3 KB (added by wonderboymusic, 8 months ago)
  • wp-includes/ms-settings.php

    Property changes on: .
    ___________________________________________________________________
    Added: svn:ignore
       + .wp-tests-version
    
    
     
    2222 
    2323if ( !isset( $current_site ) || !isset( $current_blog ) ) { 
    2424 
    25         $domain = addslashes( $_SERVER['HTTP_HOST'] ); 
    26         if ( false !== strpos( $domain, ':' ) ) { 
    27                 if ( substr( $domain, -3 ) == ':80' ) { 
    28                         $domain = substr( $domain, 0, -3 ); 
    29                         $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); 
    30                 } elseif ( substr( $domain, -4 ) == ':443' ) { 
    31                         $domain = substr( $domain, 0, -4 ); 
    32                         $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); 
    33                 } else { 
    34                         wp_load_translations_early(); 
    35                         wp_die( __( 'Multisite only works without the port number in the URL.' ) ); 
     25        if ( isset( $_SERVER['HTTP_HOST'] ) ) { 
     26                $domain = addslashes( $_SERVER['HTTP_HOST'] ); 
     27                if ( false !== strpos( $domain, ':' ) ) { 
     28                        if ( substr( $domain, -3 ) == ':80' ) { 
     29                                $domain = substr( $domain, 0, -3 ); 
     30                                $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); 
     31                        } elseif ( substr( $domain, -4 ) == ':443' ) { 
     32                                $domain = substr( $domain, 0, -4 ); 
     33                                $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); 
     34                        } else { 
     35                                wp_load_translations_early(); 
     36                                wp_die( __( 'Multisite only works without the port number in the URL.' ) ); 
     37                        } 
    3638                } 
     39        } else { 
     40                $domain = DOMAIN_CURRENT_SITE; 
    3741        } 
    3842 
    3943        $domain = rtrim( $domain, '.' ); 
     
    4145        if ( substr( $cookie_domain, 0, 4 ) == 'www.' ) 
    4246                $cookie_domain = substr( $cookie_domain, 4 ); 
    4347 
    44         $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] ); 
    45         $path = str_replace ( '/wp-admin/', '/', $path ); 
    46         $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path ); 
    47  
     48        if ( isset( $_SERVER['REQUEST_URI'] ) ) { 
     49                $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] ); 
     50                $path = str_replace ( '/wp-admin/', '/', $path ); 
     51                $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path ); 
     52        } else { 
     53                $path = '/'; 
     54        } 
     55         
    4856        $current_site = wpmu_current_site(); 
    4957        if ( ! isset( $current_site->blog_id ) ) 
    5058                $current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) ); 
     
    6371                } else 
    6472                        $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 
    6573        } else { 
    66                 $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) ); 
     74                if ( isset( $_SERVER[ 'REQUEST_URI' ] ) ) 
     75                        $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) ); 
     76                else  
     77                        $blogname = htmlspecialchars( $path );   
     78                         
    6779                if ( false !== strpos( $blogname, '/' ) ) 
    6880                        $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) ); 
    6981                if ( false !== strpos( $blogname, '?' ) ) 
     
    94106 
    95107        if ( ! defined( 'WP_INSTALLING' ) ) { 
    96108                if ( $current_site && ! $current_blog ) { 
    97                         if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) { 
     109                        if ( isset( $_SERVER[ 'HTTP_HOST' ] ) && $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) { 
    98110                                header( 'Location: http://' . $current_site->domain . $current_site->path ); 
    99111                                exit; 
    100112                        }