diff --git a/wp-admin/includes/htaccess.ms b/wp-admin/includes/htaccess.ms new file mode 100644 index 0000000000..a10abfe078 --- /dev/null +++ b/wp-admin/includes/htaccess.ms @@ -0,0 +1,26 @@ +RewriteEngine On +RewriteBase BASE/ + +#uploaded files +RewriteRule ^(.*/)?files/$ index.php [L] +RewriteCond %{REQUEST_URI} !.*wp-content/plugins.* +RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L] + +# add a trailing slash to /wp-admin +RewriteCond %{REQUEST_URI} ^.*/wp-admin$ +RewriteRule ^(.+)$ $1/ [R=301,L] + +RewriteCond %{REQUEST_FILENAME} -f [OR] +RewriteCond %{REQUEST_FILENAME} -d +RewriteRule . - [L] +RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L] +RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] +RewriteRule . index.php [L] + + + +SecFilterEngine Off +SecFilterScanPOST Off + + + diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index acb0f18c56..9d91a19526 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -317,6 +317,12 @@ function populate_options() { 'embed_size_h' => 600, ); + // 3.0 multisite + if ( is_multisite() ) { + $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name ); + $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; + } + // Set autoload to no for these options $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); @@ -606,4 +612,119 @@ function populate_roles_300() { } } +/** + * populate network settings + * + * @since 3.0 + * + * @param int $network_id id of network to populate + */ +function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $vhost = 'no' ) { + global $wpdb, $current_site, $wp_version, $wp_db_version, $wp_rewrite; + + //@todo: turn these checks into returned messages + if( $domain == '' ) + die( 'You must provide a domain name!' ); + if( $site_name == '' ) + die( 'You must provide a site name!' ); + + // check for network collision + $existing_network = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$wpdb->site} WHERE id = %d", $network_id ) ); + if( $existing_network == $network_id ) + die( 'That network already exists!' ); + + $site_user = get_user_by_email( $email ); + if( !$site_user ) + die( 'You must provide an email address!' ); + // set up site tables + $template = get_option( 'template' ); + $stylesheet = get_option( 'stylesheet' ); + if ( $template != $stylesheet ) { + $allowed_themes = array( $template, $stylesheet ); + } else { + $allowed_themes = array( $stylesheet ); + } + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'site_name', %s)", $network_id, $site_name ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'admin_email', %s)", $network_id, $site_user->user_email ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'admin_user_id', %d)", $network_id, $site_user->ID ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'registration', 'none')", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( %d, %s, %s )", $network_id, $domain, $path ) ); + if ( !is_multisite() ) { + $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (1, 'Uncategorized', 'uncategorized', NOW())" ); + $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (2, 'Blogroll', 'blogroll', NOW())" ); + } + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'upload_filetypes', 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf' )", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'blog_upload_space', '10' )", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'fileupload_maxk', '1500' )", $network_id ) ); + if ( !is_multisite() ) { + $site_admins = array( $site_user->user_login ); + $users = get_users_of_blog(); + if ( $users ) { + foreach ( $users as $user ) { + if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) ) { + $site_admins[] = $user->user_login; + } + } + } + } else { + $site_admins = get_site_option( 'site_admins' ); + } + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'site_admins', '" . serialize( $site_admins ) . "' )", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'allowedthemes', '" . serialize( $allowed_themes ) . "' )", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'illegal_names', '" . serialize( array( "www", "web", "root", "admin", "main", "invite", "administrator" ) ) . "' )", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'wpmu_upgrade_site', '{$wp_db_version}')", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'welcome_email', 'Dear User, + +Your new SITE_NAME blog has been successfully set up at: +BLOG_URL + +You can log in to the administrator account with the following information: +Username: USERNAME +Password: PASSWORD +Login Here: BLOG_URLwp-login.php + +We hope you enjoy your new blog. +Thanks! + +--The Team @ SITE_NAME')", $network_id ) ); + $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'first_post', 'Welcome to SITE_NAME. This is your first post. Edit or delete it, then start blogging!' )", $network_id ) ); + $weblog_title = stripslashes( $_POST[ 'weblog_title' ] ); + + $current_site->domain = $domain; + $current_site->path = $base; + $current_site->site_name = ucfirst( $domain ); + + if ( !is_multisite() ) { + $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->blogs} (site_id, domain, path) VALUES (%s, %s, %s)", $network_id, $domain, $path ) ); + update_usermeta( $site_user->ID, 'source_domain', $domain ); + update_usermeta( $site_user->ID, 'primary_blog', 1 ); + } + + if( $vhost == 'yes' ) { + update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); + } else { + update_option( 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/'); + } + $wp_rewrite->flush_rules(); + + if ( $vhost == 'yes' ) { + $vhost_ok = false; + $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! + $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); + if( is_object( $page ) && is_wp_error( $page ) ) { + foreach ( $page->get_error_messages() as $err ) + $errstr = $err; + } elseif( $page[ 'response' ][ 'code' ] == 200 ) { + $vhost_ok = true; + } + if( !$vhost_ok ) { + $msg = "

Warning! Wildcard DNS may not be configured correctly!

