You are here

function boost_chk_htaccess_doc in Boost 6

Check htaccess file for given rules.

1 call to boost_chk_htaccess_doc()
boost_requirements in ./boost.install
Implementation of hook_requirements().

File

./boost.install, line 347
Handles Boost module installation and upgrade tasks.

Code

function boost_chk_htaccess_doc($htaccess) {
  $char = BOOST_CHAR;
  if (BOOST_CACHE_HTML || BOOST_CACHE_XML || BOOST_CACHE_JSON) {
    $rules = (int) BOOST_CACHE_HTML + (int) BOOST_CACHE_XML + (int) BOOST_CACHE_JSON;
    $rules = BOOST_GZIP ? $rules * 4 + 1 : $rules * 2 + 1;
    if (count(explode("%{REQUEST_URI}{$char}%{QUERY_STRING}\\.", $htaccess)) < $rules) {
      return FALSE;
    }
  }
  if (BOOST_CACHE_CSS || BOOST_CACHE_JS) {
    $rules = BOOST_CACHE_CSS && BOOST_CACHE_JS ? 2 : 1;
    $rules = BOOST_GZIP ? $rules * 4 + 1 : $rules * 2 + 1;
    if (count(explode("%{REQUEST_URI}{$char}\\.", $htaccess)) < $rules) {
      return FALSE;
    }
  }
  if (BOOST_GZIP && BOOST_AGGRESSIVE_GZIP) {
    if (!strstr($htaccess, "RewriteRule ^(.*)boost-gzip-cookie-test\\.")) {
      return FALSE;
    }
    $rules = 1;
    $rules = BOOST_CACHE_CSS || BOOST_CACHE_JS ? $rules + 1 : $rules;
    $rules = BOOST_CACHE_HTML || BOOST_CACHE_XML || BOOST_CACHE_JSON ? $rules + 1 : $rules;
    if (count(explode("RewriteCond %{HTTP_COOKIE} !(boost-gzip)", $htaccess)) < $rules) {
      return FALSE;
    }
  }
  if (!(BOOST_CACHE_HTML || BOOST_CACHE_XML || BOOST_CACHE_CSS || BOOST_CACHE_JS || BOOST_CACHE_JSON)) {
    return FALSE;
  }
  return TRUE;
}