Пример #1
0
/**
 * Prints step 2 for Network installation process.
 *
 * @since 3.0.0
 */
function network_step2($errors = false)
{
    global $wpdb;
    $hostname = get_clean_basedomain();
    $slashed_home = trailingslashit(get_option('home'));
    $base = parse_url($slashed_home, PHP_URL_PATH);
    $document_root_fix = str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT']));
    $abspath_fix = str_replace('\\', '/', ABSPATH);
    $home_path = 0 === strpos($abspath_fix, $document_root_fix) ? $document_root_fix . $base : get_home_path();
    $wp_siteurl_subdir = preg_replace('#^' . preg_quote($home_path, '#') . '#', '', $abspath_fix);
    $rewrite_base = !empty($wp_siteurl_subdir) ? ltrim(trailingslashit($wp_siteurl_subdir), '/') : '';
    $location_of_wp_config = ABSPATH;
    if (!file_exists(ABSPATH . 'wp-config.php') && file_exists(dirname(ABSPATH) . '/wp-config.php')) {
        $location_of_wp_config = trailingslashit(dirname(ABSPATH));
    }
    // Wildcard DNS message.
    if (is_wp_error($errors)) {
        echo '<div class="error">' . $errors->get_error_message() . '</div>';
    }
    if ($_POST) {
        if (allow_subdomain_install()) {
            $subdomain_install = allow_subdirectory_install() ? !empty($_POST['subdomain_install']) : true;
        } else {
            $subdomain_install = false;
        }
    } else {
        if (is_multisite()) {
            $subdomain_install = is_subdomain_install();
            ?>
	<p><?php 
            _e('The original configuration steps are shown here for reference.');
            ?>
</p>
<?php 
        } else {
            $subdomain_install = (bool) $wpdb->get_var("SELECT meta_value FROM {$wpdb->sitemeta} WHERE site_id = 1 AND meta_key = 'subdomain_install'");
            ?>
	<div class="error"><p><strong><?php 
            _e('Warning:');
            ?>
</strong> <?php 
            _e('An existing WordPress network was detected.');
            ?>
</p></div>
	<p><?php 
            _e('Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.');
            ?>
</p>
<?php 
        }
    }
    $subdir_match = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
    $subdir_replacement_01 = $subdomain_install ? '' : '$1';
    $subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
    if ($_POST || !is_multisite()) {
        ?>
		<h3><?php 
        esc_html_e('Enabling the Network');
        ?>
</h3>
		<p><?php 
        _e('Complete the following steps to enable the features for creating a network of sites.');
        ?>
</p>
		<div class="updated inline"><p><?php 
        if (file_exists($home_path . '.htaccess')) {
            printf(__('<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.'), '.htaccess');
        } elseif (file_exists($home_path . 'web.config')) {
            printf(__('<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.'), 'web.config');
        } else {
            _e('<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.');
        }
        ?>
</p></div>
<?php 
    }
    ?>
		<ol>
			<li><p><?php 
    printf(__('Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:'), $location_of_wp_config);
    ?>
</p>
				<textarea class="code" readonly="readonly" cols="100" rows="6">
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', <?php 
    echo $subdomain_install ? 'true' : 'false';
    ?>
);
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);</textarea>
<?php 
    $keys_salts = array('AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '');
    foreach ($keys_salts as $c => $v) {
        if (defined($c)) {
            unset($keys_salts[$c]);
        }
    }
    if (!empty($keys_salts)) {
        $keys_salts_str = '';
        $from_api = wp_remote_get('https://api.wordpress.org/secret-key/1.1/salt/');
        if (is_wp_error($from_api)) {
            foreach ($keys_salts as $c => $v) {
                $keys_salts_str .= "\ndefine( '{$c}', '" . wp_generate_password(64, true, true) . "' );";
            }
        } else {
            $from_api = explode("\n", wp_remote_retrieve_body($from_api));
            foreach ($keys_salts as $c => $v) {
                $keys_salts_str .= "\ndefine( '{$c}', '" . substr(array_shift($from_api), 28, 64) . "' );";
            }
        }
        $num_keys_salts = count($keys_salts);
        ?>
	<p><?php 
        echo _n('This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts);
        ?>
 <?php 
        _e('To make your installation more secure, you should also add:');
        ?>
</p>
	<textarea class="code" readonly="readonly" cols="100" rows="<?php 
        echo $num_keys_salts;
        ?>
"><?php 
        echo esc_textarea($keys_salts_str);
        ?>
</textarea>
<?php 
    }
    ?>
</li>
<?php 
    if (iis7_supports_permalinks()) {
        // IIS doesn't support RewriteBase, all your RewriteBase are belong to us
        $iis_subdir_match = ltrim($base, '/') . $subdir_match;
        $iis_rewrite_base = ltrim($base, '/') . $rewrite_base;
        $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
        $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>';
        if (is_multisite() && get_site_option('ms_files_rewriting')) {
            $web_config_file .= '
                <rule name="WordPress Rule for Files" stopProcessing="true">
                    <match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
                    <action type="Rewrite" url="' . $iis_rewrite_base . 'wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
                </rule>';
        }
        $web_config_file .= '
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^' . $iis_subdir_match . 'wp-admin$" ignoreCase="false" />
                    <action type="Redirect" url="' . $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
                </rule>
                <rule name="WordPress Rule 3" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 4" stopProcessing="true">
                    <match url="^' . $iis_subdir_match . '(wp-(content|admin|includes).*)" ignoreCase="false" />
                    <action type="Rewrite" url="' . $iis_rewrite_base . '{R:1}" />
                </rule>
                <rule name="WordPress Rule 5" stopProcessing="true">
                    <match url="^' . $iis_subdir_match . '([_0-9a-zA-Z-]+/)?(.*\\.php)$" ignoreCase="false" />
                    <action type="Rewrite" url="' . $iis_rewrite_base . '{R:2}" />
                </rule>
                <rule name="WordPress Rule 6" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>';
        ?>
		<li><p><?php 
        printf(__('Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:'), $home_path);
        ?>
</p>
		<?php 
        if (!$subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content') {
            echo '<p><strong>' . __('Warning:') . ' ' . __('Subdirectory networks may not be fully compatible with custom wp-content directories.') . '</strong></p>';
        }
        ?>
		<textarea class="code" readonly="readonly" cols="100" rows="20"><?php 
        echo esc_textarea($web_config_file);
        ?>
		</textarea></li>
		</ol>

	<?php 
    } else {
        // end iis7_supports_permalinks(). construct an htaccess file instead:
        $ms_files_rewriting = '';
        if (is_multisite() && get_site_option('ms_files_rewriting')) {
            $ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
            $ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}wp-includes/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
        }
        $htaccess_file = <<<EOF
RewriteEngine On
RewriteBase {$base}
RewriteRule ^index\\.php\$ - [L]
{$ms_files_rewriting}
# add a trailing slash to /wp-admin
RewriteRule ^{$subdir_match}wp-admin\$ {$subdir_replacement_01}wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}{$subdir_replacement_12} [L]
RewriteRule ^{$subdir_match}(.*\\.php)\$ {$rewrite_base}{$subdir_replacement_12} [L]
RewriteRule . index.php [L]
EOF;
        ?>
		<li><p><?php 
        printf(__('Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:'), $home_path);
        ?>
</p>
		<?php 
        if (!$subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content') {
            echo '<p><strong>' . __('Warning:') . ' ' . __('Subdirectory networks may not be fully compatible with custom wp-content directories.') . '</strong></p>';
        }
        ?>
		<textarea class="code" readonly="readonly" cols="100" rows="<?php 
        echo substr_count($htaccess_file, "\n") + 1;
        ?>
">
<?php 
        echo esc_textarea($htaccess_file);
        ?>
</textarea></li>
		</ol>

	<?php 
    }
    // end IIS/Apache code branches.
    if (!is_multisite()) {
        ?>
		<p><?php 
        printf(__('Once you complete these steps, your network is enabled and configured. You will have to log in again.'));
        ?>
 <a href="<?php 
        echo esc_url(site_url('wp-login.php'));
        ?>
"><?php 
        _e('Log In');
        ?>
</a></p>
<?php 
    }
}
Пример #2
0
/**
 * Prints step 2 for Network installation process.
 *
 * @since 3.0.0
 */
