WordPress 3.0 beta 1 documentation kindly provided to you by Hay Kranen
| [ Index ] |
PHP Cross Reference of WordPress 3.0 beta 1 |
|
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Used to set up and fix common variables and include 4 * the Multisite procedural and class library. 5 * 6 * Allows for some configuration in wp-config.php (see ms-default-constants.php) 7 * 8 * @package WordPress 9 * @subpackage Multisite 10 */ 11 12 // $base sanity check. 13 if ( 'BASE' == $base ) 14 die( /*WP_I18N_BASE_ERROR*/'Configuration error in <code>wp-config.php</code>. <code>$base</code> is set to "BASE" when it should be the path like "/" or "/blogs/".'/*/WP_I18N_BASE_ERROR*/ ); 15 16 /** Include Multisite initialization functions */ 17 require ( ABSPATH . WPINC . '/ms-load.php' ); 18 require ( ABSPATH . WPINC . '/ms-default-constants.php' ); 19 20 if ( defined( 'SUNRISE' ) ) 21 include_once( WP_CONTENT_DIR . '/sunrise.php' ); 22 23 if ( !isset( $current_site ) || !isset( $current_blog ) ) { 24 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_die( /*WP_I18N_NO_PORT_NUMBER*/'Multisite only works without the port number in the URL.'/*/WP_I18N_NO_PORT_NUMBER*/ ); 35 } 36 } 37 38 $domain = rtrim( $domain, '.' ); 39 $cookie_domain = $domain; 40 if ( substr( $cookie_domain, 0, 4 ) == 'www.' ) 41 $cookie_domain = substr( $cookie_domain, 4 ); 42 43 $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] ); 44 $path = str_replace ( '/wp-admin/', '/', $path ); 45 $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path ); 46 47 $current_site = wpmu_current_site(); 48 if ( ! isset( $current_site->blog_id ) ) 49 $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 ) ); 50 51 if ( is_subdomain_install() ) { 52 $current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' ); 53 if ( !$current_blog ) { 54 $current_blog = get_blog_details( array( 'domain' => $domain ), false ); 55 if ( $current_blog ) 56 wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' ); 57 } 58 if ( $current_blog && $current_blog->site_id != $current_site->id ) 59 $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d", $current_blog->site_id ) ); 60 else 61 $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 62 } else { 63 $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) ); 64 if ( false !== strpos( $blogname, '/' ) ) 65 $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) ); 66 if ( false !== strpos( $blogname, '?' ) ) 67 $blogname = substr( $blogname, 0, strpos( $blogname, '?' ) ); 68 $reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' ); 69 if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) ) 70 $path .= $blogname . '/'; 71 $current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' ); 72 if ( ! $current_blog ) { 73 $current_blog = get_blog_details( array( 'domain' => $domain, 'path' => $path ), false ); 74 if ( $current_blog ) 75 wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' ); 76 } 77 } 78 79 if ( ! defined( 'WP_INSTALLING' ) && is_subdomain_install() && ! is_object( $current_blog ) ) { 80 if ( defined( 'NOBLOGREDIRECT' ) ) { 81 $destination = NOBLOGREDIRECT; 82 if ( '%siteurl%' == $destination ) 83 $destination = "http://" . $current_site->domain . $current_site->path; 84 } else { 85 $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); 86 } 87 header( 'Location: ' . $destination ); 88 die(); 89 } 90 91 if ( ! defined( 'WP_INSTALLING' ) ) { 92 if ( $current_site && ! $current_blog ) { 93 if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) { 94 header( 'Location: http://' . $current_site->domain . $current_site->path ); 95 exit; 96 } 97 $current_blog = get_blog_details( array( 'domain' => $current_site->domain, 'path' => $current_site->path ), false ); 98 } 99 if ( ! $current_blog || ! $current_site ) 100 ms_not_installed(); 101 } 102 103 $blog_id = $current_blog->blog_id; 104 $public = $current_blog->public; 105 106 if ( empty( $current_blog->site_id ) ) 107 $current_blog->site_id = 1; 108 $site_id = $current_blog->site_id; 109 110 $current_site = get_current_site_name( $current_site ); 111 112 if ( ! $blog_id ) { 113 if ( defined( 'WP_INSTALLING' ) ) { 114 $current_blog->blog_id = $blog_id = 1; 115 } else { 116 $msg = ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ? ' ' . /*WP_I18N_TABLES_MISSING*/'Database tables are missing.'/*/WP_I18N_TABLES_MISSING*/ : ''; 117 wp_die( /*WP_I18N_NO_BLOG*/'No blog by that name on this system.'/*/WP_I18N_NO_BLOG*/ . $msg ); 118 } 119 } 120 } 121 $wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php 122 $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); 123 $table_prefix = $wpdb->get_blog_prefix(); 124 125 // need to init cache again after blog_id is set 126 wp_start_object_cache(); 127 128 // Define upload directory constants 129 ms_upload_constants();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Apr 5 14:26:09 2010 | Cross-referenced by PHPXref 0.7 |