blog_id ) ) $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 ) ); if ( is_subdomain_install() ) { $current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' ); if ( !$current_blog ) { $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain ) ); if ( $current_blog ) wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' ); } if ( $current_blog && $current_blog->site_id != $current_site->id ) $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d", $current_blog->site_id ) ); else $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); } else { $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) ); if ( false !== strpos( $blogname, '/' ) ) $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) ); if ( false !== strpos( $blogname, '?' ) ) $blogname = substr( $blogname, 0, strpos( $blogname, '?' ) ); $reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' ); if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) ) $path = $path . $blogname . '/'; $current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' ); if ( ! $current_blog ) { $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domain, $path ) ); if ( $current_blog ) wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' ); } } if ( ! defined( 'WP_INSTALLING' ) && is_subdomain_install() && ! is_object( $current_blog ) ) { if ( defined( 'NOBLOGREDIRECT' ) ) { $destination = NOBLOGREDIRECT; if ( '%siteurl%' == $destination ) $destination = "http://" . $current_site->domain . $current_site->path; } else { $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); } wp_redirect( $destination ); die(); } if ( ! defined( 'WP_INSTALLING' ) ) { if ( $current_site && ! $current_blog ) { if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) { wp_redirect( 'http://' . $current_site->domain . $current_site->path ); exit; } $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) ); } if ( ! $current_blog || ! $current_site ) is_installed(); } $blog_id = $current_blog->blog_id; $public = $current_blog->public; if ( empty( $current_blog->site_id ) ) $current_blog->site_id = 1; $site_id = $current_blog->site_id; $current_site = get_current_site_name( $current_site ); if ( ! $blog_id ) { if ( defined('WP_INSTALLING') ) { $current_blog->blog_id = $blog_id = 1; } else { $msg = ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ? __( 'Database tables are missing.' ) : ''; wp_die( __( 'No blog by that name on this system.' ) . $msg ); } } $wpdb->suppress_errors( false ); $wpdb->blogid = $current_blog->blog_id; $wpdb->siteid = $current_blog->site_id; $wpdb->set_prefix( $table_prefix ); // set up blog tables $table_prefix = $wpdb->get_blog_prefix(); // need to init cache again after blog_id is set wp_start_object_cache(); // Define upload directory constants ms_default_constants( 'uploads' ); ?>