/** * Clear full page cache (/cache directory) */ function dbm_delete_pagecache() { global $DB, $Messages, $cache_path; // Clear general cache directory if (cleardir_r($cache_path . 'general')) { $Messages->add(sprintf(T_('General cache deleted: %s'), $cache_path . 'general'), 'note'); } else { $Messages->add(sprintf(T_('Could not delete general cache: %s'), $cache_path . 'general'), 'error'); } $SQL = 'SELECT blog_ID FROM T_blogs INNER JOIN T_coll_settings ON ( blog_ID = cset_coll_ID AND cset_name = "cache_enabled" AND cset_value = "1" ) WHERE 1=1'; if ($blog_array = $DB->get_col($SQL)) { foreach ($blog_array as $l_blog) { // Clear blog cache if (cleardir_r($cache_path . 'c' . $l_blog)) { $Messages->add(sprintf(T_('Blog %d cache deleted: %s'), $l_blog, $cache_path . 'c' . $l_blog), 'note'); } else { $Messages->add(sprintf(T_('Could not delete blog %d cache: %s'), $l_blog, $cache_path . 'c' . $l_blog), 'error'); } // Create .htaccess file with deny rules create_htaccess_deny($cache_path); } } $Messages->add(T_('Page cache deleted.'), 'success'); }
/** * @return boolean true if cache has been successfully created */ function cache_create($clear = true) { global $cache_path; // Create by using the filemanager's default chmod. TODO> we may not want to make these publicly readable if (!mkdir_r($this->ads_collcache_path, NULL)) { return false; } if ($clear) { // Clear contents of folder, if any: cleardir_r($this->ads_collcache_path); } // Create htaccess file with deny rules if (!create_htaccess_deny($cache_path)) { return false; } return true; }
/** * Deletes a dir recursively, wiping out all subdirectories!! * * @param string The dir * @return boolean False on failure */ function rmdir_r($path) { $path = trailing_slash($path); $r = true; if (!cleardir_r($path)) { $r = false; } if (!@rmdir($path)) { $r = false; } return $r; }