Changeset 12896 for trunk/wp-includes/ms-settings.php
- Timestamp:
- 01/29/2010 04:26:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-settings.php
r12888 r12896 21 21 22 22 $domain = addslashes( $_SERVER['HTTP_HOST'] ); 23 if ( strpos( $domain, ':' ) ) {23 if ( false !== strpos( $domain, ':' ) ) { 24 24 if ( substr( $domain, -3 ) == ':80' ) { 25 25 $domain = substr( $domain, 0, -3 ); … … 29 29 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); 30 30 } else { 31 die( 'WPMUonly works without the port number in the URL.' );31 wp_die( 'Multisite only works without the port number in the URL.' ); 32 32 } 33 33 } 34 $domain = preg_replace('/:.*$/', '', $domain); // Strip ports35 if ( substr( $domain, -1 ) == '.' )36 $domain = substr( $domain, 0, -1 );37 34 38 if ( substr( $domain, 0, 4 ) == 'www.' ) 39 $cookie_domain = substr( $domain, 4 );40 else 41 $cookie_domain = $domain;35 $domain = rtrim( $domain, '.' ); 36 $cookie_domain = $domain; 37 if ( substr( $cookie_domain, 0, 4 ) == 'www.' ) 38 $cookie_domain = substr( $cookie_domain, 4 ); 42 39 43 40 $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] ); … … 46 43 47 44 $current_site = wpmu_current_site(); 48 if ( ! isset( $current_site->blog_id ) )49 $current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'");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 ) ); 50 47 51 48 if ( is_subdomain_install() ) { 52 49 $current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' ); 53 50 if ( !$current_blog ) { 54 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain) );51 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain ) ); 55 52 if ( $current_blog ) 56 53 wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' ); 57 54 } 58 if ( $current_blog != null&& $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) );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 ) ); 60 57 else 61 58 $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 62 59 } else { 63 60 $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) ); 64 if ( strpos( $blogname, '/' ) )61 if ( false !== strpos( $blogname, '/' ) ) 65 62 $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) ); 66 if ( strpos( " ".$blogname, '?' ) )63 if ( false !== strpos( $blogname, '?' ) ) 67 64 $blogname = substr( $blogname, 0, strpos( $blogname, '?' ) ); 68 65 $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 ) )66 if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) ) 70 67 $path = $path . $blogname . '/'; 71 68 $current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' ); 72 if ( ! $current_blog ) {73 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domain, $path) );69 if ( ! $current_blog ) { 70 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domain, $path ) ); 74 71 if ( $current_blog ) 75 72 wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' ); … … 77 74 } 78 75 79 if ( ! defined( 'WP_INSTALLING' ) && is_subdomain_install() && !is_object( $current_blog ) ) { 80 76 if ( ! defined( 'WP_INSTALLING' ) && is_subdomain_install() && ! is_object( $current_blog ) ) { 81 77 if ( defined( 'NOBLOGREDIRECT' ) ) { 82 $destination = constant( 'NOBLOGREDIRECT' );83 if ( $destination == '%siteurl%')78 $destination = NOBLOGREDIRECT; 79 if ( '%siteurl%' == $destination ) 84 80 $destination = "http://" . $current_site->domain . $current_site->path; 85 header( "Location: " . $destination);86 die();87 81 } else { 88 header( "Location: http://" . $current_site->domain . $current_site->path . "wp-signup.php?new=" . str_replace( '.' . $current_site->domain, '', $domain ) ); 89 die(); 82 $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); 90 83 } 91 84 wp_redirect( $destination ); 85 die(); 92 86 } 93 87 94 88 if ( ! defined( 'WP_INSTALLING' ) ) { 95 if ( $current_site && $current_blog == null) {89 if ( $current_site && ! $current_blog ) { 96 90 if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) { 97 header( "Location: http://". $current_site->domain . $current_site->path );91 wp_redirect( 'http://' . $current_site->domain . $current_site->path ); 98 92 exit; 99 93 } 100 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path) );94 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) ); 101 95 } 102 if ( $current_blog == false || $current_site == false )96 if ( ! $current_blog || ! $current_site ) 103 97 is_installed(); 104 98 } … … 107 101 $public = $current_blog->public; 108 102 109 if ( $current_blog->site_id == 0 || $current_blog->site_id == '')103 if ( empty( $current_blog->site_id ) ) 110 104 $current_blog->site_id = 1; 111 105 $site_id = $current_blog->site_id; … … 113 107 $current_site = get_current_site_name( $current_site ); 114 108 115 if ( $blog_id == false ) { 116 // no blog found, are we installing? Check if the table exists. 117 if ( defined('WP_INSTALLING') ) { 118 $blog_id = $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs LIMIT 0,1" ); 119 if ( $blog_id == false ) { 120 // table doesn't exist. This is the first blog 121 $blog_id = 1; 122 } else { 123 // table exists 124 // don't create record at this stage. we're obviously installing so it doesn't matter what the table vars below are like. 125 // default to using the "main" blog. 126 $blog_id = 1; 127 } 128 $current_blog->blog_id = $blog_id; 109 if ( ! $blog_id ) { 110 if ( defined('WP_INSTALLING') ) { 111 $current_blog->blog_id = $blog_id = 1; 129 112 } else { 130 $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); 131 if ( $check == false ) 132 $msg = ': DB Tables Missing'; 133 else 134 $msg = ''; 135 die( "No Blog by that name on this system." . $msg ); 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 ); 136 115 } 137 116 } … … 139 118 $wpdb->suppress_errors( false ); 140 119 141 if ( '0' == $current_blog->public ) {142 // This just means the blog shouldn't show up in google, etc. Only to registered members143 }144 145 120 $wpdb->blogid = $current_blog->blog_id; 146 121 $wpdb->siteid = $current_blog->site_id; 147 $wpdb->set_prefix( $table_prefix); // set up blog tables122 $wpdb->set_prefix( $table_prefix ); // set up blog tables 148 123 $table_prefix = $wpdb->get_blog_prefix(); 149 150 // Fix empty PHP_SELF151 $PHP_SELF = $_SERVER['PHP_SELF'];152 if ( empty($PHP_SELF) || ( empty($PHP_SELF) && !is_subdomain_install() && $current_blog->path != '/' ) )153 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);154 124 155 125 // need to init cache again after blog_id is set 156 126 wp_start_object_cache(); 157 127 128 // Define upload directory constants 158 129 ms_default_constants( 'uploads' ); 159 130
Note: See TracChangeset
for help on using the changeset viewer.