function CheckCacheFiles_Rec($strDir) { global $iGoodNum, $iOldNum, $iEmptyDirNum, $dLog; if ($handle = @opendir($strDir)) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") continue; if (is_dir($strDir."/".$file)) { CheckCacheFiles_Rec($strDir."/".$file); } elseif (is_file($strDir."/".$file)) { $ext = ""; $ext_pos = bxstrrpos($file, "."); if ($ext_pos!==false) $ext = substr($file, $ext_pos + 1); $bCacheExp = False; if ($ext=="html") $bCacheExp = CPageCache::IsCacheExpired($strDir."/".$file); elseif ($ext=="php") $bCacheExp = CPHPCache::IsCacheExpired($strDir."/".$file); if ($bCacheExp) { $iOldNum++; @unlink($strDir."/".$file); } else { $iGoodNum++; } } } @closedir($handle); } clearstatcache(); $bEmptyFolder = True; if ($handle = @opendir($strDir)) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") continue; $bEmptyFolder = False; break; } } if ($bEmptyFolder) { $iEmptyDirNum++; @rmdir($strDir); } }
public static function getJS($arJS, $type, $cacheTime = 86400) { // Cache timelife if ($cacheTime) { self::$CACHE_TIME = $cacheTime; } $cachedFile = self::getCacheKey($arJS) . ".js"; // Get cache file name if (!self::validateCache($cachedFile)) { // If cache is valid // Clear old cache self::clearCache(); // Create new cache file self::createCacheFile($cachedFile, $arJS); } // Return file switch ($type) { case "internal": return '<script>' . self::getFileSource(self::getCacheFilePath($cachedFile)) . '</script>'; break; case "external": return '<script src="' . self::getCacheFilePath($cachedFile, false) . '"></script>'; break; } }
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; __IncludeLang(dirname(__FILE__) . "/lang/" . LANGUAGE_ID . "/getdata.php"); if (!check_bitrix_sessid()) { return; } $rnd = $_REQUEST["rnd"]; include_once dirname(__FILE__) . '/include.php'; if (!array_key_exists("GD_RSS_PARAMS", $_SESSION) || !array_key_exists($rnd, $_SESSION["GD_RSS_PARAMS"]) || !is_array($_SESSION["GD_RSS_PARAMS"][$rnd])) { return; } $arGadgetParams = $_SESSION["GD_RSS_PARAMS"][$rnd]; $arGadgetParams["CNT"] = IntVal($arGadgetParams["CNT"]); if ($arGadgetParams["CNT"] > 50) { $arGadgetParams["CNT"] = 0; } $cache = new CPageCache(); if ($arGadgetParams["CACHE_TIME"] > 0 && !$cache->StartDataCache($arGadgetParams["CACHE_TIME"], 'c' . $arGadgetParams["RSS_URL"] . '-' . $arGadgetParams["CNT"], "gdrss")) { return; } if ($arGadgetParams["RSS_URL"] == "") { ?> <div class="gdrsserror"> <?php echo GetMessage("GD_RSS_READER_NEW_RSS"); ?> </div> <?php $cache->EndDataCache(); return; } session_write_close();
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/classes/general/xml.php'; $APPLICATION->SetAdditionalCSS('/bitrix/gadgets/bitrix/probki/styles.css'); if ($arGadgetParams["CITY"] != '') { $url = 'yasoft=barff®ion=' . substr($arGadgetParams["CITY"], 1) . '&ts=' . mktime(); } else { $url = 'ts=' . mktime(); } $cache = new CPageCache(); if ($arGadgetParams["CACHE_TIME"] > 0 && !$cache->StartDataCache($arGadgetParams["CACHE_TIME"], 'c' . $arGadgetParams["CITY"], "gdprobki")) { return; } $ob = new CHTTP(); $ob->http_timeout = 10; $ob->Query("GET", "export.yandex.ru", 80, "/bar/reginfo.xml?" . $url, false, "", "N"); $errno = $ob->errno; $errstr = $ob->errstr; $res = $ob->result; $res = str_replace("−", "-", $res); $xml = new CDataXML(); $xml->LoadString($APPLICATION->ConvertCharset($res, 'UTF-8', SITE_CHARSET)); $node = $xml->SelectNodes('/info/traffic/title'); ?> <h3><?php echo $node->content; ?> </h3>
**************************************************************************/ IncludeTemplateLangFile(__FILE__); $IBLOCK_TYPE = strlen($IBLOCK_TYPE) > 0 ? $IBLOCK_TYPE : "news"; $IBLOCK_SORT_BY = isset($IBLOCK_SORT_BY) ? $IBLOCK_SORT_BY : "SORT"; $IBLOCK_SORT_ORDER = isset($IBLOCK_SORT_ORDER) ? $IBLOCK_SORT_ORDER : "ASC"; $IBLOCK_SORT = array($IBLOCK_SORT_BY => $IBLOCK_SORT_ORDER); $NEWS_COUNT = strlen($NEWS_COUNT) > 0 ? intval($NEWS_COUNT) : "5"; $SORT_BY1 = isset($SORT_BY1) ? $SORT_BY1 : "ACTIVE_FROM"; $SORT_ORDER1 = isset($SORT_ORDER1) ? $SORT_ORDER1 : "DESC"; $SORT_BY2 = isset($SORT_BY2) ? $SORT_BY2 : "SORT"; $SORT_ORDER2 = isset($SORT_ORDER2) ? $SORT_ORDER2 : "ASC"; $SORT = array($SORT_BY1 => $SORT_ORDER1, $SORT_BY2 => $SORT_ORDER2); $CACHE_TIME = intval($CACHE_TIME); $CACHE_ID = SITE_ID . "|" . $APPLICATION->GetCurPage() . "|" . md5(serialize($arParams)) . "|" . $USER->GetGroups(); $APPLICATION->SetTitle(GetMessage("T_NEWS_INDEX_TITLE")); $cache = new CPageCache(); if ($cache->StartDataCache($CACHE_TIME, $CACHE_ID)) { if (!CModule::IncludeModule("iblock")) { echo ShowError(GetMessage("T_NEWS_INDEX_MODULE_NA")); } else { //if(!CModule::IncludeModule("iblock")): $iblocks = GetIBlockList($IBLOCK_TYPE, array(), array(), $IBLOCK_SORT); while ($arIBlock = $iblocks->GetNext()) { ?> <font class="text"> <a href="<?php echo $arIBlock["LIST_PAGE_URL"]; ?> "><b><?php echo $arIBlock["NAME"]; ?>
function InitCache($TTL, $uniq_str, $initdir = false, $basedir = "cache") { /** @global CMain $APPLICATION */ global $APPLICATION, $USER; if ($initdir === false) { $initdir = $APPLICATION->GetCurDir(); } $this->basedir = BX_PERSONAL_ROOT . "/" . $basedir . "/"; $this->initdir = $initdir; $this->filename = "/" . CPageCache::GetPath($uniq_str); $this->TTL = $TTL; $this->uniq_str = $uniq_str; if ($TTL <= 0) { return false; } if (is_object($USER) && $USER->CanDoOperation('cache_control')) { if (isset($_GET["clear_cache_session"])) { if (strtoupper($_GET["clear_cache_session"]) == "Y") { $_SESSION["SESS_CLEAR_CACHE"] = "Y"; } elseif (strlen($_GET["clear_cache_session"]) > 0) { unset($_SESSION["SESS_CLEAR_CACHE"]); } } if (isset($_GET["clear_cache"]) && strtoupper($_GET["clear_cache"]) == "Y") { return false; } } if (isset($_SESSION["SESS_CLEAR_CACHE"]) && $_SESSION["SESS_CLEAR_CACHE"] == "Y") { return false; } if (!$this->_cache->read($this->content, $this->basedir, $this->initdir, $this->filename, $this->TTL)) { return false; } // $GLOBALS["CACHE_STAT_BYTES"] += $this->_cache->read; if (\Bitrix\Main\Data\Cache::getShowCacheStat()) { $read = 0; $path = ''; if ($this->_cache instanceof \Bitrix\Main\Data\ICacheEngineStat) { $read = $this->_cache->getReadBytes(); $path = $this->_cache->getCachePath(); } elseif ($this->_cache instanceof \ICacheBackend) { /** @noinspection PhpUndefinedFieldInspection */ $read = $this->_cache->read; /** @noinspection PhpUndefinedFieldInspection */ $path = $this->_cache->path; } \Bitrix\Main\Diag\CacheTracker::addCacheStatBytes($read); \Bitrix\Main\Diag\CacheTracker::add($read, $path, $this->basedir, $this->initdir, $this->filename, "R"); } return true; }
function InitCache($TTL, $uniq_str, $initdir = false, $basedir = "cache") { global $APPLICATION, $USER; if ($initdir === false) { $initdir = $APPLICATION->GetCurDir(); } $this->basedir = BX_PERSONAL_ROOT . "/" . $basedir . "/"; $this->initdir = $initdir; $this->filename = "/" . CPageCache::GetPath($uniq_str); $this->TTL = $TTL; $this->uniq_str = $uniq_str; if ($TTL <= 0) { return false; } if (is_object($USER) && $USER->CanDoOperation('cache_control')) { if (isset($_GET["clear_cache_session"])) { if (strtoupper($_GET["clear_cache_session"]) == "Y") { $_SESSION["SESS_CLEAR_CACHE"] = "Y"; } elseif (strlen($_GET["clear_cache_session"]) > 0) { unset($_SESSION["SESS_CLEAR_CACHE"]); } } if (isset($_GET["clear_cache"]) && strtoupper($_GET["clear_cache"]) == "Y") { return false; } } if (isset($_SESSION["SESS_CLEAR_CACHE"]) && $_SESSION["SESS_CLEAR_CACHE"] == "Y") { return false; } if (!$this->_cache->read($this->content, $this->basedir, $this->initdir, $this->filename, $this->TTL)) { return false; } $GLOBALS["CACHE_STAT_BYTES"] += $this->_cache->read; return true; }
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die(); $arParams["IBLOCK_TYPE"] = trim($arParams["IBLOCK_TYPE"]); $arParams["IBLOCK_ID"] = intval($arParams["IBLOCK_ID"]); $arParams["ELEMENT_COUNT"] = intval($arParams["ELEMENT_COUNT"]); if (empty($arParams["OFFERS_SORT_FIELD"])) $arParams["OFFERS_SORT_FIELD"] = "sort"; if (!preg_match('/^(asc|desc|nulls)(,asc|,desc|,nulls){0,1}$/i', $arParams["OFFERS_SORT_ORDER"])) $arParams["OFFERS_SORT_ORDER"] = "asc"; if (empty($arParams["ELEMENT_COUNT"])) $arParams["ELEMENT_COUNT"] = ""; if(CModule::IncludeModule('iblock')&&CModule::IncludeModule("catalog")) { $cache = new CPageCache(); $arSort= Array($arParams["OFFERS_SORT_FIELD"]=>$arParams["OFFERS_SORT_ORDER"]); $arSelect = Array("ID","NAME","DETAIL_PAGE_URL","DETAIL_PICTURE","PREVIEW_TEXT"); $arFilter = Array("IBLOCK_TYPE"=>$arParams["IBLOCK_TYPE"],"IBLOCK_ID"=>$arParams["IBLOCK_ID"], "ACTIVE"=>"Y"); if(!empty($arParams["SECTION_ID"])) { if($arParams["INCLUDE_SUBSECTIONS"]=="Y") { $arFilter = Array("IBLOCK_TYPE"=>$arParams["IBLOCK_TYPE"],"IBLOCK_ID"=>$arParams["IBLOCK_ID"],"SECTION_ID"=>$arParams["SECTION_ID"], "INCLUDE_SUBSECTIONS" => "Y", "ACTIVE"=>"Y"); } else { $arFilter = Array("IBLOCK_TYPE"=>$arParams["IBLOCK_TYPE"],"IBLOCK_ID"=>$arParams["IBLOCK_ID"],"SECTION_ID"=>$arParams["SECTION_ID"], "ACTIVE"=>"Y"); } }