Skip to content

Commit

Permalink
Merge pull request opencart#186 from savage4pro/ocshop-2.1.0.1-patch-3
Browse files Browse the repository at this point in the history
oc-2.1.0.1. fix cachemanager module
  • Loading branch information
ocshop committed Dec 10, 2015
2 parents a62afe7 + 5756285 commit fce2092
Showing 1 changed file with 47 additions and 35 deletions.
82 changes: 47 additions & 35 deletions upload/admin/controller/module/cachemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,58 +80,70 @@ public function index() {

public function clearsystemcache() {
$this->load->language('module/cachemanager');

$files = glob(DIR_CACHE . 'cache.*');
foreach($files as $file){
$this->deldir($file);
if (!empty($files)) {
foreach($files as $file){
$this->deldir($file);
}
}

$this->session->data['success'] = $this->language->get('text_success_system');

$this->response->redirect($this->url->link('module/cachemanager', 'token=' . $this->session->data['token'], 'SSL'));
}
}

public function clearcache() {
$this->load->language('module/cachemanager');
$imgfiles = glob(DIR_IMAGE . 'cache/*');
foreach($imgfiles as $imgfile){
$this->deldir($imgfile);

$imgfiles = glob(DIR_IMAGE . 'cache/*');
if (!empty($imgfiles)) {
foreach($imgfiles as $imgfile){
$this->deldir($imgfile);
}
}

$this->session->data['success'] = $this->language->get('text_success_img');
$this->response->redirect($this->url->link('module/cachemanager', 'token=' . $this->session->data['token'], 'SSL'));
}

$this->response->redirect($this->url->link('module/cachemanager', 'token=' . $this->session->data['token'], 'SSL'));
}

public function clearallcache() {
$this->load->language('module/cachemanager');
$imgfiles = glob(DIR_IMAGE . 'cache/*');
foreach($imgfiles as $imgfile){
$this->deldir($imgfile);

$imgfiles = glob(DIR_IMAGE . 'cache/*');
if (!empty($imgfiles)) {
foreach($imgfiles as $imgfile){
$this->deldir($imgfile);
}
}
$files = glob(DIR_CACHE . 'cache.*');
if (!empty($files)) {
foreach($files as $file){
$this->deldir($file);

$this->deldir($file);
}
}

$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('module/cachemanager', 'token=' . $this->session->data['token'], 'SSL'));
}
public function deldir($dirname){

$this->response->redirect($this->url->link('module/cachemanager', 'token=' . $this->session->data['token'], 'SSL'));
}

public function deldir($dirname){
if(file_exists($dirname)) {
if(is_dir($dirname)){
$dir=opendir($dirname);
while($filename=readdir($dir)){
if($filename!="." && $filename!=".."){
$file=$dirname."/".$filename;
$this->deldir($file);
}
}
closedir($dir);
rmdir($dirname);
}
else {@unlink($dirname);}
$dir=opendir($dirname);
while($filename=readdir($dir)){
if($filename!="." && $filename!=".."){
$file=$dirname."/".$filename;
$this->deldir($file);
}
}
closedir($dir);
rmdir($dirname);
} else {
@unlink($dirname);
}
}
}
}

0 comments on commit fce2092

Please sign in to comment.