function network_step2($errors = false)
{
    global $base, $wpdb;
    $hostname = get_clean_basedomain();
    if (!isset($base)) {
        $base = trailingslashit(stripslashes(dirname(dirname($_SERVER['SCRIPT_NAME']))));
    }
    // Wildcard DNS message.
    if (is_wp_error($errors)) {
        echo '<div class="error">' . $errors->get_error_message() . '</div>';
    }
    if ($_POST) {
        if (allow_subdomain_install()) {
            $subdomain_install = allow_subdirectory_install() ? !empty($_POST['subdomain_install']) : true;
        } else {
            $subdomain_install = false;
        }
    } else {
        if (is_multisite()) {
            $subdomain_install = is_subdomain_install();
            ?>
	<p><?php 
            _e('The original configuration steps are shown here for reference.');
            ?>
</p>
<?php 
        } else {
            $subdomain_install = (bool) $wpdb->get_var("SELECT meta_value FROM {$wpdb->sitemeta} WHERE site_id = 1 AND meta_key = 'subdomain_install'");
            ?>
	<div class="error"><p><strong><?php 
            _e('Warning:');
            ?>
</strong> <?php 
            _e('An existing WordPress network was detected.');
            ?>
</p></div>
	<p><?php 
            _e('Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.');
            ?>
</p>
<?php 
        }
    }
    if ($_POST || !is_multisite()) {
        ?>
		<h3><?php 
        esc_html_e('Enabling the Network');
        ?>
</h3>
		<p><?php 
        _e('Complete the following steps to enable the features for creating a network of sites.');
        ?>
</p>
		<div class="updated inline"><p><?php 
        if (file_exists(ABSPATH . '.htaccess')) {
            printf(__('<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.'), '.htaccess');
        } elseif (file_exists(ABSPATH . 'web.config')) {
            printf(__('<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.'), 'web.config');
        } else {
            _e('<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.');
        }
        ?>
</p></div>
<?php 
    }
    ?>
		<ol>
			<li><p><?php 
    printf(__('Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.'), WP_CONTENT_DIR);
    if (WP_CONTENT_DIR != ABSPATH . 'wp-content') {
        echo ' <strong>' . __('Warning:') . ' ' . __('Networks may not be fully compatible with custom wp-content directories.') . '</strong>';
    }
    ?>
</p></li>
			<li><p><?php 
    printf(__('Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:'), ABSPATH);
    ?>
</p>
				<textarea class="code" readonly="readonly" cols="100" rows="7">
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);</textarea>
<?php 
    $keys_salts = array('AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '');
    foreach ($keys_salts as $c => $v) {
        if (defined($c)) {
            unset($keys_salts[$c]);
        }
    }
    if (!empty($keys_salts)) {
        $keys_salts_str = '';
        $from_api = wp_remote_get('https://api.wordpress.org/secret-key/1.1/salt/');
        if (is_wp_error($from_api)) {
            foreach ($keys_salts as $c => $v) {
                $keys_salts_str .= "\ndefine( '{$c}', '" . wp_generate_password(64, true, true) . "' );";
            }
        } else {
            $from_api = explode("\n", wp_remote_retrieve_body($from_api));
            foreach ($keys_salts as $c => $v) {
                $keys_salts_str .= "\ndefine( '{$c}', '" . substr(array_shift($from_api), 28, 64) . "' );";
            }
        }
        $num_keys_salts = count($keys_salts);
        ?>
	<p><?php 
        echo _n('This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts);
        ?>
 <?php 
        _e('To make your installation more secure, you should also add:');
        ?>
</p>
	<textarea class="code" readonly="readonly" cols="100" rows="<?php 
        echo $num_keys_salts;
        ?>
"><?php 
        echo esc_textarea($keys_salts_str);
        ?>
</textarea>
<?php 
    }
    ?>
</li>
<?php 
    if (iis7_supports_permalinks()) {
        if ($subdomain_install) {
            $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^files/(.+)" ignoreCase="false" />
                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
                </rule>
                <rule name="WordPress Rule 3" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 4" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>';
        } else {
            $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
                </rule>
                <rule name="WordPress Rule 3" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
                </rule>
                <rule name="WordPress Rule 4" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 5" stopProcessing="true">
                    <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
                    <action type="Rewrite" url="{R:1}" />
                </rule>
                <rule name="WordPress Rule 6" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?(.*\\.php)$" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 7" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>';
        }
        ?>
		<li><p><?php 
        printf(__('Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:'), ABSPATH);
        ?>
</p>
		<textarea class="code" readonly="readonly" cols="100" rows="20">
		<?php 
        echo esc_textarea($web_config_file);
        ?>
		</textarea></li>
		</ol>

	<?php 
    } else {
        // end iis7_supports_permalinks(). construct an htaccess file instead:
        $htaccess_file = 'RewriteEngine On
RewriteBase ' . $base . '
RewriteRule ^index\\.php$ - [L]

# uploaded files
RewriteRule ^' . ($subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?') . 'files/(.+) wp-includes/ms-files.php?file=$' . ($subdomain_install ? 1 : 2) . ' [L]' . "\n";
        if (!$subdomain_install) {
            $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
        }
        $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]';
        // @todo custom content dir.
        if (!$subdomain_install) {
            $htaccess_file .= "\nRewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) \$1 [L]\nRewriteRule  ^[_0-9a-zA-Z-]+/(.*\\.php)\$ \$1 [L]";
        }
        $htaccess_file .= "\nRewriteRule . index.php [L]";
        ?>
		<li><p><?php 
        printf(__('Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:'), ABSPATH);
        ?>
</p>
		<textarea class="code" readonly="readonly" cols="100" rows="<?php 
        echo $subdomain_install ? 11 : 16;
        ?>
">
<?php 
        echo esc_textarea($htaccess_file);
        ?>
</textarea></li>
		</ol>

	<?php 
    }
    // end IIS/Apache code branches.
    if (!is_multisite()) {
        ?>
		<p><?php 
        printf(__('Once you complete these steps, your network is enabled and configured. You will have to log in again.'));
        ?>
 <a href="<?php 
        echo esc_url(site_url('wp-login.php'));
        ?>
"><?php 
        _e('Log In');
        ?>
</a></p>
<?php 
    }
}
Пример #3
0
<div class="wrap">
<h1><?php 
echo esc_html($title);
?>
</h1>

<?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();
    }
} elseif (is_multisite() || network_domain_check()) {
    network_step2();
} else {
Пример #4
0
function step3()
{
    global $wpdb, $current_site, $dirs, $wpmu_version;
    $base = stripslashes(dirname($_SERVER["SCRIPT_NAME"]));
    if ($base != "/") {
        $base .= "/";
    }
    $domain = get_clean_basedomain();
    $email = $wpdb->escape($_POST['email']);
    if ($email == '') {
        die('You must enter an email address!');
    }
    // set up site tables
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_name', '" . $wpdb->escape($_POST['weblog_title']) . "')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_email', '" . $email . "')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_user_id', '1')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'registration', 'none')");
    $wpdb->query("INSERT INTO " . $wpdb->site . " ( id, domain, path ) VALUES ( NULL, '{$domain}', '{$base}' )");
    $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("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'upload_filetypes', 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'blog_upload_space', '10' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'fileupload_maxk', '1500' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_admins', '" . serialize(array('admin')) . "' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'allowedthemes', '" . serialize(array('classic' => 1, 'default' => 1)) . "' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'illegal_names', '" . serialize(array("www", "web", "root", "admin", "main", "invite", "administrator")) . "' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'welcome_email', 'Dear User,\n\nYour new SITE_NAME blog has been successfully set up at:\nBLOG_URL\n\nYou can log in to the administrator account with the following information:\nUsername: USERNAME\nPassword: PASSWORD\nLogin Here: BLOG_URLwp-login.php\n\nWe hope you enjoy your new blog.\nThanks!\n\n--The Team @ SITE_NAME')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' )");
    $weblog_title = stripslashes($_POST['weblog_title']);
    $pass = substr(md5(rand()), 5, 12);
    $user_id = wpmu_create_user('admin', $pass, $email);
    $current_site->domain = $domain;
    $current_site->path = $base;
    $current_site->site_name = ucfirst($domain);
    wpmu_create_blog($domain, $base, $weblog_title, $user_id, array('blog_public' => 1, 'public' => 1));
    update_blog_option(1, 'template', 'home');
    update_blog_option(1, 'stylesheet', 'home');
    if (constant('VHOST') == 'yes') {
        update_blog_option(1, 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
    } else {
        update_blog_option(1, 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
    }
    update_blog_option(1, 'rewrite_rules', '');
    $msg = "Your new WordPress MU site has been created at\nhttp://{$domain}{$base}\n\nLogin details:\nUsername: admin\nPassword: {$pass}\nLogin: http://{$domain}{$base}wp-login.php\n";
    wp_mail($email, "Your new WordPress MU site is ready!", $msg, "From: wordpress@" . $_SERVER['HTTP_HOST']);
    ?>
	<h2>Installation Finished!</h2>
	<p>Congratulations! <br />Your <a href='http://<?php 
    echo $domain . $base;
    ?>
'>WordPress &micro; site</a> has been configured.</p>
	<p>You can <a class="button" href='wp-login.php'>log in</a> using the username "admin" and password <?php 
    echo $pass;
    ?>
</p>
	
	<h2>Directory Permissions</h2>
	<p>Please remember to reset the permissions on the following directories:
		<ul>
		<?php 
    reset($dirs);
    foreach ((array) $dirs as $dir) {
        echo "<li>{$dir}</li>";
    }
    ?>
		</ul>
	</p>
	<p>You can probably use the following command to fix the permissions but check with your host if it doubt:
		<br />
		<code>chmod&nbsp;755&nbsp;
			<?php 
    reset($dirs);
    foreach ((array) $dirs as $dir) {
        echo "{$dir}&nbsp;";
    }
    ?>
		</code>
	</p>
	
	<h2>Further reading</h2>
	<p>
		<ul>
			<li>If you run into problems, please search the <a href='http://mu.wordpress.org/forums/'>WordPress &micro; Forums</a> where you will most likely find a solution. Please don't post there before searching. It's not polite.</li>
			<li>There is also the <a href='http://trac.mu.wordpress.org/'>WordPress &micro; Trac</a>. That's our bug tracker.</li>
		</ul>
	</p>
	<p>Thanks for installing WordPress &micro;!<br /><br />Donncha<br /><code>wpmu version: <?php 
    echo $wpmu_version;
    ?>
</code></p>
	<?php 
}
Пример #5
0
/**
 * Prints step 2 for Network installation process.
 *
 * @since 3.0.0
 */
function network_step2($errors = false)
{
    global $base, $wpdb;
    $hostname = get_clean_basedomain();
    // Wildcard DNS message.
    if (is_wp_error($errors)) {
        echo '<div class="error">' . $errors->get_error_message() . '</div>';
    }
    if ($_POST) {
        $vhost = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
    } else {
        if (is_multisite()) {
            $vhost = is_subdomain_install();
            ?>
	<div class="updated"><p><strong><?php 
            _e('Notice: The Network feature is already enabled.');
            ?>
</strong> <?php 
            _e('The original configuration steps are shown here for reference.');
            ?>
</p></div>
<?php 
        } else {
            $vhost = (bool) $wpdb->get_var("SELECT meta_value FROM {$wpdb->sitemeta} WHERE site_id = 1 AND meta_key = 'subdomain_install'");
            ?>
	<div class="error"><p><strong><?php 
            _e('Warning:');
            ?>
</strong> <?php 
            _e('An existing WordPress network was detected.');
            ?>
</p></div>
	<p><?php 
            _e('Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.');
            ?>
</p>
<?php 
        }
    }
    if ($_POST || !is_multisite()) {
        ?>
		<h3><?php 
        esc_html_e('Enabling the Network');
        ?>
</h3>
		<p><?php 
        _e('Complete the following steps to enable the features for creating a network of sites.');
        ?>
</p>
		<div class="updated inline"><p><?php 
        _e('<strong>Caution:</strong> We recommend you backup your existing <code>wp-config.php</code> and <code>.htaccess</code> files.');
        ?>
</p></div>
<?php 
    }
    ?>
		<ol>
			<li><p><?php 
    printf(__('Create a <code>blogs.dir</code> directory in <code>%s</code>. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.'), WP_CONTENT_DIR);
    ?>
</p></li>
			<li><p><?php 
    printf(__('Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:'), ABSPATH);
    ?>
</p>
				<textarea class="code" readonly="readonly" cols="100" rows="7">
define( 'MULTISITE', true );
define( 'VHOST', '<?php 
    echo $vhost ? 'yes' : 'no';
    ?>
' );
$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 );</textarea>
<?php 
    $keys_salts = array('AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '');
    foreach ($keys_salts as $c => $v) {
        if (defined($c)) {
            unset($keys_salts[$c]);
        }
    }
    if (!empty($keys_salts)) {
        $from_api = wp_remote_get('https://api.wordpress.org/secret-key/1.1/salt/');
        if (is_wp_error($from_api)) {
            foreach ($keys_salts as $c => $v) {
                $keys_salts[$c] = wp_generate_password(64, true, true);
            }
        } else {
            $from_api = explode("\n", wp_remote_retrieve_body($from_api));
            foreach ($keys_salts as $c => $v) {
                $keys_salts[$c] = substr(array_shift($from_api), 28, 64);
            }
        }
        $num_keys_salts = count($keys_salts);
        ?>
	<p><?php 
        echo _n('This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts);
        ?>
 <?php 
        _e('To make your installation more secure, you should also add:');
        ?>
</p>
	<textarea class="code" readonly="readonly" cols="100" rows="<?php 
        echo $num_keys_salts;
        ?>
"><?php 
        foreach ($keys_salts as $c => $v) {
            echo "\ndefine( '{$c}', '{$v}' );";
        }
        ?>
</textarea>
<?php 
    }
    ?>
</li>
<?php 
    // Construct an htaccess file.
    $htaccess_file = 'RewriteEngine On
RewriteBase ' . $base . '
RewriteRule ^index\\.php$ - [L]

# uploaded files
RewriteRule ^' . ($vhost ? '' : '([_0-9a-zA-Z-]+/)?') . 'files/(.+) wp-includes/ms-files.php?file=$' . ($vhost ? 1 : 2) . ' [L]' . "\n";
    if (!$vhost) {
        $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
    }
    $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]';
    // @todo custom content dir.
    if (!$vhost) {
        $htaccess_file .= "\n" . 'RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]';
    }
    $htaccess_file .= "\nRewriteRule . index.php [L]";
    ?>
			<li><p><?php 
    printf(__('Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:'), ABSPATH);
    ?>
</p>
				<textarea class="code" readonly="readonly" cols="100" rows="<?php 
    echo $vhost ? 11 : 16;
    ?>
">
<?php 
    echo wp_htmledit_pre($htaccess_file);
    ?>
</textarea></li>
		</ol>
<?php 
    if (!is_multisite()) {
        ?>
		<p><?php 
        printf(__('Once you complete these steps, your network is enabled and configured.'));
        ?>
 <a href="<?php 
        echo esc_url(admin_url());
        ?>
"><?php 
        _e('Return to Dashboard');
        ?>
</a></p>
<?php 
    }
}
Пример #6
0
function step3()
{
    global $wpdb, $current_site, $dirs, $wpmu_version;
    $base = stripslashes(dirname($_SERVER["SCRIPT_NAME"]));
    if ($base != "/") {
        $base .= "/";
    }
    $domain = get_clean_basedomain();
    $email = $wpdb->escape($_POST['email']);
    if ($email == '') {
        die('You must enter an email address!');
    }
    // set up site tables
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_name', '" . $wpdb->escape($_POST['weblog_title']) . "')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_email', '" . $email . "')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_user_id', '1')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'registration', 'none')");
    $wpdb->query("INSERT INTO " . $wpdb->site . " ( id, domain, path ) VALUES ( NULL, '{$domain}', '{$base}' )");
    $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("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'upload_filetypes', 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'blog_upload_space', '10' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'fileupload_maxk', '1500' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_admins', '" . serialize(array('admin')) . "' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'allowedthemes', '" . serialize(array('classic' => 1, 'default' => 1)) . "' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'illegal_names', '" . serialize(array("www", "web", "root", "admin", "main", "invite", "administrator")) . "' )");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'welcome_email', 'Dear User,\n\nYour new SITE_NAME blog has been successfully set up at:\nBLOG_URL\n\nYou can log in to the administrator account with the following information:\nUsername: USERNAME\nPassword: PASSWORD\nLogin Here: BLOG_URLwp-login.php\n\nWe hope you enjoy your new blog.\nThanks!\n\n--The Team @ SITE_NAME')");
    $wpdb->query("INSERT INTO " . $wpdb->sitemeta . " (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' )");
    $weblog_title = stripslashes($_POST['weblog_title']);
    $pass = substr(md5(rand()), 5, 12);
    $user_id = wpmu_create_user('admin', $pass, $email);
    $current_site->domain = $domain;
    $current_site->path = $base;
    $current_site->site_name = ucfirst($domain);
    wpmu_create_blog($domain, $base, $weblog_title, $user_id, array('blog_public' => 1, 'public' => 1));
    update_blog_option(1, 'template', 'home');
    update_blog_option(1, 'stylesheet', 'home');
    if (constant('VHOST') == 'yes') {
        update_blog_option(1, 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
    } else {
        update_blog_option(1, 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
    }
    $msg = "Your new WordPress MU site has been created at\nhttp://{$domain}{$base}\n\nLogin details:\nUsername: admin\nPassword: {$pass}\nLogin: http://{$domain}{$base}wp-login.php\n";
    wp_mail($email, "Your new WordPress MU site is ready!", $msg, "From: wordpress@" . $_SERVER['HTTP_HOST']);
    ?>
	<h2>Installation Finished!</h2>
	<p>Congratulations! <br />Your <a href='http://<?php 
    echo $domain . $base;
    ?>
'>WordPress &micro; site</a> has been configured.</p>
	<p>You can <a class="button" href='wp-login.php'>log in</a> using the username "admin" and password <?php 
    echo $pass;
    ?>
</p>

	<?php 
    if ($_POST['vhost'] == 'yes') {
        $vhost_ok = false;
        $hostname = substr(md5(time()), 0, 6) . '.' . $domain;
        // Very random hostname!
        if (include_once 'wp-includes/http.php') {
            $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;
            }
        } else {
            $fp = fsockopen($hostname, 80, $errno, $errstr, 5);
            // Very random hostname!
            if ($fp) {
                $vhost_ok = true;
                fclose($fp);
            }
        }
        if (!$vhost_ok) {
            echo "<h2>Warning! Wildcard DNS may not be configured correctly!</h2>";
            echo "<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>";
            echo "<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 />\nThis 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>";
            echo "<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>";
        }
    }
    ?>
	
	<h2>Directory Permissions</h2>
	<p>Please remember to reset the permissions on the following directories:
		<ul>
		<?php 
    reset($dirs);
    foreach ((array) $dirs as $dir) {
        echo "<li>{$dir}</li>";
    }
    ?>
		</ul>
	</p>
	<p>You can probably use the following command to fix the permissions but check with your host if it doubt:
		<br />
		<code>chmod&nbsp;755&nbsp;
			<?php 
    reset($dirs);
    foreach ((array) $dirs as $dir) {
        echo "{$dir}&nbsp;";
    }
    ?>
		</code>
	</p>
	
	<h2>Further reading</h2>
	<p>
		<ul>
			<li>If you run into problems, please search the <a href='http://mu.wordpress.org/forums/'>WordPress &micro; Forums</a> where you will most likely find a solution. Please don't post there before searching. It's not polite.</li>
			<li>There is also the <a href='http://trac.mu.wordpress.org/'>WordPress &micro; Trac</a>. That's our bug tracker.</li>
		</ul>
	</p>
	<p>Thanks for installing WordPress &micro;!<br /><br />Donncha<br /><code>wpmu version: <?php 
    echo $wpmu_version;
    ?>
</code></p>
	<?php 
}