diff --git a/wp-cache-base.php b/wp-cache-base.php index 812601e3..df65196c 100644 --- a/wp-cache-base.php +++ b/wp-cache-base.php @@ -1,8 +1,9 @@ domain : trim( $current_blog->path, '/' ); + } elseif ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST === 'yes' ) ) { $blogcacheid = $WPSC_HTTP_HOST; } else { - if ( isset( $base ) == false ) { - $base = ''; - } $request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) ); - if ( strlen( $request_uri ) > 0 && strpos( $request_uri, '/', 1 ) ) { - if ( $base == '/' ) { - $blogcacheid = substr( $request_uri, 1, strpos( $request_uri, '/', 1 ) - 1 ); - } else { - $blogcacheid = str_replace( $base, '', $request_uri ); - if ( $blogcacheid != '' ) { - $blogcacheid = substr( $blogcacheid, 0, strpos( $blogcacheid, '/', 1 ) ); - } - } - if ( '/' == substr( $blogcacheid, -1 ) ) { - $blogcacheid = substr( $blogcacheid, 0, -1 ); - } + $request_uri = str_replace( '//', '/', $request_uri ); + + $wpsc_path_segs = array_filter( explode( '/', trim( $request_uri, '/' ) ) ); + $wpsc_base_count = defined( 'PATH_CURRENT_SITE' ) ? count( array_filter( explode( '/', trim( PATH_CURRENT_SITE, '/' ) ) ) ) : 0; + if ( '/' !== substr( $request_uri, -1 ) ) { + $wpsc_path_segs = array_slice( $wpsc_path_segs, 0, -1 ); } - $blogcacheid = str_replace( '/', '', $blogcacheid ); + + if ( count( $wpsc_path_segs ) > $wpsc_base_count && + ( ! defined( 'PATH_CURRENT_SITE' ) || 0 === strpos( $request_uri, PATH_CURRENT_SITE ) ) + ) { + $blogcacheid = $wpsc_path_segs[ $wpsc_base_count ]; + } + } + + // If blogcacheid is empty then set it to main blog. + if ( empty( $blogcacheid ) ) { + $blogcacheid = 'blog'; } + $blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' ); } diff --git a/wp-cache-phase2.php b/wp-cache-phase2.php index 41fb0c66..efc73e93 100644 --- a/wp-cache-phase2.php +++ b/wp-cache-phase2.php @@ -825,7 +825,7 @@ function get_oc_key( $url = false ) { global $wp_cache_gzip_encoding, $WPSC_HTTP_HOST; if ( $url ) { - $key = intval( $_SERVER[ 'SERVER_PORT' ] ) . strtolower( preg_replace( '/:.*$/', '', $WPSC_HTTP_HOST ) ) . $url; + $key = intval( $_SERVER[ 'SERVER_PORT' ] ) . preg_replace( '/:.*$/', '', $WPSC_HTTP_HOST ) . $url; } else { $key = get_current_url_supercache_dir(); }