Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/acrit.cleanmaster/classes/general/ |
Upload File : |
<?php class CCleanCache extends TCleanMasterFunctions { private $documentRoot; private $conn; const CACHE_TYPES = [ 'marked', 'managed', 'cache' ]; private $managedCache, $stackCache, $cache, $compositeCache; public function __construct() { $this->documentRoot = Bitrix\Main\Application::getDocumentRoot(); $this->conn = Bitrix\Main\Application::getConnection(); $this->cache = '/bitrix/cache/'; $this->managedCache = '/bitrix/managed_cache/'; $this->stackCache = '/bitrix/stack_cache/'; $this->compositeCache = '/bitrix/html_pages/'; } /** * @param array{onlyCache : array{'marked' : string} } $stepParams = [] * * @return void */ public function CacheClear($stepParams = []): void { if (isset($stepParams['onlyCache'])) { if ($stepParams['onlyCache']['marked'] == 'Y') { $this->clearMarkedCache(); } if ($stepParams['onlyCache']['managed'] == 'Y') { DeleteDirFilesEx($this->managed_cache); // управляемый кэш } if ($stepParams['onlyCache']['cache'] == 'Y') { DeleteDirFilesEx($this->cache); // управляемый кэш } return; } // all DeleteDirFilesEx($this->managed_cache); // управляемый кэш DeleteDirFilesEx($this->cache); // просто кэш DeleteDirFilesEx($this->stackCache); // джонни кэш $this->clearMarkedCache(); $staticHtmlCache = \Bitrix\Main\Data\StaticHtmlCache::getInstance(); $staticHtmlCache->deleteAll(); } /** * Тегированный кеш, помеченный на удаление * @return int * @throws \Bitrix\Main\DB\SqlQueryException */ private function getMarkedCacheCnt(): int { return (int)$this->conn->query("SELECT COUNT(*) AS CNT FROM b_cache_tag WHERE TAG='*'")->fetch()["CNT"]; } private function getMarkedCacheSize(): float { $size = 0; $rs = $this->conn->query("SELECT RELATIVE_PATH FROM b_cache_tag WHERE TAG='*'"); while ($ar = $rs->fetch()) { $size += $this->GetDirSize($this->documentRoot . $ar['RELATIVE_PATH']); } return $size; } private function clearMarkedCache(): void { $rs = $this->conn->query("SELECT ID,RELATIVE_PATH FROM b_cache_tag WHERE TAG='*'"); while ($ar = $rs->fetch()) { DeleteDirFilesEx($ar['RELATIVE_PATH']); $this->conn->query('DELETE FROM b_cache_tag WHERE ID = ' . (int)$ar['ID']); } } public function GetDiagnosticData($step = false): bool { $_SESSION['cleanmaster']['diagnostic']['cache']['size'] = 0; $dirs = [ $this->cache, $this->managedCache, $this->stackCache, $this->compositeCache, ]; foreach ($dirs as $dir) { if (file_exists($this->documentRoot . $dir)) { $_SESSION['cleanmaster']['diagnostic']['cache']['dirs'][$dir] = $this->GetDirSize($this->documentRoot . $dir); $_SESSION['cleanmaster']['diagnostic']['cache']['size'] += $_SESSION['cleanmaster']['diagnostic']['cache']['dirs'][$dir]; } } $_SESSION['cleanmaster']['diagnostic']['cache']['marked'] = [ 'cnt' => $this->getMarkedCacheCnt(), 'size' => $this->getMarkedCacheSize(), ]; return false; } }