function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '') { global $wpdb; $base = '/'; $domain = JQUERY_STAGING_PREFIX . 'jquery.com'; wp_check_mysql_version(); wp_cache_flush(); make_db_current_silent(); populate_options(); populate_roles(); $user_id = wp_create_user($user_name, trim($user_password), $user_email); $user = new WP_User($user_id); $user->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); update_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); jquery_install_remaining_sites($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); }
?> <a href="<?php echo esc_url(site_url('wp-login.php')); ?> "><?php _e('Log In'); ?> </a></p> <?php } } if ($_POST) { check_admin_referer('install-network-1'); require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // create network tables install_network(); $base = parse_url(trailingslashit(get_option('home')), PHP_URL_PATH); $subdomain_install = allow_subdomain_install() ? !empty($_POST['subdomain_install']) : false; if (!network_domain_check()) { $result = populate_network(1, get_clean_basedomain(), sanitize_email($_POST['email']), wp_unslash($_POST['sitename']), $base, $subdomain_install); if (is_wp_error($result)) { if (1 == count($result->get_error_codes()) && 'no_wildcard_dns' == $result->get_error_code()) { network_step2($result); } else { network_step1($result); } } else { network_step2(); } } else { network_step2();
private function _multisite_convert($assoc_args) { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // need to register the multisite tables manually for some reason foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) { $wpdb->{$table} = $prefixed_table; } install_network(); $domain = self::get_clean_basedomain(); $result = populate_network($assoc_args['site_id'], $domain, get_option('admin_email'), $assoc_args['title'], $assoc_args['base'], $assoc_args['subdomains']); if (true === $result) { WP_CLI::log('Set up multisite database tables.'); } else { if (is_wp_error($result)) { switch ($result->get_error_code()) { case 'siteid_exists': WP_CLI::log($result->get_error_message()); return false; case 'no_wildcard_dns': WP_CLI::warning(__('Wildcard DNS may not be configured correctly.')); break; default: WP_CLI::error($result); } } } if (!is_multisite()) { ob_start(); ?> define('MULTISITE', true); define('SUBDOMAIN_INSTALL', <?php var_export($assoc_args['subdomains']); ?> ); $base = '<?php echo $assoc_args['base']; ?> '; define('DOMAIN_CURRENT_SITE', '<?php echo $domain; ?> '); define('PATH_CURRENT_SITE', '<?php echo $assoc_args['base']; ?> '); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); <?php $ms_config = ob_get_clean(); self::modify_wp_config($ms_config); WP_CLI::log('Added multisite constants to wp-config.php.'); } return true; }
private function _multisite_convert($assoc_args) { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $domain = self::get_clean_basedomain(); if ('localhost' === $domain && !empty($assoc_args['subdomains'])) { WP_CLI::error("Multisite with subdomains cannot be configured when domain is 'localhost'."); } // need to register the multisite tables manually for some reason foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) { $wpdb->{$table} = $prefixed_table; } install_network(); $result = populate_network($assoc_args['site_id'], $domain, get_option('admin_email'), $assoc_args['title'], $assoc_args['base'], $assoc_args['subdomains']); if (true === $result) { WP_CLI::log('Set up multisite database tables.'); } else { if (is_wp_error($result)) { switch ($result->get_error_code()) { case 'siteid_exists': WP_CLI::log($result->get_error_message()); return false; case 'no_wildcard_dns': WP_CLI::warning(__('Wildcard DNS may not be configured correctly.')); break; default: WP_CLI::error($result); } } } // delete_site_option() cleans the alloptions cache to prevent dupe option delete_site_option('upload_space_check_disabled'); update_site_option('upload_space_check_disabled', 1); if (!is_multisite()) { $subdomain_export = Utils\get_flag_value($assoc_args, 'subdomains') ? 'true' : 'false'; $ms_config = <<<EOT define( 'WP_ALLOW_MULTISITE', true ); define( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', {$subdomain_export} ); \$base = '{$assoc_args['base']}'; define( 'DOMAIN_CURRENT_SITE', '{$domain}' ); define( 'PATH_CURRENT_SITE', '{$assoc_args['base']}' ); define( 'SITE_ID_CURRENT_SITE', 1 ); define( 'BLOG_ID_CURRENT_SITE', 1 ); EOT; $wp_config_path = Utils\locate_wp_config(); if (is_writable($wp_config_path)) { self::modify_wp_config($ms_config); WP_CLI::log('Added multisite constants to wp-config.php.'); } else { WP_CLI::warning('Multisite constants could not be written to wp-config.php. You may need to add them manually:'); WP_CLI::log($ms_config); } } return true; }
global $current_section; $current_section = 'configuration'; require_once '../../init.php'; // Required files require_once MAD_PATH . '/www/cp/auth.php'; require_once MAD_PATH . '/functions/adminredirect.php'; require_once MAD_PATH . '/www/cp/restricted.php'; require_once MAD_PATH . '/www/cp/admin_functions.php'; require_once MAD_PATH . '/www/cp/templates/header.tpl.php'; if (!check_permission('configuration', $user_detail['user_id'])) { exit; } if (isset($_GET['action'])) { if ($_GET['action'] == 'install' && !empty($_GET['networkid'])) { install_network($_GET['networkid']); } if ($_GET['action'] == 'uninstall' && !empty($_GET['networkid'])) { uninstall_network($_GET['networkid']); } } ?> <div id="content"> <div id="contentHeader"> <h1>Ad Network Modules</h1> </div> <!-- #contentHeader --> <div class="container">
public function install() { global $table_prefix; error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); define('WP_INSTALLING', true); $this->startHeadlessRequest(); if ($this->isMultisite) { echo "Running as multisite..." . PHP_EOL; define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', WP_TESTS_DOMAIN); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); $GLOBALS['base'] = '/'; } else { echo "Running as single site..." . PHP_EOL; } // Preset WordPress options defined in bootstrap file. // Used to activate themes, plugins, as well as other settings. if (isset($GLOBALS['wp_tests_options'])) { function wp_tests_options($value) { $key = substr(current_filter(), strlen('pre_option_')); return $GLOBALS['wp_tests_options'][$key]; } foreach (array_keys($GLOBALS['wp_tests_options']) as $key) { tests_add_filter('pre_option_' . $key, 'wp_tests_options'); } } // Load WordPress require_once ABSPATH . 'wp-settings.php'; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; require_once ABSPATH . 'wp-includes/wp-db.php'; define('WP_TESTS_VERSION_FILE', ABSPATH . '.wp-tests-version'); $wpdb->suppress_errors(); $installed = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'siteurl'"); $wpdb->suppress_errors(false); $hash = get_option('db_version') . ' ' . (int) $multisite . ' ' . sha1(json_encode($this->settings)); if (!$this->alwaysReinstall && $installed && file_exists(WP_TESTS_VERSION_FILE) && file_get_contents(WP_TESTS_VERSION_FILE) == $hash) { return; } $wpdb->query('SET storage_engine = INNODB'); $wpdb->select(DB_NAME, $wpdb->dbh); echo "Installing..." . PHP_EOL; // Drop all tables foreach ($wpdb->get_col($wpdb->prepare("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA='%s'", DB_NAME)) as $table) { $wpdb->query("DROP TABLE IF EXISTS {$table}"); } wp_install(WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, $this->adminPassword); if ($multisite) { echo "Installing network..." . PHP_EOL; define('WP_INSTALLING_NETWORK', true); $title = WP_TESTS_TITLE . ' Network'; $subdomain_install = false; install_network(); populate_network(1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install); } file_put_contents(WP_TESTS_VERSION_FILE, $hash); if ($this->events['after-install'] !== null) { $this->events['after-install'](); } }
public function install_network($args, $assoc_args) { if (is_multisite()) { WP_CLI::error('This already is a multisite install.'); } global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // need to register the multisite tables manually for some reason foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) { $wpdb->{$table} = $prefixed_table; } WP_CLI::check_required_args(array('title'), $assoc_args); extract(wp_parse_args($assoc_args, array('base' => '/'))); $hostname = self::get_clean_basedomain(); $subdomain_install = isset($assoc_args['subdomains']); install_network(); $result = populate_network(1, $hostname, get_option('admin_email'), $assoc_args['title'], $base, $subdomain_install); if (is_wp_error($result)) { WP_CLI::error($result); } ob_start(); ?> define('MULTISITE', true); define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?> ); $base = '<?php echo $base; ?> '; define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?> '); define('PATH_CURRENT_SITE', '<?php echo $base; ?> '); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); <?php $ms_config = ob_get_clean(); $wp_config_path = WP_CLI::locate_wp_config(); $token = "/* That's all, stop editing!"; list($before, $after) = explode($token, file_get_contents($wp_config_path)); file_put_contents($wp_config_path, $before . $ms_config . $token . $after); wp_mkdir_p(WP_CONTENT_DIR . '/blogs.dir'); WP_CLI::success("Network installed. Don't forget to set up rewrite rules."); }
function execute() { if (getconfig_var('last_trafficrequest_update') == '') { //path to directory to scan $directory = MAD_PATH . "/modules/network_modules/"; //get all files in specified directory $files = glob($directory . "*"); //print each file name foreach ($files as $file) { //check to see if the file is a folder/directory if (is_dir($file)) { $network_name = str_replace(MAD_PATH . "/modules/network_modules/", '', $file); install_network($network_name); } } } // removing all madserve.org references since it's expired // $time_since_last_tr = time() - getconfig_var('last_trafficrequest_update'); // if ($time_since_last_tr >= MAD_TRCHECK_INTERVAL_DASHBOARD or !is_numeric(getconfig_var('last_trafficrequest_update'))) { // update_traffic_requests(); // } $time_since_last_pending_exec = time() - getconfig_var('last_pendingactions_exec'); if ($time_since_last_pending_exec >= MAD_ACTION_EXEC_INTERVAL_DASHBOARD or !is_numeric(getconfig_var('last_pendingactions_exec'))) { execute_pending_actions(); } }
protected function createMultisiteTables() { global $wpdb; // We need to create references to ms global tables to enable Network. foreach ($this->multisiteTables() as $table => $prefixed_table) { $wpdb->{$table} = $prefixed_table; } // Create network tables. require_once wordpress_path('wp-admin/includes/upgrade.php'); install_network(); }