You are here

function boost_htaccess_cache_dir_put in Boost 6

Same name and namespace in other branches
  1. 7 boost.module \boost_htaccess_cache_dir_put()
4 calls to boost_htaccess_cache_dir_put()
boost_admin_boost_performance_page_submit in ./boost.admin.inc
submit boost_admin_boost_performance_page form submissions.
boost_cache_delete in ./boost.module
Deletes files in the cache.
boost_requirements in ./boost.install
Implementation of hook_requirements().
boost_update_htaccess in ./boost.admin.inc
Helper function to update htaccess Inserts or removes the autogenerated boost rules

File

./boost.module, line 2986
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_htaccess_cache_dir_put() {

  // Server is not apache; do nothing
  if (stristr($_SERVER["SERVER_SOFTWARE"], 'apache') == FALSE) {
    return TRUE;
  }

  // Get some info
  $cache_dir = BOOST_ROOT_CACHE_DIR;
  $filename = $cache_dir . '/.htaccess';
  $generated = boost_htaccess_cache_dir_generate();
  $htaccess = file_exists($filename) ? file_get_contents($filename) : FALSE;

  // htaccess exists and has the correct contents
  if ($htaccess && strcmp($htaccess, $generated) === 0) {
    return TRUE;
  }

  // cache dir doesn't exist, try to create it; if no go, bail out.
  if (!is_dir($cache_dir) && !_boost_mkdir_p($cache_dir)) {
    return FALSE;
  }

  // cache dir htaccess is not there, create it.
  $result = file_put_contents($filename, $generated);
  if ($result) {
    return $result;
  }
  else {
    return FALSE;
  }
}