"; + $msg .= "

To use the subdomain feature of WordPress MU you must have a wildcard entry in your dns. The installer attempted to contact a random hostname ($hostname) on your domain but failed. It returned this error message:
$errstr

From the README.txt:

"; + $msg .= "

If you want to host blogs of the form http://blog.domain.tld/ where domain.tld is the domain name of your machine then you must add a wildcard record to your DNS records.
+This usually means adding a '*' hostname record pointing at your webserver in your DNS configuration tool. Matt has a more detailed explanation on his blog. If you still have problems, these forum messages may help.

"; + $msg .= "

You can still use your site but any subdomain you create may not be accessible. This check is not foolproof so ignore if you know your dns is correct.

"; + } + } + return $msg; +} ?> diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 8895b0e3b8..2cdcd12294 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1713,4 +1713,108 @@ function pre_schema_upgrade() { } +/** + * Install Network. + * + * @since 3.0 + * + */ +if ( !function_exists( 'install_network' ) ) : +function install_network() { + global $wpdb, $charset_collate; + $ms_queries = " +CREATE TABLE $wpdb->users ( + ID bigint(20) unsigned NOT NULL auto_increment, + user_login varchar(60) NOT NULL default '', + user_pass varchar(64) NOT NULL default '', + user_nicename varchar(50) NOT NULL default '', + user_email varchar(100) NOT NULL default '', + user_url varchar(100) NOT NULL default '', + user_registered datetime NOT NULL default '0000-00-00 00:00:00', + user_activation_key varchar(60) NOT NULL default '', + user_status int(11) NOT NULL default '0', + display_name varchar(250) NOT NULL default '', + spam tinyint(2) NOT NULL default '0', + deleted tinyint(2) NOT NULL default '0', + PRIMARY KEY (ID), + KEY user_login_key (user_login), + KEY user_nicename (user_nicename) +) $charset_collate; +CREATE TABLE $wpdb->blogs ( + blog_id bigint(20) NOT NULL auto_increment, + site_id bigint(20) NOT NULL default '0', + domain varchar(200) NOT NULL default '', + path varchar(100) NOT NULL default '', + registered datetime NOT NULL default '0000-00-00 00:00:00', + last_updated datetime NOT NULL default '0000-00-00 00:00:00', + public tinyint(2) NOT NULL default '1', + archived enum('0','1') NOT NULL default '0', + mature tinyint(2) NOT NULL default '0', + spam tinyint(2) NOT NULL default '0', + deleted tinyint(2) NOT NULL default '0', + lang_id int(11) NOT NULL default '0', + PRIMARY KEY (blog_id), + KEY domain (domain(50),path(5)), + KEY lang_id (lang_id) +) $charset_collate; +CREATE TABLE $wpdb->blog_versions ( + blog_id bigint(20) NOT NULL default '0', + db_version varchar(20) NOT NULL default '', + last_updated datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (blog_id), + KEY db_version (db_version) +) $charset_collate; +CREATE TABLE $wpdb->registration_log ( + ID bigint(20) NOT NULL auto_increment, + email varchar(255) NOT NULL default '', + IP varchar(30) NOT NULL default '', + blog_id bigint(20) NOT NULL default '0', + date_registered datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (ID), + KEY IP (IP) +) $charset_collate; +CREATE TABLE $wpdb->site ( + id bigint(20) NOT NULL auto_increment, + domain varchar(200) NOT NULL default '', + path varchar(100) NOT NULL default '', + PRIMARY KEY (id), + KEY domain (domain,path) +) $charset_collate; +CREATE TABLE $wpdb->sitemeta ( + meta_id bigint(20) NOT NULL auto_increment, + site_id bigint(20) NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (meta_id), + KEY meta_key (meta_key), + KEY site_id (site_id) +) $charset_collate; +CREATE TABLE $wpdb->sitecategories ( + cat_ID bigint(20) NOT NULL auto_increment, + cat_name varchar(55) NOT NULL default '', + category_nicename varchar(200) NOT NULL default '', + last_updated timestamp NOT NULL, + PRIMARY KEY (cat_ID), + KEY category_nicename (category_nicename), + KEY last_updated (last_updated) +) $charset_collate; +CREATE TABLE $wpdb->signups ( + domain varchar(200) NOT NULL default '', + path varchar(100) NOT NULL default '', + title longtext NOT NULL, + user_login varchar(60) NOT NULL default '', + user_email varchar(100) NOT NULL default '', + registered datetime NOT NULL default '0000-00-00 00:00:00', + activated datetime NOT NULL default '0000-00-00 00:00:00', + active tinyint(1) NOT NULL default '0', + activation_key varchar(50) NOT NULL default '', + meta longtext, + KEY activation_key (activation_key), + KEY domain (domain) +) $charset_collate; +"; +// now create tables + dbDelta( $ms_queries ); +} +endif; ?> diff --git a/wp-admin/includes/wp-config.ms b/wp-admin/includes/wp-config.ms new file mode 100644 index 0000000000..68c69a2659 --- /dev/null +++ b/wp-admin/includes/wp-config.ms @@ -0,0 +1,116 @@ +