Skip to content

Commit

Permalink
Adding support for PATH_CURRENT_SITE and $GLOBALS['base'].
Browse files Browse the repository at this point in the history
  • Loading branch information
JasWSInc committed Dec 8, 2013
1 parent 402fd1a commit 9bfe5ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions quick-cache/includes/advanced-cache.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@ public function maybe_start_output_buffering()
$host_dir_token = '/'; // Assume NOT multisite; or running it's own domain.

if(is_multisite() && (!defined('SUBDOMAIN_INSTALL') || !SUBDOMAIN_INSTALL))
{ // Multisite w/ sub-directories; need sub-directory. We MUST validate against blog paths too.
{ // Multisite w/ sub-directories; need a valid sub-directory token.

list($host_dir_token) = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
$base = '/'; // Initial default value.
if(defined('PATH_CURRENT_SITE')) $base = PATH_CURRENT_SITE;
else if(!empty($GLOBALS['base'])) $base = $GLOBALS['base'];

$uri_minus_base = // Supports `/sub-dir/child-blog-sub-dir/` also.
preg_replace('/^'.preg_quote($base, '/').'/', '', $_SERVER['REQUEST_URI']);

list($host_dir_token) = explode('/', trim($uri_minus_base, '/'));
$host_dir_token = (isset($host_dir_token[0])) ? '/'.$host_dir_token.'/' : '/';

if($host_dir_token !== '/' // Perhaps NOT the main site?
Expand Down
11 changes: 9 additions & 2 deletions quick-cache/quick-cache.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,16 @@ public function clear_cache($manually = FALSE)
$host_dir_token = '/'; // Assume NOT multisite; or running it's own domain.

if($is_multisite && (!defined('SUBDOMAIN_INSTALL') || !SUBDOMAIN_INSTALL))
{ // Multisite w/ sub-directories; need sub-directory. We MUST validate against blog paths too.
{ // Multisite w/ sub-directories; need a valid sub-directory token.

list($host_dir_token) = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
$base = '/'; // Initial default value.
if(defined('PATH_CURRENT_SITE')) $base = PATH_CURRENT_SITE;
else if(!empty($GLOBALS['base'])) $base = $GLOBALS['base'];

$uri_minus_base = // Supports `/sub-dir/child-blog-sub-dir/` also.
preg_replace('/^'.preg_quote($base, '/').'/', '', $_SERVER['REQUEST_URI']);

list($host_dir_token) = explode('/', trim($uri_minus_base, '/'));
$host_dir_token = (isset($host_dir_token[0])) ? '/'.$host_dir_token.'/' : '/';

if($host_dir_token !== '/' // Perhaps NOT the main site?
Expand Down

0 comments on commit 9bfe5ca

Please sign in to comment.