diff --git a/config.php b/config.php deleted file mode 100644 index f04ff5e0..00000000 --- a/config.php +++ /dev/null @@ -1,108 +0,0 @@ -set_role( 'administrator' ); - - $guess_url = wp_guess_url(); - - foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) - $wpdb->$table = $prefixed_table; - - install_network(); - populate_network( 1, $domain, $user_email, 'jQuery Network', $base, false ); - - delete_site_option( 'site_admins' ); - add_site_option( 'site_admins', array( $user->user_login ) ); - - update_site_option( 'allowedthemes', array() ); - - $wpdb->insert( $wpdb->blogs, array( 'site_id' => 1, 'domain' => $domain, 'path' => $base, 'registered' => current_time( 'mysql' ) ) ); - $blog_id = $wpdb->insert_id; - update_user_meta( $user_id, 'source_domain', $domain ); - update_user_meta( $user_id, 'primary_blog', $blog_id ); - if ( !$upload_path = get_option( 'upload_path' ) ) { - $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads'; - update_option( 'upload_path', $upload_path ); - } - update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path ); - - foreach ( jquery_sites() as $site => $details ) - jquery_install_site( $site, $user ); - - wp_new_blog_notification( $blog_title, $guess_url, $user_id, $message = __( 'The password you chose during the install.' ) ); - wp_cache_flush(); - - return array( 'url' => $guess_url, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message ); -} - -function jquery_install_site( $site, $user ) { - $sites = jquery_sites(); - $details = $sites[ $site ]; - - if ( strpos( $site, '/' ) ) { - list( $domain, $path ) = explode( '/', $site, 2 ); - $path = '/' . trim( $path, '/' ) . '/'; - } else { - $domain = $site; - $path = '/'; - } - - $default_options = jquery_default_site_options(); - $default_options['admin_email'] = $user->user_email; - - if ( 1 !== $details['blog_id'] ) { - // krinkle(2021-09-03): This used to use insert_blog which didn't take a blog_id. - // Thus, this only worked reliably when setting up a fresh server, or when adding - // sites in the exact order that they are defined, and without any gaps, as otherwise - // the "next" inserted ID would not match what we declare in jquery_sites() - // - // $blog_id = insert_blog( JQUERY_STAGING_PREFIX . $domain, $path, 1 ); - // - // WordPress 5.1, deprecates insert_blog() in favour of a new wp_insert_site() function, - // which does accept a custom 'blog_id' to be set up front. - // But, we are still on WordPress 4.x, so, for now inline what insert_blog() did, but - // augmented with a custom blog_id. - // - // Start insert_blog() - global $wpdb; - $path = trailingslashit($path); - // WordPress 4 terms: The network is a site, and each domain is a blog. - // WordPress 5+ terms: The network is a network, and each domain is a site. - // Network id must be constant for all blogs, always 1. - $site_id = 1; - $result = $wpdb->insert( $wpdb->blogs, array('site_id' => (int)$site_id, 'blog_id' => (int)$details['blog_id'], 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) ); - $blog_id = $result ? $wpdb->insert_id : false; - refresh_blog_details( $blog_id ); - wp_maybe_update_network_site_counts(); - // End insert_blog() - - if ( $blog_id != $details['blog_id'] ) - wp_die( "Something went very wrong when trying to install $domain as site $blog_id-{$details['blog_id']}. Find nacin." ); - - switch_to_blog( $blog_id ); - - install_blog( $blog_id, $details['options']['blogname'] ); - - add_user_to_blog( $blog_id, $user->ID, 'administrator' ); - } - - $options = array_merge( $default_options, $details['options'] ); - foreach ( $options as $option => $value ) - update_option( $option, $value ); - - delete_option( 'rewrite_rules' ); - restore_current_blog(); -} diff --git a/sunrise.php b/sunrise.php deleted file mode 100644 index 72063820..00000000 --- a/sunrise.php +++ /dev/null @@ -1,67 +0,0 @@ -id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1; - $current_site->blog_id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1; - $current_site->cookie_domain = defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '.jquery.com'; - $current_site->domain = DOMAIN_CURRENT_SITE; - $current_site->path = PATH_CURRENT_SITE; - $current_site->site_name = 'jQuery'; -} - -if ( isset( $blog_id ) ) { - $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); - - // If for some reason this became a multi-network configuration, populate the site's network. - if ( is_object( $current_blog ) && $current_blog->site_id != $current_site->id ) { - $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * from $wpdb->site WHERE id = %d LIMIT 0,1", $current_blog->site_id ) ); - $current_site->site_name = 'jQuery'; - } - - // Can't find the site in the DB: - if ( ! is_object( $current_blog ) ) { - $current_blog = new stdClass; - $current_blog->blog_id = $current_blog->site_id = $current_blog->public = 1; - $current_blog->archived = $current_blog->deleted = $current_blog->spam = 0; - - add_filter( 'ms_site_check', '__return_true' ); - - if ( ! defined( 'WP_INSTALLING' ) ) { - // Okay, see if we can find the main site in the DB. - // If not, time for a new network install. - if ( 1 == $blog_id || ! $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs WHERE blog_id = 1" ) ) { - require( ABSPATH . WPINC . '/kses.php' ); - require( ABSPATH . WPINC . '/pluggable.php' ); - require( ABSPATH . WPINC . '/formatting.php' ); - wp_redirect( 'http://' . DOMAIN_CURRENT_SITE . '/wp-admin/install.php' ); - die(); - } - - // Otherwise, we have a working network, but have a new site to install. Do that now. - define( 'WP_INSTALLING', true ); - add_action( 'init', function() use ( $blog_id ) { - global $wpdb; - $wpdb->set_blog_id( $blog_id ); - if ( is_super_admin() ) { - $super_admin = wp_get_current_user(); - } else { - $super_admins = get_super_admins(); - $super_admin = get_user_by( 'login', reset( $super_admins ) ); - } - require ABSPATH . 'wp-admin/includes/upgrade.php'; - $sites = jquery_sites(); - $site = str_replace( JQUERY_STAGING_PREFIX, '', $_SERVER['HTTP_HOST'] ); - if ( ! empty( $sites[ $site ]['subsites'] ) ) { - list( $first_path_segment ) = explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ), 2 ); - if ( $first_path_segment && isset( $sites[ $site . '/' . $first_path_segment ] ) ) - $site .= '/' . $first_path_segment; - } - - jquery_install_site( $site, $super_admin ); - wp_safe_redirect( 'http://' . JQUERY_STAGING_PREFIX . $site ); - exit; - } ); - } - } -} \ No newline at end of file