Changeset 12921 for trunk/wp-includes/ms-load.php
- Timestamp:
- 02/01/2010 08:26:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-load.php
r12901 r12921 10 10 11 11 /** 12 * Whether a subdomain configuration is enabled 12 * Whether a subdomain configuration is enabled. 13 13 * 14 14 * @since 3.0 … … 23 23 } 24 24 25 function ms_network_settings() { 26 global $wpdb, $current_site, $cookiehash; 27 28 if ( !isset($current_site->site_name) ) 29 $current_site->site_name = get_site_option('site_name'); 30 31 if ( $current_site->site_name == false ) 32 $current_site->site_name = ucfirst( $current_site->domain ); 33 } 34 25 /** 26 * Returns array of sitewide plugin files to be included in global scope. 27 * 28 * @access private 29 * @since 3.0.0 30 * @return array Files to include 31 */ 35 32 function ms_network_plugins() { 36 33 $network_plugins = array(); … … 63 60 } 64 61 62 /** 63 * Checks status of current blog. 64 * 65 * Checks if the blog is deleted, inactive, archived, or spammed. 66 * 67 * Dies with a default message if the blog does not pass the check. 68 * 69 * To change the default message when a blog does not pass the check, 70 * use the wp-content/blog-deleted.php, blog-inactive.php and 71 * blog-suspended.php drop-ins. 72 * 73 * @return bool|string Returns true on success, or drop-in file to include. 74 */ 65 75 function ms_site_check() { 66 76 global $wpdb, $current_blog; 67 77 68 78 if ( '1' == $current_blog->deleted ) { 69 if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) { 70 return WP_CONTENT_DIR . '/blog-deleted.php'; 71 } else { 72 header('HTTP/1.1 410 Gone'); 73 wp_die(__('This user has elected to delete their account and the content is no longer available.')); 74 } 75 } elseif ( '2' == $current_blog->deleted ) { 76 if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) 77 return WP_CONTENT_DIR . '/blog-inactive.php'; 78 else 79 wp_die( sprintf( __( 'This blog has not been activated yet. If you are having problems activating your blog, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) ); 79 if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) { 80 return WP_CONTENT_DIR . '/blog-deleted.php'; 81 } else { 82 header( 'HTTP/1.1 410 Gone' ); 83 wp_die( __( 'This user has elected to delete their account and the content is no longer available.' ) ); 84 } 85 } 86 87 if ( '2' == $current_blog->deleted ) { 88 if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) 89 return WP_CONTENT_DIR . '/blog-inactive.php'; 90 else 91 wp_die( sprintf( __( 'This blog has not been activated yet. If you are having problems activating your blog, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) ); 80 92 } 81 93 82 94 if ( $current_blog->archived == '1' || $current_blog->spam == '1' ) { 83 84 85 86 header('HTTP/1.1 410 Gone');87 wp_die(__('This blog has been archived or suspended.'));88 95 if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) { 96 return WP_CONTENT_DIR . '/blog-suspended.php'; 97 } else { 98 header( 'HTTP/1.1 410 Gone' ); 99 wp_die( __( 'This blog has been archived or suspended.' ) ); 100 } 89 101 } 90 102 … … 92 104 } 93 105 106 /** 107 * Sets current site name. 108 * 109 * @access private 110 * @since 3.0.0 111 * @return object $current_site object with site_name 112 */ 94 113 function get_current_site_name( $current_site ) { 95 114 global $wpdb; 96 115 $current_site->site_name = wp_cache_get( $current_site->id . ':current_site_name', "site-options" ); 97 if ( ! $current_site->site_name ) {116 if ( ! $current_site->site_name ) { 98 117 $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) ); 99 if ( $current_site->site_name == null)118 if ( ! $current_site->site_name ) 100 119 $current_site->site_name = ucfirst( $current_site->domain ); 101 wp_cache_set( $current_site->id . ':current_site_name', $current_site->site_name, 'site-options' );120 wp_cache_set( $current_site->id . ':current_site_name', $current_site->site_name, 'site-options' ); 102 121 } 103 122 return $current_site; 104 123 } 105 124 125 /** 126 * Sets current_site object. 127 * 128 * @access private 129 * @since 3.0.0 130 * @return object $current_site object 131 */ 106 132 function wpmu_current_site() { 107 133 global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain; … … 122 148 } 123 149 124 $current_site = wp_cache_get( "current_site", "site-options");150 $current_site = wp_cache_get( 'current_site', 'site-options' ); 125 151 if ( $current_site ) 126 152 return $current_site; 127 153 128 154 $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site 129 if ( count( $sites ) == 1) {155 if ( 1 == count( $sites ) ) { 130 156 $current_site = $sites[0]; 131 157 $path = $current_site->path; 132 $current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'");158 $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 ) ); 133 159 $current_site = get_current_site_name( $current_site ); 134 160 if ( substr( $current_site->domain, 0, 4 ) == 'www.' ) 135 161 $current_site->cookie_domain = substr( $current_site->domain, 4 ); 136 wp_cache_set( "current_site", $current_site, "site-options");162 wp_cache_set( 'current_site', $current_site, 'site-options' ); 137 163 return $current_site; 138 164 } … … 140 166 141 167 if ( $domain == $cookie_domain ) 142 $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) );168 $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) ); 143 169 else 144 $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 ) ); 145 if ( $current_site == null ) { 170 $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 ) ); 171 172 if ( ! $current_site ) { 146 173 if ( $domain == $cookie_domain ) 147 174 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain ) ); … … 149 176 $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 ) ); 150 177 } 151 if ( $current_site != null ) { 178 179 if ( $current_site ) { 152 180 $path = $current_site->path; 153 181 $current_site->cookie_domain = $cookie_domain; 154 182 return $current_site; 155 } elseif ( is_subdomain_install() ) { 183 } 184 185 if ( is_subdomain_install() ) { 156 186 $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) ); 157 187 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) ); 158 if ( $current_site != null) {188 if ( $current_site ) { 159 189 $current_site->cookie_domain = $current_site->domain; 160 190 return $current_site; 161 191 } 192 162 193 $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $sitedomain) ); 163 if ( $current_site == null && defined( "WP_INSTALLING" ) == false ) { 164 if ( count( $sites ) == 1 ) { 165 $current_site = $sites[0]; 166 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>" ); 167 } else { 168 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." ); 169 } 170 } else { 171 $path = '/'; 172 } 173 } elseif ( defined( "WP_INSTALLING" ) == false ) { 174 if ( count( $sites ) == 1 ) { 175 $current_site = $sites[0]; 176 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>" ); 177 } else { 178 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." ); 179 } 180 } else { 194 } 195 196 if ( $current_site || defined( 'WP_INSTALLING' ) ) { 181 197 $path = '/'; 182 } 183 return $current_site; 184 } 185 198 return $current_site; 199 } 200 201 // Still no dice. 202 // @todo Update or remove WPMU codex link. 203 if ( 1 == count( $sites ) ) 204 wp_die( sprintf( __( 'That blog does not exist. Please try <a href="%s">%s</a>.' ), $sites[0]->domain . $sites[0]->path ) ); 205 else 206 wp_die( __( 'No 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.' ) ); 207 } 208 209 /** 210 * Displays a failure message when blog does not exist. 211 * 212 * Checks for a missing $wpdb->site table as well. 213 * 214 * @todo Merge with is_blog_installed(), dead_db(), wp_not_installed(), etc. 215 * @access private 216 * @since 3.0.0 217 */ 186 218 function is_installed() { 187 219 global $wpdb, $domain, $path; 188 220 $base = stripslashes( $base ); 189 if ( defined( "WP_INSTALLING" ) == false ) { 190 $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); 191 $msg = "If your blog does not display, please contact the owner of this site.<br /><br />If you are the owner of this site please check that MySQL is running properly and all tables are error free.<br /><br />"; 192 if ( $check == false ) { 193 $msg .= "<strong>Database Tables Missing.</strong><br />Database tables are missing. This means that MySQL is either not running, WPMU was not installed properly, or someone deleted {$wpdb->site}. You really <em>should</em> look at your database now.<br />"; 194 } else { 195 $msg .= '<strong>Could Not Find Blog!</strong><br />'; 196 $msg .= "Searched for <em>" . $domain . $path . "</em> in " . DB_NAME . "::" . $wpdb->blogs . " table. Is that right?<br />"; 197 } 198 $msg .= "<br />\n<h1>What do I do now?</h1>"; 199 $msg .= "Read the <a target='_blank' href='http://codex.wordpress.org/Debugging_WPMU'>bug report</a> page. Some of the guidelines there may help you figure out what went wrong.<br />"; 200 $msg .= "If you're still stuck with this message, then check that your database contains the following tables:<ul> 201 <li> $wpdb->blogs </li> 202 <li> $wpdb->users </li> 203 <li> $wpdb->usermeta </li> 204 <li> $wpdb->site </li> 205 <li> $wpdb->sitemeta </li> 206 <li> $wpdb->sitecategories </li> 207 </ul>"; 208 $msg .= "If you suspect a problem please report it to the support forums but you must include the information asked for in the <a href='http://codex.wordpress.org/Debugging_WPMU'>WPMU bug reporting guidelines</a>!<br /><br />"; 209 if ( is_file( 'release-info.txt' ) ) { 210 $msg .= 'Your bug report must include the following text: "'; 211 $info = file( 'release-info.txt' ); 212 $msg .= $info[ 4 ] . '"'; 213 } 214 215 die( "<h1>Fatal Error</h1> " . $msg ); 216 } 221 if ( defined( 'WP_INSTALLING' ) ) 222 return; 223 224 $msg = '<h1>' . esc_html__( 'Fatal Error' ) . '</h1>'; 225 $msg = '<p>' . __( 'If your blog does not display, please contact the owner of this site.' ) . '</p>'; 226 $msg .= '<p>' . __( 'If you are the owner of this site please check that MySQL is running properly and all tables are error free.' ) . '</p>'; 227 if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ) 228 $msg .= '<p>' . sprintf( __( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted <code>%s</code>. You really <em>should</em> look at your database now.' ), $wpdb->site ) . '</p>'; 229 else 230 $msg .= '<p>' . sprintf( __( '<strong>Could Not Find Blog!</strong> Searched for table <em>%1$s</em> in <code>%2$s</code>. Is that right?' ), $domain . $path, DB_NAME, $wpdb->blogs ) . '</p>'; 231 $msg .= '<h1>' . esc_html__( 'What do I do now?' ) . '</h1>'; 232 // @todo Update WPMU codex link. 233 $msg .= '<p>' . __( 'Read the <a target="_blank" href="http://codex.wordpress.org/Debugging_WPMU">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' ) . '</p>'; 234 $msg .= '<p>' . __( "If you're still stuck with this message, then check that your database contains the following tables:" ) . '</p><ul>'; 235 foreach ( $wpdb->global_tables as $table ) { 236 $msg .= '<li>' . $wpdb->prefix . $table . '</li>'; 237 } 238 $msg .= '</ul>'; 239 // @todo Update WPMU codex link and support instructions. 240 $msg = '<p>' . __( 'If you suspect a problem please report it to the support forums but you must include the information asked for in the <a target="_blank" href="http://codex.wordpress.org/Debugging_WPMU">WPMU bug reporting guidelines</a>! ' ) . '</p>'; 241 242 // @todo This file no longer exists post-merge. 243 if ( is_file( 'release-info.txt' ) ) { 244 $msg .= '<p>' . __( 'Your bug report must include the following text:' ) . '</p>'; 245 $info = file( 'release-info.txt' ); 246 $msg .= $info[ 4 ] . '"'; 247 } 248 249 die( $msg ); 217 250 } 218 251
Note: See TracChangeset
for help on using the changeset viewer.