diff --git a/library/ajax/manage_admin.php b/library/ajax/manage_admin.php index a383ba9a8..90467fd18 100644 --- a/library/ajax/manage_admin.php +++ b/library/ajax/manage_admin.php @@ -18,7 +18,11 @@ $mode = (string)$this->request['mode']; switch ($mode) { case 'clear_cache': - clean_cache(); + foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) { + if (!in_array('db_sqlite', $cache_val)) { + CACHE($cache_name)->rm(); + } + } $this->response['cache_html'] = '' . $lang['ALL_CACHE_CLEARED'] . ''; @@ -26,7 +30,9 @@ switch ($mode) { case 'clear_datastore': - clean_datastore(); + global $datastore; + + $datastore->clean(); $this->response['datastore_html'] = '' . $lang['DATASTORE_CLEARED'] . ''; @@ -34,7 +40,18 @@ switch ($mode) { case 'clear_template_cache': - clean_tpl_cache(); + global $template; + + $match = 'tpl_'; + $match_len = strlen($match); + $dir = $template->cachedir; + $res = @opendir($dir); + while (($file = readdir($res)) !== false) { + if (0 === strpos($file, $match)) { + @unlink($dir . $file); + } + } + closedir($res); $this->response['template_cache_html'] = '' . $lang['ALL_TEMPLATE_CLEARED'] . ''; diff --git a/library/includes/functions.php b/library/includes/functions.php index 6970543c0..17de5ece5 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -11,56 +11,6 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -/** - * Clean all template cache - * - * @return void - */ -function clean_tpl_cache(): void -{ - global $template; - - $match = XS_TPL_PREFIX; - $dir = $template->cachedir; - $res = @opendir($dir); - - while (($file = readdir($res)) !== false) { - if (0 === strpos($file, $match)) { - @unlink($dir . $file); - } - } - - closedir($res); -} - -/** - * Clean all datastore items - * - * @return void - */ -function clean_datastore(): void -{ - global $datastore; - - $datastore->clean(); -} - -/** - * Clean all cache items - * - * @return void - */ -function clean_cache(): void -{ - global $bb_cfg; - - foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) { - if (!in_array('db_sqlite', $cache_val)) { - CACHE($cache_name)->rm(); - } - } -} - function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div) { global $bb_cfg;