Skip to content

Commit

Permalink
Cache manager fix
Browse files Browse the repository at this point in the history
Исключены появления notice, возникающие при изменении параметров кеша.
Исправлен warning, при попытке удаления пустого каталога.
  • Loading branch information
ocshop committed Sep 5, 2014
1 parent 4fb6607 commit ef83d7b
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions upload/admin/controller/tool/cachemanager.php
Expand Up @@ -23,6 +23,8 @@ public function index() {
$this->model_setting_setting->editSetting('cachemanager', $this->request->post);

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

$this->clearsystemcache();

$this->redirect($this->url->link('tool/cachemanager', 'token=' . $this->session->data['token'], 'SSL'));
}
Expand Down Expand Up @@ -218,11 +220,15 @@ public function clear() {
$this->load->language('tool/cachemanager');

$pattern = $this->request->get['pattern'];

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


if ($files) {
foreach($files as $file){
@unlink($file);
}
}

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

Expand All @@ -231,12 +237,17 @@ public function clear() {


public function clearsystemcache() {

$this->load->language('tool/cachemanager');

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


if ($files) {
foreach($files as $file){
$this->deldir($file);
};
}

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

$this->redirect(HTTPS_SERVER . 'index.php?route=tool/cachemanager&token=' . $this->session->data['token']);
Expand All @@ -250,13 +261,13 @@ public function clearvqmodcache($return = false) {
if ($files) {
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
@unlink($file);
}
}
}

if (is_file($this->vqmod_modcache)) {
unlink($this->vqmod_modcache);
@unlink($this->vqmod_modcache);
}

if ($return) {
Expand All @@ -270,8 +281,10 @@ public function clearvqmodcache($return = false) {
}

public function clearcache() {

$this->load->language('tool/cachemanager');
$imgfiles = glob(DIR_IMAGE . 'cache/*');

$imgfiles = glob(DIR_IMAGE . 'cache/*');
foreach($imgfiles as $imgfile){
$this->deldir($imgfile);
}
Expand All @@ -280,10 +293,14 @@ public function clearcache() {
$this->redirect(HTTPS_SERVER . 'index.php?route=tool/cachemanager&token=' . $this->session->data['token']);
}

public function deldir($dirname){
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;
Expand All @@ -299,6 +316,7 @@ public function deldir($dirname){


protected function validate() {

if (!$this->user->hasPermission('modify', 'tool/cachemanager')) {
$this->error['warning'] = $this->language->get('error_permission');
}
Expand Down

0 comments on commit ef83d7b

Please sign in to comment.