Skip to content

Instantly share code, notes, and snippets.

@withremote withremote/Cache.php
Created Mar 13, 2013

Embed
What would you like to do?
codeigniter-cache delete_all()
/**
* Delete Full Cache or Cache subdir
* Skips .htaccess and index.htm(l) files for security
*
* @access public
* @param string
* @return void
*/
function delete_all($dirname = '')
{
if (empty($this->_path))
{
return FALSE;
}
$this->_ci->load->helper('file');
if (file_exists($this->_path.$dirname)) {
$files = scandir($this->_path.$dirname);
foreach($files as $f) {
if($f != '.' && $f != '..' && $f != '.htaccess' && strpos($f, 'index.htm') === false) {
$p = str_replace('\\','/', rtrim($this->_path.$dirname,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$f);
if(is_dir($p)) {
delete_files($p, TRUE);
rmdir($p);
} else {
unlink($p);
}
}
}
}
// Reset values
$this->_reset();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.