Changeset 12756
- Timestamp:
- 01/19/2010 12:04:25 AM (15 years ago)
- Location:
- trunk/wp-admin/includes
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/schema.php
r12754 r12756 318 318 ); 319 319 320 // 3.0 multisite 321 if ( is_multisite() ) { 322 $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name ); 323 $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; 324 } 325 320 326 // Set autoload to no for these options 321 327 $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); … … 607 613 } 608 614 615 /** 616 * populate network settings 617 * 618 * @since 3.0 619 * 620 * @param int $network_id id of network to populate 621 */ 622 function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $vhost = 'no' ) { 623 global $wpdb, $current_site, $wp_version, $wp_db_version, $wp_rewrite; 624 625 //@todo: turn these checks into returned messages 626 if( $domain == '' ) 627 die( 'You must provide a domain name!' ); 628 if( $site_name == '' ) 629 die( 'You must provide a site name!' ); 630 631 // check for network collision 632 $existing_network = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$wpdb->site} WHERE id = %d", $network_id ) ); 633 if( $existing_network == $network_id ) 634 die( 'That network already exists!' ); 635 636 $site_user = get_user_by_email( $email ); 637 if( !$site_user ) 638 die( 'You must provide an email address!' ); 639 // set up site tables 640 $template = get_option( 'template' ); 641 $stylesheet = get_option( 'stylesheet' ); 642 if ( $template != $stylesheet ) { 643 $allowed_themes = array( $template, $stylesheet ); 644 } else { 645 $allowed_themes = array( $stylesheet ); 646 } 647 $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 ) ); 648 $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 ) ); 649 $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 ) ); 650 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'registration', 'none')", $network_id ) ); 651 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( %d, %s, %s )", $network_id, $domain, $path ) ); 652 if ( !is_multisite() ) { 653 $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (1, 'Uncategorized', 'uncategorized', NOW())" ); 654 $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (2, 'Blogroll', 'blogroll', NOW())" ); 655 } 656 $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 ) ); 657 $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 ) ); 658 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'fileupload_maxk', '1500' )", $network_id ) ); 659 if ( !is_multisite() ) { 660 $site_admins = array( $site_user->user_login ); 661 $users = get_users_of_blog(); 662 if ( $users ) { 663 foreach ( $users as $user ) { 664 if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) ) { 665 $site_admins[] = $user->user_login; 666 } 667 } 668 } 669 } else { 670 $site_admins = get_site_option( 'site_admins' ); 671 } 672 $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 ) ); 673 $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 ) ); 674 $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 ) ); 675 $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 ) ); 676 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'welcome_email', 'Dear User, 677 678 Your new SITE_NAME blog has been successfully set up at: 679 BLOG_URL 680 681 You can log in to the administrator account with the following information: 682 Username: USERNAME 683 Password: PASSWORD 684 Login Here: BLOG_URLwp-login.php 685 686 We hope you enjoy your new blog. 687 Thanks! 688 689 --The Team @ SITE_NAME')", $network_id ) ); 690 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' )", $network_id ) ); 691 $weblog_title = stripslashes( $_POST[ 'weblog_title' ] ); 692 693 $current_site->domain = $domain; 694 $current_site->path = $base; 695 $current_site->site_name = ucfirst( $domain ); 696 697 if ( !is_multisite() ) { 698 $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->blogs} (site_id, domain, path) VALUES (%s, %s, %s)", $network_id, $domain, $path ) ); 699 update_usermeta( $site_user->ID, 'source_domain', $domain ); 700 update_usermeta( $site_user->ID, 'primary_blog', 1 ); 701 } 702 703 if( $vhost == 'yes' ) { 704 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); 705 } else { 706 update_option( 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/'); 707 } 708 $wp_rewrite->flush_rules(); 709 710 if ( $vhost == 'yes' ) { 711 $vhost_ok = false; 712 $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! 713 $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); 714 if( is_object( $page ) && is_wp_error( $page ) ) { 715 foreach ( $page->get_error_messages() as $err ) 716 $errstr = $err; 717 } elseif( $page[ 'response' ][ 'code' ] == 200 ) { 718 $vhost_ok = true; 719 } 720 if( !$vhost_ok ) { 721 $msg = "<h2>Warning! Wildcard DNS may not be configured correctly!</h2>"; 722 $msg .= "<p>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:<br /> <strong>$errstr</strong></p><p>From the README.txt:</p>"; 723 $msg .= "<p><blockquote> 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.<br /> 724 This usually means adding a '*' hostname record pointing at your webserver in your DNS configuration tool. Matt has a more detailed <a href='http://ma.tt/2003/10/10/wildcard-dns-and-sub-domains/'>explanation</a> on his blog. If you still have problems, these <a href='http://mu.wordpress.org/forums/tags/wildcard'>forum messages</a> may help.</blockquote></p>"; 725 $msg .= "<p>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.</p>"; 726 } 727 } 728 return $msg; 729 } 609 730 ?> -
trunk/wp-admin/includes/upgrade.php
r12753 r12756 1714 1714 } 1715 1715 1716 /** 1717 * Install Network. 1718 * 1719 * @since 3.0 1720 * 1721 */ 1722 if ( !function_exists( 'install_network' ) ) : 1723 function install_network() { 1724 global $wpdb, $charset_collate; 1725 $ms_queries = " 1726 CREATE TABLE $wpdb->users ( 1727 ID bigint(20) unsigned NOT NULL auto_increment, 1728 user_login varchar(60) NOT NULL default '', 1729 user_pass varchar(64) NOT NULL default '', 1730 user_nicename varchar(50) NOT NULL default '', 1731 user_email varchar(100) NOT NULL default '', 1732 user_url varchar(100) NOT NULL default '', 1733 user_registered datetime NOT NULL default '0000-00-00 00:00:00', 1734 user_activation_key varchar(60) NOT NULL default '', 1735 user_status int(11) NOT NULL default '0', 1736 display_name varchar(250) NOT NULL default '', 1737 spam tinyint(2) NOT NULL default '0', 1738 deleted tinyint(2) NOT NULL default '0', 1739 PRIMARY KEY (ID), 1740 KEY user_login_key (user_login), 1741 KEY user_nicename (user_nicename) 1742 ) $charset_collate; 1743 CREATE TABLE $wpdb->blogs ( 1744 blog_id bigint(20) NOT NULL auto_increment, 1745 site_id bigint(20) NOT NULL default '0', 1746 domain varchar(200) NOT NULL default '', 1747 path varchar(100) NOT NULL default '', 1748 registered datetime NOT NULL default '0000-00-00 00:00:00', 1749 last_updated datetime NOT NULL default '0000-00-00 00:00:00', 1750 public tinyint(2) NOT NULL default '1', 1751 archived enum('0','1') NOT NULL default '0', 1752 mature tinyint(2) NOT NULL default '0', 1753 spam tinyint(2) NOT NULL default '0', 1754 deleted tinyint(2) NOT NULL default '0', 1755 lang_id int(11) NOT NULL default '0', 1756 PRIMARY KEY (blog_id), 1757 KEY domain (domain(50),path(5)), 1758 KEY lang_id (lang_id) 1759 ) $charset_collate; 1760 CREATE TABLE $wpdb->blog_versions ( 1761 blog_id bigint(20) NOT NULL default '0', 1762 db_version varchar(20) NOT NULL default '', 1763 last_updated datetime NOT NULL default '0000-00-00 00:00:00', 1764 PRIMARY KEY (blog_id), 1765 KEY db_version (db_version) 1766 ) $charset_collate; 1767 CREATE TABLE $wpdb->registration_log ( 1768 ID bigint(20) NOT NULL auto_increment, 1769 email varchar(255) NOT NULL default '', 1770 IP varchar(30) NOT NULL default '', 1771 blog_id bigint(20) NOT NULL default '0', 1772 date_registered datetime NOT NULL default '0000-00-00 00:00:00', 1773 PRIMARY KEY (ID), 1774 KEY IP (IP) 1775 ) $charset_collate; 1776 CREATE TABLE $wpdb->site ( 1777 id bigint(20) NOT NULL auto_increment, 1778 domain varchar(200) NOT NULL default '', 1779 path varchar(100) NOT NULL default '', 1780 PRIMARY KEY (id), 1781 KEY domain (domain,path) 1782 ) $charset_collate; 1783 CREATE TABLE $wpdb->sitemeta ( 1784 meta_id bigint(20) NOT NULL auto_increment, 1785 site_id bigint(20) NOT NULL default '0', 1786 meta_key varchar(255) default NULL, 1787 meta_value longtext, 1788 PRIMARY KEY (meta_id), 1789 KEY meta_key (meta_key), 1790 KEY site_id (site_id) 1791 ) $charset_collate; 1792 CREATE TABLE $wpdb->sitecategories ( 1793 cat_ID bigint(20) NOT NULL auto_increment, 1794 cat_name varchar(55) NOT NULL default '', 1795 category_nicename varchar(200) NOT NULL default '', 1796 last_updated timestamp NOT NULL, 1797 PRIMARY KEY (cat_ID), 1798 KEY category_nicename (category_nicename), 1799 KEY last_updated (last_updated) 1800 ) $charset_collate; 1801 CREATE TABLE $wpdb->signups ( 1802 domain varchar(200) NOT NULL default '', 1803 path varchar(100) NOT NULL default '', 1804 title longtext NOT NULL, 1805 user_login varchar(60) NOT NULL default '', 1806 user_email varchar(100) NOT NULL default '', 1807 registered datetime NOT NULL default '0000-00-00 00:00:00', 1808 activated datetime NOT NULL default '0000-00-00 00:00:00', 1809 active tinyint(1) NOT NULL default '0', 1810 activation_key varchar(50) NOT NULL default '', 1811 meta longtext, 1812 KEY activation_key (activation_key), 1813 KEY domain (domain) 1814 ) $charset_collate; 1815 "; 1816 // now create tables 1817 dbDelta( $ms_queries ); 1818 } 1819 endif; 1716 1820 ?>
Note: See TracChangeset
for help on using the changeset viewer.