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 IncludeModuleLangFile(__FILE__); class CCleanSite { private $app; public function __construct() { $this->app = &$GLOBALS['APPLICATION']; } /** * Выбрать сайты по фильтру * @param array $filter = [] * @return array */ public function getSites($filter = []) { $by = "sort"; $order = "desc"; $sites = []; $dbSites = CSite::GetList($by, $order, $filter); while ($arSite = $dbSites->Fetch()) { $sites[$arSite['ID']] = $arSite; } return $sites; } public function GetActiveSites() { return $this->getSites(["ACTIVE" => "Y"]); } public function GetInactiveSites() { return $this->getSites(["ACTIVE" => "N"]); } /** * @param string|array $sites * @return array */ public function GetSitesForum($sites) { $r = []; if (! CModule::IncludeModule('forum')) { return $r; } $rs = \CForumNew::GetList(['sort' => 'asc'], ['SITE_ID' => $sites]); while ($ar = $rs->Fetch()) { $ar['SITES'] = array_keys(CForumNew::GetSites($ar['ID'])); $r[] = $ar; } return $r; } public function GetSitesIBlock($sites) { $siteIDs = array_keys($sites); $res = CIBlock::GetList([], ['SITE_ID' => $siteIDs], true); $deletedIBlock = []; while ($ar_res = $res->Fetch()) { $iblockSites = []; $rsSites = CIBlock::GetSite($ar_res['ID']); while ($arSite = $rsSites->Fetch()) { $iblockSites[] = htmlspecialchars($arSite["SITE_ID"]); } $isDiff = array_diff($iblockSites, $siteIDs); if (empty($isDiff)) { $deletedIBlock[$ar_res['ID']] = $ar_res; } } return $deletedIBlock; } public function CleanSites(array $siteList) { $siteIds = array_keys($siteList); $arActiveSites = $this->GetActiveSites(); $activeSiteDir = []; $processReport = [ 'error' => [], 'success' => [], ]; foreach ($arActiveSites as $site) { $activeSiteDir[] = $site['DIR']; } foreach ($siteList as $site_id => $site_dir) { $res = CIBlock::GetList([], ['SITE_ID' => $siteIds], true); while ($ar_res = $res->Fetch()) { $iblockSites = []; $rsSites = CIBlock::GetSite($ar_res['ID']); while ($arSite = $rsSites->Fetch()) { $iblockSites[] = htmlspecialchars($arSite["SITE_ID"]); } $isDiff = array_diff($iblockSites, $siteIds); if (empty($isDiff)) { if (CIBlock::Delete($ar_res['ID'])) { $processReport['success'][] = GetMessage("ACRIT_CLEANMASTER_INFOBLOK", ['#IBLOCK_ID#' => $ar_res['ID'], '#IBLOCK_NAME#' => $ar_res['NAME']]); } else { //if($ex = $this->app->GetException()) // $processReport['error'][] = $ex->GetString(); } } } if (\CModule::IncludeModule('forum')) { $forums = $this->GetSitesForum($site_id); foreach ($forums as $forum) { $isDiff = array_diff($forum['SITES'], $siteIds); if (empty($isDiff)) { if (\CForumNew::Delete($forum['ID'])) { $processReport['success'][] = GetMessage("ACRIT_CLEANMASTER_FORUM_DELETE", ['#FORUM_ID#' => $forum['ID'], '#FORUM_NAME#' => $forum['NAME']]); } } } } if (\CModule::IncludeModule('sale')) { $db_sales = \CSaleOrder::GetList(["DATE_INSERT" => "ASC"], ["LID" => $site_id]); if ($db_sales->SelectedRowsCount() > 0) { $processReport['success'][] = GetMessage("ACRIT_CLEANMASTER_CLEAN_SITE_ORDERS"); } while ($ar_sales = $db_sales->Fetch()) { \CSaleOrder::Delete($ar_sales['ID']); } $db_ptype = \CSalePersonType::GetList(["SORT" => "ASC"], ["LID" => $site_id]); while ($ptype = $db_ptype->Fetch()) { \CSalePersonType::Delete($ptype['ID']); } } if (\CModule::IncludeModule('subscribe')) { $db_rub = \CRubric::GetList(["SORT" => "ASC"], ["LID" => $site_id]); if ($db_rub->SelectedRowsCount() > 0) { $processReport['success'][] = GetMessage("ACRIT_CLEANMASTER_CLEAN_SITE_SUBSCRIBE_RUBRICS"); } while ($ar = $db_rub->Fetch()) { \CRubric::Delete($ar['ID']); } } if (CSite::Delete($site_id) === false) { if ($ex = $this->app->GetException()) { $processReport['error'][] = str_replace('#SITE#', $site_id, GetMessage('CLEANMASTER_ACTION_1_SITE')) . $ex->GetString(); } } else { $processReport['success'][] = GetMessage('CLEANMASTER_ACTION_1_SITE_DELETED', ['#SITE#' => $site_id]); } if (!in_array($site_dir, $activeSiteDir)) { if (file_exists($site_dir)) { DeleteDirFilesEx($site_dir); } } } return $processReport; } /** * Получаем данные для диагностики */ public function GetDiagnosticData($step = false) { $anactiveSites = $this->GetInactiveSites(); $anactiveSitesIB = $this->GetSitesIBlock($anactiveSites); $_SESSION['cleanmaster']['diagnostic']['site']['site'] = $anactiveSites; $_SESSION['cleanmaster']['diagnostic']['site']['iblock'] = $anactiveSitesIB; return false; } }