mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 05:13:54 -07:00
Misc code improvements
This commit is contained in:
parent
33b78f8b99
commit
b479068bf3
2 changed files with 53 additions and 20 deletions
|
@ -18,11 +18,7 @@ $mode = (string)$this->request['mode'];
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'clear_cache':
|
case 'clear_cache':
|
||||||
|
|
||||||
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) {
|
clean_cache();
|
||||||
if (!in_array('db_sqlite', $cache_val)) {
|
|
||||||
CACHE($cache_name)->rm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->response['cache_html'] = '<span class="seed bold">' . $lang['ALL_CACHE_CLEARED'] . '</span>';
|
$this->response['cache_html'] = '<span class="seed bold">' . $lang['ALL_CACHE_CLEARED'] . '</span>';
|
||||||
|
|
||||||
|
@ -30,9 +26,7 @@ switch ($mode) {
|
||||||
|
|
||||||
case 'clear_datastore':
|
case 'clear_datastore':
|
||||||
|
|
||||||
global $datastore;
|
clean_datastore();
|
||||||
|
|
||||||
$datastore->clean();
|
|
||||||
|
|
||||||
$this->response['datastore_html'] = '<span class="seed bold">' . $lang['DATASTORE_CLEARED'] . '</span>';
|
$this->response['datastore_html'] = '<span class="seed bold">' . $lang['DATASTORE_CLEARED'] . '</span>';
|
||||||
|
|
||||||
|
@ -40,18 +34,7 @@ switch ($mode) {
|
||||||
|
|
||||||
case 'clear_template_cache':
|
case 'clear_template_cache':
|
||||||
|
|
||||||
global $template;
|
clean_tpl_cache();
|
||||||
|
|
||||||
$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'] = '<span class="seed bold">' . $lang['ALL_TEMPLATE_CLEARED'] . '</span>';
|
$this->response['template_cache_html'] = '<span class="seed bold">' . $lang['ALL_TEMPLATE_CLEARED'] . '</span>';
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,56 @@ if (!defined('BB_ROOT')) {
|
||||||
die(basename(__FILE__));
|
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)
|
function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div)
|
||||||
{
|
{
|
||||||
global $bb_cfg;
|
global $bb_cfg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue