2020-08-21 08:03:22 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implementation of ClearCache controller
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @license GPL 2
|
|
|
|
* @version @version@
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class which does the busines logic for clearing the cache
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
class SeedDMS_Controller_ClearCache extends SeedDMS_Controller_Common {
|
|
|
|
|
|
|
|
public function run() {
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
$user = $this->params['user'];
|
|
|
|
$settings = $this->params['settings'];
|
|
|
|
$post = $this->params['post'];
|
|
|
|
|
|
|
|
$ret = '';
|
2023-01-05 14:09:25 +00:00
|
|
|
if(!empty($post['previewpng'])) {
|
2023-09-14 10:10:12 +00:00
|
|
|
$cmd = 'rm -rf '.addDirSep($settings->_cacheDir).'png'.DIRECTORY_SEPARATOR.'[1-9]*';
|
2023-01-05 14:09:25 +00:00
|
|
|
system($cmd, $ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!empty($post['previewpdf'])) {
|
2023-09-14 10:10:12 +00:00
|
|
|
$cmd = 'rm -rf '.addDirSep($settings->_cacheDir).'pdf'.DIRECTORY_SEPARATOR.'[1-9]*';
|
2023-01-05 14:09:25 +00:00
|
|
|
system($cmd, $ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!empty($post['previewtxt'])) {
|
2023-09-14 10:10:12 +00:00
|
|
|
$cmd = 'rm -rf '.addDirSep($settings->_cacheDir).'txt'.DIRECTORY_SEPARATOR.'[1-9]*';
|
2020-08-21 08:03:22 +00:00
|
|
|
system($cmd, $ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!empty($post['js'])) {
|
2024-09-18 07:23:15 +00:00
|
|
|
/* system('rm ...') does not work anymore if the number of files is too large */
|
|
|
|
array_map('unlink', array_filter((array) glob(addDirSep($settings->_cacheDir).'js'.DIRECTORY_SEPARATOR.'*')));
|
2020-08-21 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(false === $this->callHook('clear', $post)) {
|
|
|
|
if(empty($this->errormsg))
|
|
|
|
$this->errormsg = 'hook_clear_failed';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|