Created
March 13, 2013 17:34
-
-
Save withremote/5154366 to your computer and use it in GitHub Desktop.
codeigniter-cache delete_all()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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