public static function writeFile($file_name, $content) { global $USER; if(is_object($USER) && $USER->IsAuthorized()) return; $content_len = function_exists('mb_strlen')? mb_strlen($content, 'latin1'): strlen($content); if($content_len <= 0) return; $arHTMLPagesOptions = CHTMLPagesCache::GetOptions(); //Let's be pessimists $bQuota = false; if(class_exists("cdiskquota")) { $quota = new CDiskQuota(); if($quota->checkDiskQuota(array("FILE_SIZE" => $content_len))) $bQuota = true; } else { $bQuota = true; } $arStat = CHTMLPagesCache::readStatistic(); if($arStat) $cached_size = $arStat["FILE_SIZE"]; else $cached_size = 0.0; $cache_quota = doubleval($arHTMLPagesOptions["~FILE_QUOTA"]); if($bQuota && ($cache_quota > 0.0)) { if($cache_quota < ($cached_size + $content_len)) $bQuota = false; } if($bQuota) { CheckDirPath($file_name); $written = 0; $tmp_filename = $file_name.md5(mt_rand()).".tmp"; $file = @fopen($tmp_filename, "wb"); if($file !== false) { $written = fwrite($file, $content); if($written == $content_len) { fclose($file); if(file_exists($file_name)) unlink($file_name); rename($tmp_filename, $file_name); @chmod($file_name, defined("FX_FILE_PERMISSIONS")? FX_FILE_PERMISSIONS: 0664); if(class_exists("cdiskquota")) { CDiskQuota::updateDiskQuota("file", $content_len, "copy"); } } else { $written = 0; fclose($file); if(file_exists($file_name)) unlink($file_name); if(file_exists($tmp_filename)) unlink($tmp_filename); } } $arStat = CHTMLPagesCache::writeStatistic( 0, //hit 1, //miss 0, //quota 0, //posts $written //files ); } else { //Fire cleanup CHTMLPagesCache::CleanAll(); CHTMLPagesCache::writeStatistic(0, 0, 1, 0, false); } }
} $errorMessage = ""; $okMessage = ""; if ($REQUEST_METHOD == "POST" && $clearcache == "Y" && strlen($cachetype) > 0 && check_bitrix_sessid() && $isAdmin) { if ($cachetype == "menu") { $GLOBALS["CACHE_MANAGER"]->CleanDir("menu"); } elseif ($cachetype == "managed") { $GLOBALS["CACHE_MANAGER"]->CleanAll(); $GLOBALS["stackCacheManager"]->CleanAll(); } elseif ($cachetype == "html") { CHTMLPagesCache::CleanAll(); } else { BXClearCache($cachetype == "all"); $GLOBALS["CACHE_MANAGER"]->CleanAll(); $GLOBALS["stackCacheManager"]->CleanAll(); CHTMLPagesCache::CleanAll(); } $okMessage .= GetMessage("MAIN_OPTION_CACHE_OK") . ". "; } if ($REQUEST_METHOD == "POST" && ($cache_on == "Y" || $cache_on == "N") && check_bitrix_sessid() && $isAdmin) { if (COption::GetOptionString("main", "component_cache_on", "Y") == "Y") { if ($cache_on == "N") { COption::SetOptionString("main", "component_cache_on", "N"); $okMessage .= GetMessage("MAIN_OPTION_CACHE_SUCCESS") . ". "; } } else { if ($cache_on == "Y") { COption::SetOptionString("main", "component_cache_on", "Y"); $okMessage .= GetMessage("MAIN_OPTION_CACHE_SUCCESS") . ". "; } }
function InstallService($serviceID, $serviceStage) { $wizard =& $this->GetWizard(); if (CModule::IncludeModule("iblock")) { $type = substr($serviceID, 0, -1); if ($type == "iblockElement") { $dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockElement::Delete($arItem["ID"]); } } elseif ($type == "iblockSectionElement") { $dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockElement::Delete($arItem["ID"]); } $dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockSection::Delete($arItem["ID"]); } } elseif ($serviceID == "iblockDepartmentsElement") { $dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => "departments")); while ($arItem = $dbItem->Fetch()) { if ($arItem["DEPTH_LEVEL"] > 2) { CIBlockSection::Delete($arItem["ID"]); } } } elseif ($serviceID == "tasks") { if (CModule::IncludeModule("tasks")) { $dbItem = CTasks::GetList(array(), array("SITE_ID" => $wizard->GetVar("siteID"))); while ($arItem = $dbItem->Fetch()) { CTasks::Delete($arItem["ID"]); } } } elseif ($serviceID == "calendar") { if (CModule::IncludeModule("calendar")) { $dbItem = CCalendarEvent::GetList(); foreach ($dbItem as $arItem) { CCalendarEvent::Delete(array("id" => $arItem["ID"])); } } } elseif ($serviceID == "meeting") { if (CModule::IncludeModule("meeting")) { $dbItem = CMeeting::GetList(array(), array()); while ($arItem = $dbItem->Fetch()) { if ($arItem["ID"]) { CMeeting::Delete($arItem["ID"]); } } } } elseif ($serviceID == "user") { if ($serviceStage == "user") { $dbUser = CUser::GetList($by = "ID", $order = "DESC", array(">ID" => 1)); while ($arUser = $dbUser->Fetch()) { CUser::Delete($arUser["ID"]); } } } elseif ($serviceID == "crm") { if ($serviceStage == "crm") { if (CModule::IncludeModule('crm')) { $CCrmLead = new CCrmLead(); $resLead = CCrmLead::GetList(array(), array(), array(), false); while ($rowLead = $resLead->Fetch()) { $CCrmLead->Delete($rowLead["ID"]); } $CCrmContact = new CCrmContact(); $resContact = CCrmContact::GetList(array(), array(), array(), false); while ($rowContact = $resContact->Fetch()) { $CCrmContact->Delete($rowContact["ID"]); } $CCrmCompany = new CCrmCompany(); $resCompany = CCrmCompany::GetList(array(), array(), array(), false); while ($rowCompany = $resCompany->Fetch()) { $CCrmCompany->Delete($rowCompany["ID"]); } $CCrmDeal = new CCrmDeal(); $resDeal = CCrmDeal::GetList(array(), array(), array(), false); while ($rowDeal = $resDeal->Fetch()) { $CCrmDeal->Delete($rowDeal["ID"]); } } } } elseif ($serviceID == "cache") { require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_html.php"; if ($serviceStage == "cache1") { BXClearCache(true); } elseif ($serviceStage == "cache2") { $GLOBALS["CACHE_MANAGER"]->CleanAll(); } elseif ($serviceStage == "cache3") { $GLOBALS["stackCacheManager"]->CleanAll(); } elseif ($serviceStage == "cache4") { CHTMLPagesCache::CleanAll(); } COption::SetOptionString("main", "wizard_clear_exec", "Y", false, $wizard->GetVar("siteID")); } } }