32 private static $instance;
33 private static $isEnabled =
false;
34 private static $useHTMLCache =
false;
35 private static $onBeforeHandleKey =
false;
36 private static $onRestartBufferHandleKey =
false;
37 private static $onBeforeLocalRedirect =
false;
38 private static $autoUpdate =
true;
39 private static $autoUpdateTTL = 0;
40 private static $isCompositeInjected =
false;
41 private static $isRedirect =
false;
42 private static $isBufferRestarted =
false;
47 private function __construct()
55 private function __clone()
67 if (is_null(self::$instance))
69 self::$instance =
new Engine();
72 return self::$instance;
84 if ($isEnabled && !self::$isEnabled)
86 self::$onBeforeHandleKey = AddEventHandler(
88 "OnBeforeEndBufferContent",
89 array(__CLASS__,
"onBeforeEndBufferContent")
91 self::$onRestartBufferHandleKey = AddEventHandler(
93 "OnBeforeRestartBuffer",
94 array(__CLASS__,
"onBeforeRestartBuffer")
96 self::$onBeforeLocalRedirect = AddEventHandler(
98 "OnBeforeLocalRedirect",
99 array(__CLASS__,
"onBeforeLocalRedirect"),
102 self::$isEnabled =
true;
103 \CJSCore::init(array(
"fc"));
105 elseif (!$isEnabled && self::$isEnabled)
107 if (self::$onBeforeHandleKey >= 0)
109 RemoveEventHandler(
"main",
"OnBeforeEndBufferContent", self::$onBeforeHandleKey);
112 if (self::$onRestartBufferHandleKey >= 0)
114 RemoveEventHandler(
"main",
"OnBeforeRestartBuffer", self::$onRestartBufferHandleKey);
117 if (self::$onBeforeLocalRedirect >= 0)
119 RemoveEventHandler(
"main",
"OnBeforeLocalRedirect", self::$onBeforeLocalRedirect);
122 self::$isEnabled =
false;
133 return self::$isEnabled;
145 if (self::getUseAppCache())
147 self::setUseHTMLCache(
false);
149 $appCache = AppCache::getInstance();
150 $appCache->setEnabled($useAppCache);
160 $appCache = AppCache::getInstance();
162 return $appCache->isEnabled();
174 self::$useHTMLCache = $useHTMLCache;
185 return self::$useHTMLCache;
195 return Helper::isAjaxRequest();
200 return self::isAjaxRequest() &&
Context::getCurrent()->getServer()->get(
"HTTP_BX_INVALIDATE_CACHE") ===
"Y";
209 return Option::get(
"main",
"~show_composite_banner",
"Y") ==
"Y";
221 self::$autoUpdate = $flag ===
false ? false :
true;
230 return self::$autoUpdate;
242 self::$autoUpdateTTL = intval($ttl);
251 return self::$autoUpdateTTL;
263 if (self::getUseAppCache())
265 $manifest = AppCache::getInstance();
266 $params = $manifest->OnBeforeEndBufferContent();
267 $params[
"CACHE_MODE"] =
"APPCACHE";
270 elseif (self::getUseHTMLCache())
273 $page->onBeforeEndBufferContent();
275 if ($page->isCacheable())
277 $params[
"CACHE_MODE"] =
"HTMLCACHE";
279 if (self::isBannerEnabled())
281 $options = Helper::getOptions();
282 $params[
"banner"] = array(
283 "url" => GetMessage(
"COMPOSITE_BANNER_URL"),
284 "text" => GetMessage(
"COMPOSITE_BANNER_TEXT"),
285 "bgcolor" => $options[
"BANNER_BGCOLOR"] ??
"",
286 "style" => $options[
"BANNER_STYLE"] ??
""
296 $params[
"storageBlocks"] = array();
297 $params[
"dynamicBlocks"] = array();
298 $dynamicAreas = StaticArea::getDynamicAreas();
299 foreach ($dynamicAreas as $id => $dynamicArea)
301 $stub = $dynamicArea->getStub();
302 self::replaceSessid($stub);
304 $params[
"dynamicBlocks"][$dynamicArea->getId()] = mb_substr(md5($stub), 0, 12);
305 if ($dynamicArea->getBrowserStorage())
307 $realId = $dynamicArea->getContainerId() !==
null ? $dynamicArea->getContainerId() :
"bxdynamic_".$id;
308 $params[
"storageBlocks"][] = $realId;
312 $params[
"AUTO_UPDATE"] = self::getAutoUpdate();
313 $params[
"AUTO_UPDATE_TTL"] = self::getAutoUpdateTTL();
314 $params[
"version"] = 2;
316 Asset::getInstance()->addString(
317 self::getInjectedJs($params),
319 AssetLocation::BEFORE_CSS,
320 self::getUseHTMLCache() ? AssetMode::COMPOSITE : AssetMode::ALL
323 self::$isCompositeInjected =
true;
334 if (!self::isEnabled() || !is_object(
$GLOBALS[
"APPLICATION"]) || !self::$isCompositeInjected)
339 if (defined(
"BX_BUFFER_SHUTDOWN") || !defined(
"B_EPILOG_INCLUDED"))
343 "TYPE" => Logger::TYPE_PHP_SHUTDOWN,
350 $newBuffer =
$GLOBALS[
"APPLICATION"]->buffer_content;
351 $cnt = count(
$GLOBALS[
"APPLICATION"]->buffer_content_type);
353 Asset::getInstance()->setMode(AssetMode::COMPOSITE);
355 self::$isCompositeInjected =
false;
356 for ($i = 0; $i < $cnt; $i++)
358 $method =
$GLOBALS[
"APPLICATION"]->buffer_content_type[$i][
"F"];
359 if (!is_array($method) || count($method) !== 2 || $method[0] !==
$GLOBALS[
"APPLICATION"])
364 if (in_array($method[1], array(
"GetCSS",
"GetHeadScripts",
"GetHeadStrings")))
366 $newBuffer[$i * 2 + 1] = call_user_func_array(
368 $GLOBALS[
"APPLICATION"]->buffer_content_type[$i][
"P"]
370 if (self::$isCompositeInjected !==
true && $method[1] ===
"GetHeadStrings")
372 self::$isCompositeInjected =
373 strpos($newBuffer[$i * 2 + 1],
"w.frameRequestStart") !==
false;
378 Asset::getInstance()->setMode(AssetMode::STANDARD);
380 if (!self::$isCompositeInjected)
384 "TYPE" => Logger::TYPE_COMPOSITE_NOT_INJECTED,
389 return self::$isCompositeInjected ? implode(
"", $newBuffer).$content :
null;
401 public static function endBuffering(&$originalContent, $compositeContent)
403 if (!self::isEnabled() || $compositeContent ===
null || defined(
"BX_BUFFER_SHUTDOWN") || !defined(
"B_EPILOG_INCLUDED"))
406 if (self::isAjaxRequest() && self::$isRedirect ===
false)
408 $originalContent = self::getAjaxError();
417 if (function_exists(
"getmoduleevents"))
419 foreach (GetModuleEvents(
"main",
"OnEndBufferContent",
true) as $arEvent)
421 ExecuteModuleEventEx($arEvent, array(&$compositeContent));
425 $compositeContent = self::processPageContent($compositeContent);
426 if (self::isAjaxRequest() || self::getUseAppCache())
428 $originalContent = $compositeContent;
450 private static function processPageContent($content)
452 global $APPLICATION, $USER;
454 $dividedData = self::getDividedPageData($content);
455 $htmlCacheChanged =
false;
457 if (self::getUseHTMLCache())
460 if ($page->isCacheable())
462 $cacheExists = $page->exists();
463 $rewriteCache = $page->getMd5() !== $dividedData[
"md5"];
464 if (self::getAutoUpdate() && self::getAutoUpdateTTL() > 0 && $cacheExists)
466 $mtime = $page->getLastModified();
467 if ($mtime !==
false && ($mtime + self::getAutoUpdateTTL()) > time())
469 $rewriteCache =
false;
473 $invalidateCache = self::getAutoUpdate() ===
false && self::isInvalidationRequest();
476 if (!$cacheExists || $rewriteCache || $invalidateCache)
478 if ($invalidateCache || Locker::lock($page->getCacheKey()))
480 if ($cacheExists && Logger::isOn())
482 $oldContent = $page->read();
485 if ($page->getStorage() instanceof Data\FileStorage)
487 $freeSpace = strlen($dividedData[
"static"]) + strlen($dividedData[
"md5"]);
488 self::ensureFileQuota($freeSpace);
491 $success = $page->write($dividedData[
"static"], $dividedData[
"md5"]);
495 $htmlCacheChanged =
true;
496 $page->setUserPrivateKey();
499 Locker::unlock($page->getCacheKey());
503 $pageId = PageManager::register(
504 $page->getCacheKey(),
506 "CHANGED" => $htmlCacheChanged,
507 "SIZE" => $page->getSize()
511 if ($oldContent !==
null)
515 "TYPE" => Logger::TYPE_CACHE_REWRITING,
516 "MESSAGE" => $oldContent,
526 return self::getAjaxError();
530 if (self::getUseAppCache() ==
true)
532 AppCache::getInstance()->generate($dividedData[
"static"]);
536 AppCache::checkObsoleteManifest();
539 if (self::isAjaxRequest())
541 self::sendRandHeader();
543 header(
"Content-Type: application/x-javascript; charset=".SITE_CHARSET);
544 header(
"X-Bitrix-Composite: Ajax ".($htmlCacheChanged ?
"(changed)" :
"(stable)"));
547 "js" => array_unique($APPLICATION->arHeadScripts),
548 "lang" => \CJSCore::GetCoreMessages(),
549 "css" => $APPLICATION->GetCSSArray(),
550 "htmlCacheChanged" => $htmlCacheChanged,
551 "isManifestUpdated" => AppCache::getInstance()->getIsModified(),
552 "dynamicBlocks" => $dividedData[
"dynamic"],
553 "spread" => array_map(array(
"CUtil",
"JSEscape"), $APPLICATION->GetSpreadCookieUrls()),
556 $content = \CUtil::PhpToJSObject($content);
560 $content = $dividedData[
"static"];
583 private static function getDividedPageData($content)
586 "dynamic" => array(),
591 $dynamicAreas = StaticArea::getDynamicAreas();
592 if (!empty($dynamicAreas) && ($areas = self::getFrameIndexes($content)) !==
false)
595 $pageBlocks = self::getPageBlocks();
596 foreach ($areas as $area)
598 $dynamicArea = StaticArea::getDynamicArea($area->id);
599 if ($dynamicArea ===
null)
604 $realId = $dynamicArea->getContainerId() !==
null ? $dynamicArea->getContainerId() :
"bxdynamic_".$area->id;
605 $assets = Asset::getInstance()->getAssetInfo($dynamicArea->getAssetId(), $dynamicArea->getAssetMode());
606 $areaContent = substr($content, $area->openTagEnd, $area->closingTagStart - $area->openTagEnd);
607 $areaContentMd5 = substr(md5($areaContent), 0, 12);
609 $blockId = $dynamicArea->getId();
610 $hasSameContent = isset($pageBlocks[$blockId]) && $pageBlocks[$blockId] === $areaContentMd5;
612 if (!$hasSameContent)
614 $data[
"dynamic"][] = array(
616 "CONTENT" => $areaContent,
617 "HASH" => $areaContentMd5,
620 "CONTAINER_ID" => $dynamicArea->getContainerId(),
621 "USE_BROWSER_STORAGE" => $dynamicArea->getBrowserStorage(),
622 "AUTO_UPDATE" => $dynamicArea->getAutoUpdate(),
623 "USE_ANIMATION" => $dynamicArea->getAnimation(),
624 "CSS" => $assets[
"CSS"],
625 "JS" => $assets[
"JS"],
626 "BUNDLE_JS" => $assets[
"BUNDLE_JS"],
627 "BUNDLE_CSS" => $assets[
"BUNDLE_CSS"],
628 "STRINGS" => $assets[
"STRINGS"],
633 $data[
"static"] .= substr($content, $offset, $area->openTagStart - $offset);
635 if ($dynamicArea->getContainerId() ===
null)
638 '<div id="bxdynamic_'.$area->id.
'_start" style="display:none"></div>'.
639 $dynamicArea->getStub().
640 '<div id="bxdynamic_'.$area->id.
'_end" style="display:none"></div>';
644 $data[
"static"] .= $dynamicArea->getStub();
647 $offset = $area->closingTagEnd;
650 $data[
"static"] .= substr($content, $offset);
654 $data[
"static"] = $content;
657 self::replaceSessid($data[
"static"]);
658 Asset::getInstance()->moveJsToBody($data[
"static"]);
660 $data[
"md5"] = md5($data[
"static"]);
670 private static function getFrameIndexes($content)
672 $openTag =
"<!--'start_frame_cache_";
673 $closingTag =
"<!--'end_frame_cache_";
678 while (($openTagStart = strpos($content, $openTag, $offset)) !==
false)
680 $endingPos = strpos($content, $ending, $openTagStart);
681 if ($endingPos ===
false)
686 $idStart = $openTagStart + mb_strlen($openTag);
687 $idLength = $endingPos - $idStart;
688 $areaId = substr($content, $idStart, $idLength);
689 $openTagEnd = $endingPos + mb_strlen($ending);
691 $realClosingTag = $closingTag.$areaId.$ending;
692 $closingTagStart = strpos($content, $realClosingTag, $openTagEnd);
693 if ($closingTagStart ===
false)
695 $offset = $openTagEnd;
699 $closingTagEnd = $closingTagStart + mb_strlen($realClosingTag);
701 $area = new \stdClass();
703 $area->openTagStart = $openTagStart;
704 $area->openTagEnd = $openTagEnd;
705 $area->closingTagStart = $closingTagStart;
706 $area->closingTagEnd = $closingTagEnd;
709 $offset = $closingTagEnd;
712 return !empty($areas) ? $areas :
false;
715 private static function getPageBlocks()
719 if ($json !==
null && $json <>
'')
721 $blocks = json_decode($json,
true);
722 if ($blocks ===
null)
736 private static function replaceSessid(&$content)
738 $methodInvocations = bitrix_sessid_post(
"sessid",
true);
739 if ($methodInvocations > 0)
741 $content = str_replace(
"value=\"".bitrix_sessid().
"\"",
"value=\"\"", $content);
753 self::$isBufferRestarted =
true;
754 self::setEnable(
false);
758 "TYPE" => Logger::TYPE_BUFFER_RESTART,
761 ($_SERVER[
"REAL_FILE_PATH"] ?? $_SERVER[
"SCRIPT_NAME"])
768 if (!self::isAjaxRequest() || ($isExternal && $skip_security_check !==
true))
775 "reason" =>
"redirect",
776 "redirect_url" => $url,
779 self::setEnable(
false);
783 "TYPE" => Logger::TYPE_LOCAL_REDIRECT,
786 ($_SERVER[
"REAL_FILE_PATH"] ?? $_SERVER[
"SCRIPT_NAME"]).
"\n".
787 "Redirect Url: ".$url
791 self::$isRedirect =
true;
794 $response =
new Response\Json($response);
795 $response->addHeader(
'X-Bitrix-Composite',
'Ajax (error:redirect)');
797 $bxRandom = Helper::getAjaxRandom();
798 if ($bxRandom !==
false)
800 $response->addHeader(
'BX-RAND', $bxRandom);
806 private static function ensureFileQuota($requiredFreeSpace = 0)
809 if (Helper::checkQuota($requiredFreeSpace) || $tries <= 0)
814 $records = PageTable::getList(
816 "select" => array(
"ID",
"CACHE_KEY"),
817 "order" => array(
"LAST_VIEWED" =>
"ASC",
"ID" =>
"ASC"),
818 "limit" => self::getDeletionLimit()
823 $compositeOptions = Helper::getOptions();
825 while ($record = $records->fetch())
827 $ids[] = $record[
"ID"];
828 $fileStorage =
new Data\FileStorage($record[
"CACHE_KEY"], array(), $compositeOptions);
829 $deletedSize += doubleval($fileStorage->delete());
832 PageTable::deleteBatch(array(
"ID" => $ids));
834 Helper::updateCacheFileSize(-$deletedSize);
837 "TYPE" => Logger::TYPE_CACHE_RESET,
839 "Pages: ".count($ids).
"\n".
840 "Size: ".\CFile::formatSize($deletedSize)
843 if (!Helper::checkQuota($requiredFreeSpace))
846 self::ensureFileQuota($requiredFreeSpace);
853 private static function getDeletionLimit()
855 $options = Helper::getOptions();
856 if (isset($options[
"PAGE_DELETION_LIMIT"]) && intval($options[
"PAGE_DELETION_LIMIT"]) > 0)
858 return intval($options[
"PAGE_DELETION_LIMIT"]);
862 return self::PAGE_DELETION_LIMIT;
866 private static function getAjaxError($errorMsg =
null)
869 if ($errorMsg !==
null)
873 elseif (self::$isBufferRestarted)
875 $error =
"buffer_restarted";
877 elseif (!self::isEnabled())
879 $error =
"not_enabled";
881 elseif (defined(
"BX_BUFFER_SHUTDOWN"))
883 $error =
"php_shutdown";
887 $error =
"not_cacheable";
889 elseif (!self::$isCompositeInjected)
891 $error =
"not_injected";
894 header(
"X-Bitrix-Composite: Ajax (error:".$error.
")");
895 self::sendRandHeader();
902 return \CUtil::PhpToJSObject($response);
908 private static function sendRandHeader()
910 $bxRandom = Helper::getAjaxRandom();
911 if ($bxRandom !==
false)
913 header(
"BX-RAND: ".$bxRandom);
925 private static function getInjectedJs($params = array())
927 $vars = \CUtil::PhpToJSObject($params);
932 var v = w.frameCacheVars = $vars;
934 if (v.AUTO_UPDATE ===
false)
936 if (v.AUTO_UPDATE_TTL && v.AUTO_UPDATE_TTL > 0)
938 var lm = Date.parse(d.lastModified);
941 var td = new Date().getTime();
942 if ((lm + v.AUTO_UPDATE_TTL * 1000) >= td)
944 w.frameRequestStart = false;
945 w.preventAutoUpdate = true;
953 w.frameRequestStart = false;
954 w.preventAutoUpdate = true;
959 var r = w.XMLHttpRequest ?
new XMLHttpRequest() : (w.ActiveXObject ? new w.ActiveXObject(
"Microsoft.XMLHTTP") : null);
962 w.frameRequestStart =
true;
964 var m = v.CACHE_MODE; var l = w.location; var x =
new Date().getTime();
965 var q =
"?bxrand=" + x + (l.search.length > 0 ?
"&" + l.search.substring(1) :
"");
966 var u = l.protocol +
"//" + l.host + l.pathname + q;
968 r.open(
"GET", u,
true);
969 r.setRequestHeader(
"BX-ACTION-TYPE",
"get_dynamic");
970 r.setRequestHeader(
"X-Bitrix-Composite",
"get_dynamic");
971 r.setRequestHeader(
"BX-CACHE-MODE", m);
972 r.setRequestHeader(
"BX-CACHE-BLOCKS", v.dynamicBlocks ? JSON.stringify(v.dynamicBlocks) :
"");
975 r.setRequestHeader(
"BX-INVALIDATE-CACHE",
"Y");
978 try { r.setRequestHeader(
"BX-REF", d.referrer ||
"");}
catch(e) {}
980 if (m ===
"APPCACHE")
982 r.setRequestHeader(
"BX-APPCACHE-PARAMS", JSON.stringify(v.PARAMS));
983 r.setRequestHeader(
"BX-APPCACHE-URL", v.PAGE_URL ? v.PAGE_URL :
"");
986 r.onreadystatechange =
function() {
987 if (r.readyState != 4) {
return; }
988 var a = r.getResponseHeader(
"BX-RAND");
989 var b = w.BX && w.BX.frameCache ? w.BX.frameCache :
false;
990 if (a != x || !((r.status >= 200 && r.status < 300) || r.status === 304 || r.status === 1223 || r.status === 0))
992 var f = {error:
true, reason:a!=x?
"bad_rand":
"bad_status", url:u, xhr:r, status:r.status};
993 if (w.BX && w.BX.ready && b)
995 BX.ready(
function() {
996 setTimeout(
function(){
997 BX.onCustomEvent(
"onFrameDataRequestFail", [f]);
1002 w.frameRequestFail = f;
1009 b.onFrameDataReceived(r.responseText);
1010 if (!w.frameUpdateInvoked)
1014 w.frameUpdateInvoked =
true;
1018 w.frameDataString = r.responseText;
1024 var p = w.performance;
1025 if (p && p.addEventListener && p.getEntries && p.setResourceTimingBufferSize)
1027 var e =
'resourcetimingbufferfull';
1028 var h =
function() {
1029 if (w.BX && w.BX.frameCache && w.BX.frameCache.frameDataInserted)
1031 p.removeEventListener(e, h);
1035 p.setResourceTimingBufferSize(p.getEntries().length + 50);
1038 p.addEventListener(e, h);
1041 })(window, document);
1045 if (self::isBannerEnabled())
1047 $html .=
'<style type="text/css">'.str_replace(array(
"\n",
"\t"),
"", self::getInjectedCSS()).
"</style>\n";
1050 $html .=
'<script type="text/javascript" data-skip-moving="true">'.
1051 str_replace(array(
"\n",
"\t"),
"", $inlineJS).
1070 background: url(/
bitrix/images/main/composite/sprite-1x.png) no-repeat right 0 #e94524;
1071 border-radius: 15px;
1072 color: #fff !important;
1073 display:
inline-block;
1075 font-family:
"Helvetica Neue", Helvetica, Arial, sans-serif !important;
1076 font-size: 12px !important;
1077 font-weight: bold !important;
1078 height: 31px !important;
1079 padding: 0 42px 0 17px !important;
1080 vertical-align: middle !important;
1081 text-decoration: none !important;
1085 and (min-device-width: 1200px)
1086 and (max-device-width: 1600px)
1087 and (-webkit-min-device-pixel-ratio: 2)
1088 and (min-resolution: 192dpi) {
1090 background-image: url(/
bitrix/images/main/composite/sprite-2x.png);
1091 background-size: 42px 124px;
1095 .bx-composite-btn-fixed {
1103 background-position: right 0;
1104 color: #fff !important;
1108 background-position: right -31px;
1109 color: #000 !important;
1113 background-position: right -62px;
1114 color: #555 !important;
1118 background-position: right -93px;
1119 color: #657b89 !important;
1123 border: 1px solid #d4d4d4;
1124 height: 29px !important;
1125 line-height: 29px !important;
1128 .bx-composite-loading {
1132 background: url(/
bitrix/images/main/composite/loading.gif);
1145 if (self::isSelfHostedPortal())
1150 if (defined(
"USE_HTML_STATIC_CACHE") && USE_HTML_STATIC_CACHE ===
true)
1153 !defined(
"BX_SKIP_SESSION_EXPAND") &&
1154 (!defined(
"ADMIN_SECTION") || (defined(
"ADMIN_SECTION") && ADMIN_SECTION !=
"Y"))
1157 if (self::isInvalidationRequest())
1167 die(Engine::getAjaxError(
"invalidation_request_locked"));
1171 self::setUseHTMLCache();
1174 if (isset($options[
"AUTO_UPDATE"]) && $options[
"AUTO_UPDATE"] ===
"N")
1176 self::setAutoUpdate(
false);
1179 if (isset($options[
"AUTO_UPDATE_TTL"]))
1181 self::setAutoUpdateTTL($options[
"AUTO_UPDATE_TTL"]);
1184 define(
"BX_SKIP_SESSION_EXPAND",
true);
1189 $result = Logger::log(array(
1195 if ($result && $result->getId())
1197 $recordId = $result->getId();
1199 $eventManager->addEventHandler(
"main",
"OnEpilog",
function() use($recordId) {
1200 if (is_object(
$GLOBALS[
"APPLICATION"]))
1202 Debug\Model\LogTable::update($recordId, array(
1203 "TITLE" =>
$GLOBALS[
"APPLICATION"]->getTitle()
1211 (defined(
"ENABLE_HTML_STATIC_CACHE_JS") && ENABLE_HTML_STATIC_CACHE_JS ===
true) &&
1212 (!defined(
"ADMIN_SECTION") || ADMIN_SECTION !==
true)
1215 \CJSCore::init(array(
"fc"));
1231 $GLOBALS[
"APPLICATION"]->showPanelWasInvoked ===
true &&
1232 self::getUseHTMLCache() &&
1233 !self::isAjaxRequest() &&
1234 \CTopPanel::shouldShowPanel()
1237 self::setEnable(
false);
1241 "TYPE" => Logger::TYPE_ADMIN_PANEL,
1253 if (Configuration::getValue(
"force_enable_self_hosted_composite") ===
true)
1263 public static function install($setDefaults =
true)
1267 $eventManager->registerEventHandler(
"main",
"OnEpilog",
"main",
"\\".__CLASS__,
"onEpilog");
1268 $eventManager->registerEventHandler(
"main",
"OnLocalRedirect",
"main",
"\\".__CLASS__,
"onEpilog");
1269 $eventManager->registerEventHandler(
"main",
"OnChangeFile",
"main",
"\\".__CLASS__,
"onChangeFile");
1272 if ($setDefaults ===
true)
1278 if (!$file->isExists())
1280 $file->putContents(
"");
1288 $eventManager->unRegisterEventHandler(
"main",
"OnEpilog",
"main",
"\\".__CLASS__,
"onEpilog");
1289 $eventManager->unRegisterEventHandler(
"main",
"OnLocalRedirect",
"main",
"\\".__CLASS__,
"onEpilog");
1290 $eventManager->unRegisterEventHandler(
"main",
"OnChangeFile",
"main",
"\\".__CLASS__,
"onChangeFile");
1318 global $USER, $APPLICATION;
1320 if (is_object($USER) && $USER->IsAuthorized())
1322 if (self::isCurrentUserCC())
1324 if ($APPLICATION->get_cookie(
"CC") !==
"Y" || $APPLICATION->get_cookie(
"NCC") ===
"Y")
1331 if ($APPLICATION->get_cookie(
"NCC") !==
"Y" || $APPLICATION->get_cookie(
"CC") ===
"Y")
1339 if ($APPLICATION->get_cookie(
"NCC") ===
"Y" || $APPLICATION->get_cookie(
"CC") ===
"Y")
1341 self::deleteCompositeCookies();
1345 if (\
Bitrix\Main\Data\Cache::shouldClearCache())
1349 $queryString = DeleteParam(
1352 "clear_cache_session",
1353 "bitrix_include_areas",
1355 "show_page_exec_time",
1356 "show_include_exec_time",
1364 $uri =
new Uri($server->getRequestUri());
1365 $refinedUri = $queryString !=
"" ? $uri->getPath().
"?".$queryString : $uri->getPath();
1368 $cacheStorage->delete();
1383 foreach ($domains as $domain)
1385 $cacheStorage =
new Page($path, $domain);
1386 $cacheStorage->delete();
1402 if (self::isCurrentUserCC())
1419 self::deleteCompositeCookies();
1428 $groups = isset($options[
"GROUPS"]) && is_array($options[
"GROUPS"]) ? $options[
"GROUPS"] : array();
1431 $diff = array_diff($USER->GetUserGroupArray(), $groups);
1433 return empty($diff);
1441 global $APPLICATION;
1442 $APPLICATION->set_cookie(
"NCC",
"Y");
1443 $APPLICATION->set_cookie(
"CC",
"", 0);
1452 global $APPLICATION;
1453 $APPLICATION->set_cookie(
"CC",
"Y");
1454 $APPLICATION->set_cookie(
"NCC",
"", 0);
1457 $page->setUserPrivateKey();
1465 global $APPLICATION;
1466 $APPLICATION->set_cookie(
"NCC",
"", 0);
1467 $APPLICATION->set_cookie(
"CC",
"", 0);
1483 self::$autoUpdate = !$preventAutoUpdate;
1494 return !self::$autoUpdate;
1536 $id, $content, $stub =
"", $containerId =
null, $useBrowserStorage =
false,
1537 $autoUpdate =
true, $useAnimation =
false
1541 $area->setStub($stub);
1542 $area->setContainerId($containerId);
1543 $area->setBrowserStorage($useBrowserStorage);
1544 $area->setAutoUpdate($autoUpdate);
1545 $area->setAnimation($useAnimation);
1562 return $dynamicArea->startDynamicArea();
1581 $id, $stub =
"", $containerId =
null, $useBrowserStorage =
false,
1582 $autoUpdate =
true, $useAnimation =
false)
1585 if ($curDynamicArea ===
null || $curDynamicArea->getId() !== $id)
1590 $curDynamicArea->setStub($stub);
1591 $curDynamicArea->setContainerId($containerId);
1592 $curDynamicArea->setBrowserStorage($useBrowserStorage);
1593 $curDynamicArea->setAutoUpdate($autoUpdate);
1594 $curDynamicArea->setAnimation($useAnimation);
1596 return $curDynamicArea->finishDynamicArea();