2010-01-10 13:10:51 -05:00
< ? php
/**
* Used to setup and fix common variables and include
* the WordPress procedural and class library .
*
* You should not have to change this file and allows
* for some configuration in wp - config . php .
*
* @ since 3.0
*
* @ package WordPress
*/
2010-01-20 02:44:47 -05:00
if ( defined ( 'SUNRISE' ) )
2010-01-10 13:10:51 -05:00
include_once ( WP_CONTENT_DIR . '/sunrise.php' );
2010-01-20 02:44:47 -05:00
require ( ABSPATH . WPINC . '/ms-settings.php' );
2010-01-19 12:27:03 -05:00
$wpdb -> blogid = $current_blog -> blog_id ;
$wpdb -> siteid = $current_blog -> site_id ;
2010-01-10 13:10:51 -05:00
$wpdb -> set_prefix ( $table_prefix ); // set up blog tables
2010-01-15 13:02:34 -05:00
$table_prefix = $wpdb -> get_blog_prefix ();
2010-01-10 13:10:51 -05:00
// Fix empty PHP_SELF
$PHP_SELF = $_SERVER [ 'PHP_SELF' ];
if ( empty ( $PHP_SELF ) || ( empty ( $PHP_SELF ) && constant ( 'VHOST' ) == 'no' && $current_blog -> path != '/' ) )
$_SERVER [ 'PHP_SELF' ] = $PHP_SELF = preg_replace ( " /( \ ?.*)? $ / " , '' , $_SERVER [ " REQUEST_URI " ]);
wp_cache_init (); // need to init cache again after blog_id is set
if ( function_exists ( 'wp_cache_add_global_groups' ) ) { // need to add these again. Yes, it's an ugly hack
wp_cache_add_global_groups ( array ( 'users' , 'userlogins' , 'usermeta' , 'site-options' , 'site-lookup' , 'blog-lookup' , 'blog-details' , 'rss' ));
wp_cache_add_non_persistent_groups ( array ( 'comment' , 'counts' , 'plugins' ));
}
2010-01-20 02:44:47 -05:00
if ( ! defined ( 'UPLOADBLOGSDIR' ) )
define ( 'UPLOADBLOGSDIR' , 'wp-content/blogs.dir' );
2010-01-10 13:10:51 -05:00
2010-01-20 02:44:47 -05:00
if ( ! defined ( 'UPLOADS' ) )
define ( 'UPLOADS' , UPLOADBLOGSDIR . " / { $wpdb -> blogid } /files/ " );
2010-01-10 13:10:51 -05:00
2010-01-20 02:44:47 -05:00
if ( ! defined ( 'BLOGUPLOADDIR' ) )
define ( 'BLOGUPLOADDIR' , WP_CONTENT_DIR . " /blogs.dir/ { $wpdb -> blogid } /files/ " );
2010-01-10 13:10:51 -05:00
function ms_network_settings () {
2010-01-19 12:27:03 -05:00
global $wpdb , $current_site , $cookiehash ;
2010-01-10 13:10:51 -05:00
2010-01-20 02:44:47 -05:00
if ( ! isset ( $current_site -> site_name ) )
2010-01-19 12:27:03 -05:00
$current_site -> site_name = get_site_option ( 'site_name' );
2010-01-10 13:10:51 -05:00
2010-01-20 02:44:47 -05:00
if ( $current_site -> site_name == false )
2010-01-19 12:27:03 -05:00
$current_site -> site_name = ucfirst ( $current_site -> domain );
2010-01-10 13:10:51 -05:00
2010-01-19 12:27:03 -05:00
$wpdb -> hide_errors ();
2010-01-10 13:10:51 -05:00
}
function ms_network_plugins () {
2010-01-19 12:27:03 -05:00
$network_plugins = array ();
2010-01-20 02:37:53 -05:00
$deleted_sitewide_plugins = array ();
2010-01-19 12:27:03 -05:00
$wpmu_sitewide_plugins = ( array ) maybe_unserialize ( get_site_option ( 'wpmu_sitewide_plugins' ) );
2010-01-20 02:44:47 -05:00
foreach ( $wpmu_sitewide_plugins as $plugin_file => $activation_time ) {
2010-01-19 12:27:03 -05:00
if ( ! $plugin_file )
continue ;
2010-01-20 02:37:53 -05:00
if ( ! file_exists ( WP_PLUGIN_DIR . '/' . $plugin_file ) )
2010-01-19 12:27:03 -05:00
$deleted_sitewide_plugins [] = $plugin_file ;
2010-01-20 02:37:53 -05:00
else
$network_plugins [] = WP_PLUGIN_DIR . '/' . $plugin_file ;
2010-01-19 12:27:03 -05:00
}
2010-01-20 02:37:53 -05:00
if ( ! empty ( $deleted_sitewide_plugins ) ) {
2010-01-19 12:27:03 -05:00
$active_sitewide_plugins = maybe_unserialize ( get_site_option ( 'active_sitewide_plugins' ) );
/* Remove any deleted plugins from the wpmu_sitewide_plugins array */
2010-01-20 02:44:47 -05:00
foreach ( $deleted_sitewide_plugins as $plugin_file ) {
2010-01-19 12:27:03 -05:00
unset ( $wpmu_sitewide_plugins [ $plugin_file ] );
unset ( $active_sitewide_plugins [ $plugin_file ] );
}
update_site_option ( 'wpmu_sitewide_plugins' , $wpmu_sitewide_plugins );
update_site_option ( 'active_sitewide_plugins' , $wpmu_sitewide_plugins );
}
return $network_plugins ;
2010-01-10 13:10:51 -05:00
}
function ms_site_check () {
2010-01-20 02:44:47 -05:00
global $wpdb , $current_blog ;
$wpdb -> show_errors ();
if ( '1' == $current_blog -> deleted ) {
if ( file_exists ( WP_CONTENT_DIR . '/blog-deleted.php' ) ) {
return WP_CONTENT_DIR . '/blog-deleted.php' ;
} else {
header ( 'HTTP/1.1 410 Gone' );
graceful_fail ( __ ( 'This user has elected to delete their account and the content is no longer available.' ));
}
}
if ( '2' == $current_blog -> deleted ) {
if ( file_exists ( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {
return WP_CONTENT_DIR . '/blog-inactive.php' ;
} else {
graceful_fail ( 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 } " ) ) ) );
}
}
if ( $current_blog -> archived == '1' || $current_blog -> spam == '1' ) {
if ( file_exists ( WP_CONTENT_DIR . '/blog-suspended.php' ) ) {
return WP_CONTENT_DIR . '/blog-suspended.php' ;
} else {
header ( 'HTTP/1.1 410 Gone' );
graceful_fail ( __ ( 'This blog has been archived or suspended.' ));
}
}
return true ;
2010-01-10 13:10:51 -05:00
}
function ms_network_cookies () {
2010-01-20 02:44:47 -05:00
global $current_site ;
/**
* It is possible to define this in wp - config . php
* @ since 1.2 . 0
*/
if ( ! defined ( 'COOKIEPATH' ) )
define ( 'COOKIEPATH' , $current_site -> path );
/**
* It is possible to define this in wp - config . php
* @ since 1.5 . 0
*/
if ( ! defined ( 'SITECOOKIEPATH' ) )
define ( 'SITECOOKIEPATH' , $current_site -> path );
/**
* It is possible to define this in wp - config . php
* @ since 2.6 . 0
*/
if ( ! defined ( 'ADMIN_COOKIE_PATH' ) ) {
if ( ! is_subdomain_install () ) {
define ( 'ADMIN_COOKIE_PATH' , SITECOOKIEPATH );
} else {
define ( 'ADMIN_COOKIE_PATH' , SITECOOKIEPATH . 'wp-admin' );
}
}
/**
* It is possible to define this in wp - config . php
* @ since 2.0 . 0
*/
if ( ! defined ( 'COOKIE_DOMAIN' ) )
2010-01-21 12:20:23 -05:00
define ( 'COOKIE_DOMAIN' , '.' . $current_site -> cookie_domain );
2010-01-10 13:10:51 -05:00
}
?>