Changeset 13421
- Timestamp:
- 02/26/2010 12:05:11 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-settings.php
r13387 r13421 17 17 include_once( WP_CONTENT_DIR . '/sunrise.php' ); 18 18 19 if ( isset( $current_site ) && isset( $current_blog ) ) 20 return; 19 if ( !isset( $current_site ) || !isset( $current_blog ) ) { 21 20 22 $domain = addslashes( $_SERVER['HTTP_HOST'] ); 23 if ( false !== strpos( $domain, ':' ) ) { 24 if ( substr( $domain, -3 ) == ':80' ) { 25 $domain = substr( $domain, 0, -3 ); 26 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); 27 } elseif ( substr( $domain, -4 ) == ':443' ) { 28 $domain = substr( $domain, 0, -4 ); 29 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); 21 $domain = addslashes( $_SERVER['HTTP_HOST'] ); 22 if ( false !== strpos( $domain, ':' ) ) { 23 if ( substr( $domain, -3 ) == ':80' ) { 24 $domain = substr( $domain, 0, -3 ); 25 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); 26 } elseif ( substr( $domain, -4 ) == ':443' ) { 27 $domain = substr( $domain, 0, -4 ); 28 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); 29 } else { 30 wp_die( 'Multisite only works without the port number in the URL.' ); 31 } 32 } 33 34 $domain = rtrim( $domain, '.' ); 35 $cookie_domain = $domain; 36 if ( substr( $cookie_domain, 0, 4 ) == 'www.' ) 37 $cookie_domain = substr( $cookie_domain, 4 ); 38 39 $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] ); 40 $path = str_replace ( '/wp-admin/', '/', $path ); 41 $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path ); 42 43 $current_site = wpmu_current_site(); 44 if ( ! isset( $current_site->blog_id ) ) 45 $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 ) ); 46 47 if ( is_subdomain_install() ) { 48 $current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' ); 49 if ( !$current_blog ) { 50 $current_blog = get_blog_details( array( 'domain' => $domain ), false ); 51 if ( $current_blog ) 52 wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' ); 53 } 54 if ( $current_blog && $current_blog->site_id != $current_site->id ) 55 $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d", $current_blog->site_id ) ); 56 else 57 $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 30 58 } else { 31 wp_die( 'Multisite only works without the port number in the URL.' ); 59 $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) ); 60 if ( false !== strpos( $blogname, '/' ) ) 61 $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) ); 62 if ( false !== strpos( $blogname, '?' ) ) 63 $blogname = substr( $blogname, 0, strpos( $blogname, '?' ) ); 64 $reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' ); 65 if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) ) 66 $path .= $blogname . '/'; 67 $current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' ); 68 if ( ! $current_blog ) { 69 $current_blog = get_blog_details( array( 'domain' => $domain, 'path' => $path ), false ); 70 if ( $current_blog ) 71 wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' ); 72 } 73 } 74 75 if ( ! defined( 'WP_INSTALLING' ) && is_subdomain_install() && ! is_object( $current_blog ) ) { 76 if ( defined( 'NOBLOGREDIRECT' ) ) { 77 $destination = NOBLOGREDIRECT; 78 if ( '%siteurl%' == $destination ) 79 $destination = "http://" . $current_site->domain . $current_site->path; 80 } else { 81 $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); 82 } 83 header( 'Location: ' . $destination ); 84 die(); 85 } 86 87 if ( ! defined( 'WP_INSTALLING' ) ) { 88 if ( $current_site && ! $current_blog ) { 89 if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) { 90 header( 'Location: http://' . $current_site->domain . $current_site->path ); 91 exit; 92 } 93 $current_blog = get_blog_details( array( 'domain' => $current_site->domain, 'path' => $current_site->path ), false ); 94 } 95 if ( ! $current_blog || ! $current_site ) 96 ms_not_installed(); 97 } 98 99 $blog_id = $current_blog->blog_id; 100 $public = $current_blog->public; 101 102 if ( empty( $current_blog->site_id ) ) 103 $current_blog->site_id = 1; 104 $site_id = $current_blog->site_id; 105 106 $current_site = get_current_site_name( $current_site ); 107 108 if ( ! $blog_id ) { 109 if ( defined( 'WP_INSTALLING' ) ) { 110 $current_blog->blog_id = $blog_id = 1; 111 } else { 112 $msg = ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ? ' ' . __( 'Database tables are missing.' ) : ''; 113 wp_die( __( 'No blog by that name on this system.' ) . $msg ); 114 } 32 115 } 33 116 } 34 35 $domain = rtrim( $domain, '.' ); 36 $cookie_domain = $domain; 37 if ( substr( $cookie_domain, 0, 4 ) == 'www.' ) 38 $cookie_domain = substr( $cookie_domain, 4 ); 39 40 $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] ); 41 $path = str_replace ( '/wp-admin/', '/', $path ); 42 $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path ); 43 44 $current_site = wpmu_current_site(); 45 if ( ! isset( $current_site->blog_id ) ) 46 $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 ) ); 47 48 if ( is_subdomain_install() ) { 49 $current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' ); 50 if ( !$current_blog ) { 51 $current_blog = get_blog_details( array( 'domain' => $domain ), false ); 52 if ( $current_blog ) 53 wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' ); 54 } 55 if ( $current_blog && $current_blog->site_id != $current_site->id ) 56 $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d", $current_blog->site_id ) ); 57 else 58 $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 59 } else { 60 $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) ); 61 if ( false !== strpos( $blogname, '/' ) ) 62 $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) ); 63 if ( false !== strpos( $blogname, '?' ) ) 64 $blogname = substr( $blogname, 0, strpos( $blogname, '?' ) ); 65 $reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' ); 66 if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) ) 67 $path .= $blogname . '/'; 68 $current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' ); 69 if ( ! $current_blog ) { 70 $current_blog = get_blog_details( array( 'domain' => $domain, 'path' => $path ), false ); 71 if ( $current_blog ) 72 wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' ); 73 } 74 } 75 76 if ( ! defined( 'WP_INSTALLING' ) && is_subdomain_install() && ! is_object( $current_blog ) ) { 77 if ( defined( 'NOBLOGREDIRECT' ) ) { 78 $destination = NOBLOGREDIRECT; 79 if ( '%siteurl%' == $destination ) 80 $destination = "http://" . $current_site->domain . $current_site->path; 81 } else { 82 $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); 83 } 84 header( 'Location: ' . $destination ); 85 die(); 86 } 87 88 if ( ! defined( 'WP_INSTALLING' ) ) { 89 if ( $current_site && ! $current_blog ) { 90 if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) { 91 header( 'Location: http://' . $current_site->domain . $current_site->path ); 92 exit; 93 } 94 $current_blog = get_blog_details( array( 'domain' => $current_site->domain, 'path' => $current_site->path ), false ); 95 } 96 if ( ! $current_blog || ! $current_site ) 97 ms_not_installed(); 98 } 99 100 $blog_id = $current_blog->blog_id; 101 $public = $current_blog->public; 102 103 if ( empty( $current_blog->site_id ) ) 104 $current_blog->site_id = 1; 105 $site_id = $current_blog->site_id; 106 107 $current_site = get_current_site_name( $current_site ); 108 109 if ( ! $blog_id ) { 110 if ( defined( 'WP_INSTALLING' ) ) { 111 $current_blog->blog_id = $blog_id = 1; 112 } else { 113 $msg = ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ? ' ' . __( 'Database tables are missing.' ) : ''; 114 wp_die( __( 'No blog by that name on this system.' ) . $msg ); 115 } 116 } 117 118 $wpdb->set_prefix( $table_prefix, false ); // set DB table prefix 117 $wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php 119 118 $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); 120 119 $table_prefix = $wpdb->get_blog_prefix();
Note: See TracChangeset
for help on using the changeset viewer.