Changeset 12787 for trunk/wp-includes/ms-settings.php
- Timestamp:
- 01/21/2010 05:20:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-settings.php
r12760 r12787 22 22 23 23 $domain = addslashes( $_SERVER['HTTP_HOST'] ); 24 if ( substr( $domain, 0, 4 ) == 'www.' )25 $domain = substr( $domain, 4 );26 24 if ( strpos( $domain, ':' ) ) { 27 25 if ( substr( $domain, -3 ) == ':80' ) { … … 39 37 $domain = substr( $domain, 0, -1 ); 40 38 39 if ( substr( $domain, 0, 4 ) == 'www.' ) 40 $cookie_domain = substr( $domain, 4 ); 41 else 42 $cookie_domain = $domain; 43 41 44 $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] ); 42 45 $path = str_replace ( '/wp-admin/', '/', $path ); … … 56 59 57 60 function wpmu_current_site() { 58 global $wpdb, $current_site, $domain, $path, $sites ;61 global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain; 59 62 if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) { 60 63 $current_site->id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1); … … 63 66 if ( defined( 'BLOGID_CURRENT_SITE' ) ) 64 67 $current_site->blog_id = BLOGID_CURRENT_SITE; 68 if ( DOMAIN_CURRENT_SITE == $domain ) 69 $current_site->cookie_domain = $cookie_domain; 70 elseif ( substr( $current_site->domain, 0, 4 ) == 'www.' ) 71 $current_site->cookie_domain = substr( $current_site->domain, 4 ); 72 else 73 $current_site->cookie_domain = $current_site->domain; 74 65 75 return $current_site; 66 76 } … … 77 87 $current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" ); 78 88 $current_site = get_current_site_name( $current_site ); 89 if ( substr( $current_site->domain, 0, 4 ) == 'www.' ) 90 $current_site->cookie_domain = substr( $current_site->domain, 4 ); 79 91 wp_cache_set( "current_site", $current_site, "site-options" ); 80 92 return $current_site; 81 93 } 82 94 $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) ); 83 if ( is_subdomain_install() ) { 84 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path) ); 85 if ( $current_site != null ) 86 return $current_site; 87 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain) ); 88 if ( $current_site != null ) { 89 $path = '/'; 90 return $current_site; 91 } 92 95 96 if ( $domain == $cookie_domain ) 97 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) ); 98 else 99 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain IN ( %s, %s ) AND path = %s ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1", $domain, $cookie_domain, $path ) ); 100 if ( $current_site == null ) { 101 if ( $domain == $cookie_domain ) 102 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain ) ); 103 else 104 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain IN ( %s, %s ) AND path = '/' ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1", $domain, $cookie_domain, $path ) ); 105 } 106 if ( $current_site != null ) { 107 $path = $current_site->path; 108 $current_site->cookie_domain = $cookie_domain; 109 return $current_site; 110 } elseif ( is_subdomain_install() ) { 93 111 $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) ); 94 112 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) ); 95 if ( $current_site != null ) 113 if ( $current_site != null ) { 114 $current_site->cookie_domain = $current_site->domain; 96 115 return $current_site; 116 } 97 117 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $sitedomain) ); 98 118 if ( $current_site == null && defined( "WP_INSTALLING" ) == false ) { … … 106 126 $path = '/'; 107 127 } 128 } elseif ( defined( "WP_INSTALLING" ) == false ) { 129 if ( count( $sites ) == 1 ) { 130 $current_site = $sites[0]; 131 die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" ); 132 } else { 133 die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://codex.wordpress.org/Debugging_WPMU'>Debugging WPMU</a> for further assistance." ); 134 } 108 135 } else { 109 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path) ); 110 if ( $current_site != null ) 111 return $current_site; 112 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain) ); 113 if ( $current_site == null && defined( "WP_INSTALLING" ) == false ) { 114 if ( count( $sites ) == 1 ) { 115 $current_site = $sites[0]; 116 die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" ); 117 } else { 118 die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://codex.wordpress.org/Debugging_WPMU'>Debugging WPMU</a> for further assistance." ); 119 } 120 } else { 121 $path = '/'; 122 } 136 $path = '/'; 123 137 } 124 138 return $current_site;
Note: See TracChangeset
for help on using the changeset viewer.