Управление кешем

Модули и плагины для vii (студяги)!
Ответить
Аватара пользователя
glGizma
Site Admin
Сообщения: 214
Зарегистрирован: Ср сен 27, 2017 2:20 pm

Управление кешем

Сообщение glGizma » Сб фев 01, 2020 8:55 am

1) В папке /system/inc/ создаем файл cache.php со следующим содержимым:

Код: Выделить всё

<?php 
/*  
    Appointment: Управление кешем 
    File: cache.php 
  
*/ 
if(!defined('MOZG')) 
    die('Hacking attempt!'); 
 
echoheader(); 
echohtmlstart('Чистка кеша пользователей'); 
 
// Чистим кеш профиля определенного пользователя 
if(isset($POST['cid']))
{
$user_id = intval($_POST['cuid']);
mozg_clear_cache_file('user_'.$user_id.'/profile_'.$user_id);
}
 
// Чистим кеш по списку ID - ОТ и ДО 
if(isset($POST['ciduids']))
{
$start_id =intval($_POST['startuid']);
$end_id =intval($_POST['enduid']);
while($start_id < $end_id)
{
$start_id++;
$user_id = $start_id;
mozg_clear_cache_file('user_'.$user_id.'/profile_'.$user_id);
}
}
// Чистим вообще весь кеш
if(isset($POST['cidall']))
{
    $files = glob("system/cache/*");
    $c = count($files);
    if (count($files) > 0) {
        foreach ($files as $file) {      
            if (file_exists($file)) {
            unlink($file);
            }   
        }
    }
}
 
function dirsize($directory){ 
    if(!is_dir($directory)) return - 1; 
    $size = 0; 
    if($DIR = opendir($directory)){ 
        while(($dirfile = readdir($DIR)) !== false){ 
            if(@is_link($directory.'/'.$dirfile) || $dirfile == '.' || $dirfile == '..') continue; 
            if(@is_file($directory.'/'.$dirfile)) $size += filesize($directory . '/' . $dirfile); 
            else if(@is_dir($directory.'/'.$dirfile)){ 
                $dirSize = dirsize($directory.'/'.$dirfile); 
                if($dirSize >= 0) $size += $dirSize; 
                else return - 1; 
            } 
        } 
        closedir( $DIR ); 
    } 
    return $size; 
} 
 
$cache_size = formatsize(dirsize("/system/cache")); 
 
echo '
 
<div class="fllogall">Размер папки system/cache/:</div> 
 <div style="margin-bottom:10px">'.$cache_size.'&nbsp;</div> 
<div class="mgcler"></div> 
 
<form method="POST">Удалить кеш конкретного ID: <input type="text" name="cuid"><input type="submit" name="cid" value="Удалить!"></form>
<br>
<br> 
<form method="POST">Удалить кеш нескольких ID: От ID:<input type="text" name="startuid"> До ID:<input type="text" name="enduid"><input type="submit" name="ciduids" value="Удалить!"></form>
<br>
<br>
<form method="POST">Удалить весь кеш, *** знает зачем: <input type="submit" name="cidall" value="Удалить весь кеш!"></form> 
'; 
 
echohtmlend(); 
?>
2) В файле /system/inc/main.php добавляем:

Код: Выделить всё

echoblock('Управление кешем', 'Чистка кеша профиля выбранных пользователей', 'cache', 'cache'); 
В файле /system/inc/mod.php добавляем:

Код: Выделить всё

//cache
    case "cache": 
        include ADMIN_DIR.'/cache.php'; 
    break;  
Вложения
(119).jpg
(119).jpg (670.57 КБ) 12023 просмотра

Ответить