block subdomain install when install is in a folder, see #12736

git-svn-id: http://svn.automattic.com/wordpress/trunk@13926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-04-02 02:04:25 +00:00
parent 1f7d47157d
commit 8fc4bccb83
1 changed files with 21 additions and 3 deletions

View File

@ -36,6 +36,19 @@ function network_domain_check() {
return false;
}
/**
* Allow subdomain install
*
* @since 3.0.0
* @return bool - whether subdomain install is allowed
*/
function allow_subdomain_install() {
$path = preg_replace( '|https?://[^/]|', '', get_option( 'siteurl' ) );
if( strlen( $path ) > 1 || 'localhost' == $_SERVER[ 'HTTP_HOST' ] )
return false;
return true;
}
/**
* Get base domain of network.
*
@ -134,7 +147,7 @@ function network_step1( $errors = false ) {
echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled, ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p></div>';
}
if ( 'localhost' != $hostname ) : ?>
if ( allow_subdomain_install() ) : ?>
<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
<p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p>
@ -175,6 +188,11 @@ function network_step1( $errors = false ) {
<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
<td><?php _e('Because you are using <code>localhost</code>, the sites in your WordPress network must use sub-directories. Consider using <code>localhost.localdomain</code> if you wish to use sub-domains.'); ?></td>
</tr>
<?php elseif ( !allow_subdomain_install() ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
<td><?php _e('Because your install is in a directory, the sites in your WordPress network must use sub-directories.'); ?></td>
</tr>
<?php endif; ?>
<?php if ( ! $is_www ) : ?>
<tr>
@ -217,7 +235,7 @@ function network_step2( $errors = false ) {
echo '<div class="error">' . $errors->get_error_message() . '</div>';
if ( $_POST ) {
$vhost = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
$vhost = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
} else {
if ( is_multisite() ) {
$vhost = is_subdomain_install();
@ -326,7 +344,7 @@ if ( $_POST ) {
// create network tables
install_network();
$hostname = get_clean_basedomain();
$subdomain_install = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
$subdomain_install = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
if ( ! network_domain_check() ) {
$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['sitename'], $base, $subdomain_install );
if ( is_wp_error( $result ) ) {