Advertisement
bin2011

modified sunrise.php

Jun 2nd, 2012
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <?php
  2. if ( !defined( 'SUNRISE_LOADED' ) )
  3.     define( 'SUNRISE_LOADED', 1 );
  4.  
  5. if ( defined( 'COOKIE_DOMAIN' ) ) {
  6.     die( 'The constant "COOKIE_DOMAIN" is defined (probably in wp-config.php). Please remove or comment out that define() line.' );
  7. }
  8.  
  9. // let the site admin page catch the VHOST == 'no'
  10. $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
  11. $dm_domain = $wpdb->escape( $_SERVER[ 'HTTP_HOST' ] );
  12.  
  13. if( ( $nowww = preg_replace( '|^www\.|', '', $dm_domain ) ) != $dm_domain )
  14.     $where = $wpdb->prepare( 'domain IN (%s,%s)', $dm_domain, $nowww );
  15. else
  16.     $where = $wpdb->prepare( 'domain = %s', $dm_domain );
  17.  
  18. $wpdb->suppress_errors();
  19. $domain_mapping_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->dmtable} WHERE {$where} ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1" );
  20. $wpdb->suppress_errors( false );
  21. if( $domain_mapping_id ) {
  22.     $current_blog = $wpdb->get_row("SELECT * FROM {$wpdb->blogs} WHERE blog_id = '$domain_mapping_id' LIMIT 1");
  23.     $current_blog->domain = $_SERVER[ 'HTTP_HOST' ];
  24.     $current_blog->path = '/';
  25.     $blog_id = $domain_mapping_id;
  26.     $site_id = $current_blog->site_id;
  27.  
  28.     define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );
  29.  
  30.     $current_site = $wpdb->get_row( "SELECT * from {$wpdb->site} WHERE id = '{$current_blog->site_id}' LIMIT 0,1" );
  31.     $current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
  32.     if( function_exists( 'get_current_site_name' ) )
  33.         $current_site = get_current_site_name( $current_site );
  34.  
  35.     define( 'DOMAIN_MAPPING', 1 );
  36. } elseif ( isset($cookie_domain) )
  37.     define( 'COOKIE_DOMAIN', $cookie_domain );
  38.  
  39. # Modified according these instructions:
  40. # http://tech.velmont.net/howto-use-subdomain-wordpress-multisite-3-x-3-0-and-3-1-without-dashboard-site/
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement