summaryrefslogtreecommitdiffstats
path: root/wpmu-settings.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-03-12 14:40:14 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-03-12 14:40:14 +0000
commit08e516d87f90728070af0a6e9182e8457e8d1543 (patch)
treefbec8a8c463d15c7416b67c41be95251b038765a /wpmu-settings.php
parent29337e6efb527bbaa17acdf525b6d4df0c7a8581 (diff)
downloadwordpress-mu-08e516d87f90728070af0a6e9182e8457e8d1543.tar.gz
wordpress-mu-08e516d87f90728070af0a6e9182e8457e8d1543.tar.xz
wordpress-mu-08e516d87f90728070af0a6e9182e8457e8d1543.zip
Don't auto-redirect to non-www hostname
Strip "www." from all urls Added "no www" page to install Can now install from url starting with "www." git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@912 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wpmu-settings.php')
-rw-r--r--wpmu-settings.php79
1 files changed, 42 insertions, 37 deletions
diff --git a/wpmu-settings.php b/wpmu-settings.php
index 6be2891..06ba9dd 100644
--- a/wpmu-settings.php
+++ b/wpmu-settings.php
@@ -23,54 +23,59 @@ $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] );
$path = str_replace ( '/wp-admin/', '/', $path );
$path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path );
-$wpdb->hide_errors();
-$sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site
-if( count( $sites ) == 1 ) {
- $current_site = $sites[0];
- $path = $current_site->path;
-}
-
-if( isset( $current_site ) == false ) {
+function wpmu_current_site() {
+ global $wpdb, $current_site, $domain, $path, $sites;
$path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) );
if( constant( 'VHOST' ) == 'yes' ) {
$current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" );
- if( $current_site == null ) {
- $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" );
- if( $current_site == null ) {
- $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
- $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" );
- if( $current_site == null ) {
- $path = '/';
- $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" );
- if( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
- if( count( $sites ) == 1 ) {
- $current_site = $sites[0];
- die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" );
- } else {
- die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." );
- }
- }
- }
+ if( $current_site != null )
+ return $current_site;
+ $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" );
+ if( $current_site != null ) {
+ $path = '/';
+ return $current_site;
+ }
+ $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
+ $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" );
+ if( $current_site != null )
+ return $current_site;
+ $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='/'" );
+ if( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
+ if( count( $sites ) == 1 ) {
+ $current_site = $sites[0];
+ die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" );
} else {
- $path = '/';
+ die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." );
}
+ } else {
+ $path = '/';
}
} else {
$current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" );
- if( $current_site == null ) {
- $path = '/';
- $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" );
- if( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
- $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
- if( count( $sites ) == 1 ) {
- $current_site = $sites[0];
- die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" );
- } else {
- die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." );
- }
+ if( $current_site != null )
+ return $current_site;
+ $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" );
+ if( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
+ if( count( $sites ) == 1 ) {
+ $current_site = $sites[0];
+ die( "That blog does not exist. Please try <a href='http://{$current_site->domain}{$current_site->path}'>http://{$current_site->domain}{$current_site->path}</a>" );
+ } else {
+ die( "No WPMU site defined on this host. If you are the owner of this site, please check <a href='http://trac.mu.wordpress.org/wiki/DebuggingWpmu'>Debugging WPMU</a> for further assistance." );
}
+ } else {
+ $path = '/';
}
}
+ return $current_site;
+}
+
+$wpdb->hide_errors();
+$sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site
+if( count( $sites ) == 1 ) {
+ $current_site = $sites[0];
+ $path = $current_site->path;
+} else {
+ $current_site = wpmu_current_site();
}