Make WordPress Core


Ignore:
Timestamp:
01/19/2010 05:01:39 PM (15 years ago)
Author:
ryan
Message:

Formatting cleanups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-settings.php

    r12674 r12760  
    1515}
    1616
    17 if( isset( $current_site ) && isset( $current_blog ) )
     17if ( isset( $current_site ) && isset( $current_blog ) )
    1818    return;
    1919
     
    2222
    2323$domain = addslashes( $_SERVER['HTTP_HOST'] );
    24 if( substr( $domain, 0, 4 ) == 'www.' )
     24if ( substr( $domain, 0, 4 ) == 'www.' )
    2525    $domain = substr( $domain, 4 );
    26 if( strpos( $domain, ':' ) ) {
    27     if( substr( $domain, -3 ) == ':80' ) {
     26if ( strpos( $domain, ':' ) ) {
     27    if ( substr( $domain, -3 ) == ':80' ) {
    2828        $domain = substr( $domain, 0, -3 );
    2929        $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
    30     } elseif( substr( $domain, -4 ) == ':443' ) {
     30    } elseif ( substr( $domain, -4 ) == ':443' ) {
    3131        $domain = substr( $domain, 0, -4 );
    3232        $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
     
    3636}
    3737$domain = preg_replace('/:.*$/', '', $domain); // Strip ports
    38 if( substr( $domain, -1 ) == '.' )
     38if ( substr( $domain, -1 ) == '.' )
    3939    $domain = substr( $domain, 0, -1 );
    4040
     
    4848    if ( !$current_site->site_name ) {
    4949        $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) );
    50         if( $current_site->site_name == null )
     50        if ( $current_site->site_name == null )
    5151            $current_site->site_name = ucfirst( $current_site->domain );
    5252        wp_cache_set( $current_site->id . ':current_site_name', $current_site->site_name, 'site-options');
     
    5757function wpmu_current_site() {
    5858    global $wpdb, $current_site, $domain, $path, $sites;
    59     if( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
     59    if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
    6060        $current_site->id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
    6161        $current_site->domain = DOMAIN_CURRENT_SITE;
    6262        $current_site->path   = $path = PATH_CURRENT_SITE;
    63         if( defined( 'BLOGID_CURRENT_SITE' ) )
     63        if ( defined( 'BLOGID_CURRENT_SITE' ) )
    6464            $current_site->blog_id = BLOGID_CURRENT_SITE;
    6565        return $current_site;
     
    6767
    6868    $current_site = wp_cache_get( "current_site", "site-options" );
    69     if( $current_site )
     69    if ( $current_site )
    7070        return $current_site;
    7171
    7272    $wpdb->suppress_errors();
    7373    $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site
    74     if( count( $sites ) == 1 ) {
     74    if ( count( $sites ) == 1 ) {
    7575        $current_site = $sites[0];
    7676        $path = $current_site->path;
     
    8181    }
    8282    $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) );
    83     if( is_subdomain_install() ) {
     83    if ( is_subdomain_install() ) {
    8484        $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path) );
    85         if( $current_site != null )
     85        if ( $current_site != null )
    8686            return $current_site;
    8787        $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain) );
    88         if( $current_site != null ) {
     88        if ( $current_site != null ) {
    8989            $path = '/';
    9090            return $current_site;
     
    9393        $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
    9494        $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) );
    95         if( $current_site != null )
     95        if ( $current_site != null )
    9696            return $current_site;
    9797        $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $sitedomain) );
    98         if( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
    99             if( count( $sites ) == 1 ) {
     98        if ( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
     99            if ( count( $sites ) == 1 ) {
    100100                $current_site = $sites[0];
    101101                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>" );
     
    108108    } else {
    109109        $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path) );
    110         if( $current_site != null )
     110        if ( $current_site != null )
    111111            return $current_site;
    112112        $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain) );
    113         if( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
    114             if( count( $sites ) == 1 ) {
     113        if ( $current_site == null && defined( "WP_INSTALLING" ) == false ) {
     114            if ( count( $sites ) == 1 ) {
    115115                $current_site = $sites[0];
    116116                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>" );
     
    126126
    127127$current_site = wpmu_current_site();
    128 if( !isset( $current_site->blog_id ) )
     128if ( !isset( $current_site->blog_id ) )
    129129    $current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
    130130
    131 if( is_subdomain_install() ) {
     131if ( is_subdomain_install() ) {
    132132    $current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' );
    133     if( !$current_blog ) {
     133    if ( !$current_blog ) {
    134134        $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain) );
    135         if( $current_blog )
     135        if ( $current_blog )
    136136            wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' );
    137137    }
    138     if( $current_blog != null && $current_blog->site_id != $current_site->id ) {
     138    if ( $current_blog != null && $current_blog->site_id != $current_site->id )
    139139        $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE id = %d", $current_blog->site_id) );
    140     } else {
     140    else
    141141        $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
    142     }
    143142} else {
    144143    $blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) );
    145     if( strpos( $blogname, '/' ) )
     144    if ( strpos( $blogname, '/' ) )
    146145        $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) );
    147     if( strpos( " ".$blogname, '?' ) )
     146    if ( strpos( " ".$blogname, '?' ) )
    148147        $blogname = substr( $blogname, 0, strpos( $blogname, '?' ) );
    149148    $reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' );
    150     if ( $blogname != '' && !in_array( $blogname, $reserved_blognames ) && !is_file( $blogname ) ) {
     149    if ( $blogname != '' && !in_array( $blogname, $reserved_blognames ) && !is_file( $blogname ) )
    151150        $path = $path . $blogname . '/';
    152     }
    153151    $current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' );
    154     if( !$current_blog ) {
     152    if ( !$current_blog ) {
    155153        $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domain, $path) );
    156         if( $current_blog )
     154        if ( $current_blog )
    157155            wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' );
    158156    }
    159157}
    160158
    161 if( defined( "WP_INSTALLING" ) == false && is_subdomain_install() && !is_object( $current_blog ) ) {
    162     if( defined( 'NOBLOGREDIRECT' ) ) {
     159if ( defined( "WP_INSTALLING" ) == false && is_subdomain_install() && !is_object( $current_blog ) ) {
     160    if ( defined( 'NOBLOGREDIRECT' ) ) {
    163161        $destination = constant( 'NOBLOGREDIRECT' );
    164162        if ( $destination == '%siteurl%' )
     
    173171}
    174172
    175 if( defined( "WP_INSTALLING" ) == false ) {
    176     if( $current_site && $current_blog == null ) {
    177         if( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) {
     173if ( defined( "WP_INSTALLING" ) == false ) {
     174    if ( $current_site && $current_blog == null ) {
     175        if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) {
    178176            header( "Location: http://" . $current_site->domain . $current_site->path );
    179177            exit;
     
    181179        $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path) );
    182180    }
    183     if( $current_blog == false || $current_site == false )
     181    if ( $current_blog == false || $current_site == false )
    184182        is_installed();
    185183}
     
    188186$public  = $current_blog->public;
    189187
    190 if( $current_blog->site_id == 0 || $current_blog->site_id == '' )
     188if ( $current_blog->site_id == 0 || $current_blog->site_id == '' )
    191189    $current_blog->site_id = 1;
    192190$site_id = $current_blog->site_id;
     
    194192$current_site = get_current_site_name( $current_site );
    195193
    196 if( $blog_id == false ) {
     194if ( $blog_id == false ) {
    197195    // no blog found, are we installing? Check if the table exists.
    198196    if ( defined('WP_INSTALLING') ) {
    199     $blog_id = $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs LIMIT 0,1" );
    200     if( $blog_id == false ) {
    201         // table doesn't exist. This is the first blog
    202         $blog_id = 1;
    203     } else {
    204         // table exists
    205         // don't create record at this stage. we're obviously installing so it doesn't matter what the table vars below are like.
    206         // default to using the "main" blog.
    207         $blog_id = 1;
    208     }
    209     $current_blog->blog_id = $blog_id;
     197        $blog_id = $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs LIMIT 0,1" );
     198        if ( $blog_id == false ) {
     199            // table doesn't exist. This is the first blog
     200            $blog_id = 1;
     201        } else {
     202            // table exists
     203            // don't create record at this stage. we're obviously installing so it doesn't matter what the table vars below are like.
     204            // default to using the "main" blog.
     205            $blog_id = 1;
     206        }
     207        $current_blog->blog_id = $blog_id;
    210208    } else {
    211     $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
    212     if( $check == false ) {
    213         $msg = ': DB Tables Missing';
    214     } else {
    215         $msg = '';
    216     }
    217     die( "No Blog by that name on this system." . $msg );
     209        $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
     210        if ( $check == false )
     211            $msg = ': DB Tables Missing';
     212        else
     213            $msg = '';
     214        die( "No Blog by that name on this system." . $msg );
    218215    }
    219216}
     
    221218$wpdb->suppress_errors( false );
    222219
    223 if( '0' == $current_blog->public ) {
     220if ( '0' == $current_blog->public ) {
    224221    // This just means the blog shouldn't show up in google, etc. Only to registered members
    225222}
     
    228225    global $wpdb, $domain, $path;
    229226    $base = stripslashes( $base );
    230     if( defined( "WP_INSTALLING" ) == false ) {
     227    if ( defined( "WP_INSTALLING" ) == false ) {
    231228        $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
    232229        $msg = "If your blog does not display, please contact the owner of this site.<br /><br />If you are the owner of this site please check that MySQL is running properly and all tables are error free.<br /><br />";
    233         if( $check == false ) {
     230        if ( $check == false ) {
    234231            $msg .= "<strong>Database Tables Missing.</strong><br />Database tables are missing. This means that MySQL is either not running, WPMU was not installed properly, or someone deleted {$wpdb->site}. You really <em>should</em> look at your database now.<br />";
    235232        } else {
     
    248245            </ul>";
    249246        $msg .= "If you suspect a problem please report it to the support forums but you must include the information asked for in the <a href='http://codex.wordpress.org/Debugging_WPMU'>WPMU bug reporting guidelines</a>!<br /><br />";
    250         if( is_file( 'release-info.txt' ) ) {
     247        if ( is_file( 'release-info.txt' ) ) {
    251248            $msg .= 'Your bug report must include the following text: "';
    252249            $info = file( 'release-info.txt' );
Note: See TracChangeset for help on using the changeset viewer.