public function loadConfig() { //todo fix empty config caching $cache = new \CPHPCache(); $cacheFile = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/cache/" . $cache->GetPath(__CLASS__); // проверяем, обновлялся ли конфиг $cacheWritten = filemtime($cacheFile); $configWritten = filemtime($this->configFile); // устаревший кеш или неудачно начатый кеш перезаписываем if ($configWritten > $cacheWritten || !$cache->InitCache(self::TTL, __CLASS__, '/')) { $cache->Clean(__CLASS__, '/'); try { parent::loadConfig(); if ($cache->StartDataCache(self::TTL, __CLASS__, '/')) { $cache->EndDataCache(array('config' => $this->config)); } else { _log('Caching failed', 'widgets'); } } catch (Exception $e) { _log('loading config error: ' . $e->getMessage(), 'widgets'); } } else { $vars = $cache->GetVars(); $this->config = $vars['config']; } }
function __blogcleartagsimportant($options, $cache_id, $cache_path) { $obCache = new CPHPCache; if ($cache_id != "") $obCache->Clean($cache_id, $cache_path); else $obCache->CleanDir($cache_path); }
/** * @param $name * @param $value * @param int $time */ public function set($name, $value, $time = 3600) { $cache = new \CPHPCache(); list($dir, $name) = $this->dirAndName($name); $cache->InitCache($time, $name, $dir); $cache->Clean($name, $dir); $cache->StartDataCache(); $cache->EndDataCache(array('value' => $value)); }
public static function Clean($uniq_str, $initdir = false, $basedir = "cache") { if (is_object($this) && $this instanceof CPHPCache) { return $this->cache->clean($uniq_str, $initdir, $basedir); } else { $obCache = new CPHPCache(); return $obCache->Clean($uniq_str, $initdir, $basedir); } }
function Set($user_id, $type) { global $DB; $user_id = intval($user_id); if ($user_id <= 0) { return false; } if ($type != "Y") { $type = "N"; } $strSQL = "\n\t\t\tINSERT INTO b_sonet_log_smartfilter (USER_ID, TYPE)\n\t\t\tVALUES (" . $user_id . ", '" . $type . "')\n\t\t\tON DUPLICATE KEY UPDATE TYPE = '" . $type . "'\n\t\t"; $res = $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); if ($res) { CPHPCache::Clean('sonet_smartfilter_default_' . $user_id, '/sonet/log_smartfilter/'); } }
static function Add($arFields) { global $DB; if (!self::CheckFields('ADD', $arFields)) { return false; } $arInsert = $DB->PrepareInsert("b_socialservices_user", $arFields); $strSql = "INSERT INTO b_socialservices_user (" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $res = $DB->Query($strSql, true, "File: " . __FILE__ . "<br>Line: " . __LINE__); if (!$res) { $_SESSION["LAST_ERROR"] = GetMessage("SC_ADD_ERROR"); return false; } $lastId = intval($DB->LastID()); $cache_id = 'socserv_ar_user'; $obCache = new CPHPCache(); $cache_dir = '/bx/socserv_ar_user'; $obCache->Clean($cache_id, $cache_dir); $events = GetModuleEvents("socialservices", "OnAfterSocServUserAdd"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array(&$arFields)); } return $lastId; }
static function CanAccessFiles($iblock_id, $entity_type, $entity_id) { $result = false; $iblock_id = intval($iblock_id); $entity_id = intval($entity_id); if ($iblock_id > 0 && $entity_id > 0 && ($entity_type == 'group' || $entity_type == 'user')) { //cache $value = false; static $data = array(); $CACHE_PATH = "/" . SITE_ID . "/webdav/can_access_files"; $CACHE_ID = $iblock_id; $CACHE_TIME = 3600 * 24 * 30; $docCache = new CPHPCache(); if (!isset($data[$iblock_id])) { if ($docCache->InitCache($CACHE_TIME, $CACHE_ID, $CACHE_PATH)) { $value = $docCache->GetVars(); } $data[$iblock_id] = $value; } if (isset($data[$iblock_id][$entity_type][$entity_id])) { return $data[$iblock_id][$entity_type][$entity_id]; } //end cache CModule::IncludeModule('iblock'); $rIB = CIBlock::GetList(array(), array('ID' => $iblock_id, "CHECK_PERMISSIONS" => "N")); if ($rIB && ($arIB = $rIB->Fetch()) && $arIB["RIGHTS_MODE"] === "E") { $rootSectionID = self::GetSectionID($iblock_id, $entity_type, $entity_id); if ($rootSectionID !== false) { $ibRights = new CIBlockSectionRights($iblock_id, $rootSectionID); $result = $ibRights->UserHasRightTo($iblock_id, $rootSectionID, 'section_read'); if (!$result) { $arParams = array("DOCUMENT_TYPE" => array("webdav", "CIBlockDocumentWebdavSocnet", implode("_", array("iblock", $iblock_id, $entity_type, $entity_id))), "ROOT_SECTION_ID" => $rootSectionID, "ATTRIBUTES" => $entity_type == "user" ? array('user_id' => $entity_id) : array('group_id' => $entity_id)); $ob = new CWebDavIblock($iblock_id, '', $arParams); if ($ob && empty($ob->arError) && $ob->permission > 'D') { $files = array(); $options = array("path" => '/', "depth" => 1); $res = $ob->PROPFIND($options, $files, array("return" => "array")); $result = is_array($res) && sizeof($res['RESULT']) > 0; // at least 1 item can be read } } } else { return true; } } else { $result = CIBlock::GetPermission($iblock_id) > "D"; } // cache if ($data[$iblock_id] === false) { $data[$iblock_id] = array(); } $data[$iblock_id][$entity_type][$entity_id] = $result; $docCache->Clean($CACHE_ID, $CACHE_PATH); $docCache->InitCache($CACHE_TIME, $CACHE_ID, $CACHE_PATH); if ($docCache->StartDataCache()) { global $CACHE_MANAGER; $CACHE_MANAGER->StartTagCache($CACHE_PATH); $CACHE_MANAGER->RegisterTag("iblock_id_" . $iblock_id); $CACHE_MANAGER->RegisterTag('wd_socnet'); $CACHE_MANAGER->EndTagCache(); $docCache->EndDataCache($data[$iblock_id]); } // end cache } return $result; }
static function Add($arFields) { global $DB; if (!self::CheckFields('ADD', $arFields)) { return false; } $arInsert = $DB->PrepareInsert("b_socialservices_message", $arFields); $strSql = "INSERT INTO b_socialservices_message (" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $res = $DB->Query($strSql, true, "File: " . __FILE__ . "<br>Line: " . __LINE__); if (!$res) { return false; } $lastId = intval($DB->LastID()); $cache_id = 'socserv_mes_user'; $obCache = new CPHPCache(); $cache_dir = '/bx/socserv_mes_user'; $obCache->Clean($cache_id, $cache_dir); return $lastId; }
static function Delete($id) { global $DB; $id = intval($id); if ($id > 0) { $rsUser = $DB->Query("SELECT ID FROM b_socialservices_message WHERE ID=" . $id); $arUser = $rsUser->Fetch(); if (!$arUser) { return false; } /* $db_events = GetModuleEvents("socialservices", "OnBeforeSocServUserDelete"); while($arEvent = $db_events->Fetch()) ExecuteModuleEventEx($arEvent, array($id));*/ $DB->Query("DELETE FROM b_socialservices_message WHERE ID = " . $id . " ", true); $cache_id = 'socserv_mes_user'; $obCache = new CPHPCache(); $cache_dir = '/bx/socserv_mes_user'; $obCache->Clean($cache_id, $cache_dir); return true; } return false; }
function Save() { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) { return; } global $DB; if (!$this->cleanSet || !$this->cleanGet && count($this->values) >= $this->len) { $objCache = new CPHPCache(); $objCache->Clean($this->entity, $DB->type . "/" . $this->entity, "stack_cache"); if ($objCache->StartDataCache($this->ttl, $this->entity, $DB->type . "/" . $this->entity, $this->values, "stack_cache")) { $objCache->EndDataCache(); } $this->cleanGet = true; $this->cleanSet = true; } }
static function CleanChatCache($userId) { $bColorEnabled = IM\Color::isEnabled(); $cache_id = 'im_chats_v4_' . $userId . '_' . $bColorEnabled; $obCLCache = new CPHPCache(); $cache_dir = '/bx/imc/chats'; $obCLCache->Clean($cache_id, $cache_dir); }
return $arIBlockSection; } } return false; } foreach ($arResult["CATEGORIES"] as $category_id => $arCategory) { foreach ($arCategory["ITEMS"] as &$arItem) { $pathResizeImage = NULL; $image = NULL; $arElement = NULL; $section = NULL; $arIBlockSection = NULL; if (CModule::IncludeModule("iblock")) { $cache_id = 'ajax-search-w' . $arItem['ITEM_ID']; if ($_REQUEST["clear_cache"] == "Y") { CPHPCache::Clean($cache_id, "/"); } if ($obCache->InitCache($arParams["CACHE_TIME"], $cache_id, "/")) { $vars = $obCache->GetVars(); $pathResizeImage = $vars["PRODUCT_PICTURE_SRC"]; $section = $vars["SECTION"]; } else { if ($arItem['ITEM_ID'][0] == "S") { $section = array(); $section_id = intval(substr($arItem['ITEM_ID'], 1)); $arIBlockSection = GetIBlockSection2($section_id); $image = CFile::GetFileArray($arIBlockSection["PICTURE"]); $image = $image["SRC"]; if (!$image) { $section["NOT_IMAGE"] = true; }
static function Delete($id) { global $DB; $id = intval($id); if ($id > 0) { $rsUser = $DB->Query("SELECT ID FROM b_socialservices_message WHERE ID=".$id); $arUser = $rsUser->Fetch(); if(!$arUser) return false; $DB->Query("DELETE FROM b_socialservices_message WHERE ID = ".$id." ", true); $cache_id = 'socserv_mes_user'; $obCache = new CPHPCache; $cache_dir = '/bx/socserv_mes_user'; $obCache->Clean($cache_id, $cache_dir); return true; } return false; }
static function CleanChatCache($userId) { $cache_id = 'im_contact_list_chats_' . $userId . '_v1'; $obCLCache = new CPHPCache(); $cache_dir = '/bx/imc/chats'; $obCLCache->Clean($cache_id, $cache_dir); }
BXTIMEMAN.WND.SOCSERV_WND = new BX.SocservTimeman(); BXTIMEMAN.WND.SOCSERV_WND.showWnd(); }); <? } } elseif($_REQUEST['action'] == "saveuserdata") { if(isset($_POST["ENABLED"])) { $userSocServSendEnable = $_POST["ENABLED"]; CUserOptions::SetOption("socialservices","user_socserv_enable",$userSocServSendEnable, false, $userId); $cache_id = 'socserv_user_option_'.$userId; $obCache = new CPHPCache; $cache_dir = '/bx/socserv_user_option'; $obCache->Clean($cache_id, $cache_dir); } else { $arUserSocServ = ''; $userSocServSendEnable = $userSocServSendStart = $userSocServSendEnd = 'N'; $userSocServEndText = GetMessage("JS_CORE_SS_WORKDAY_END"); $userSocServStartText = GetMessage("JS_CORE_SS_WORKDAY_START"); if(isset($_POST["SOCSERVARRAY"]) && !empty($_POST["SOCSERVARRAY"])) $arUserSocServ = serialize($_POST["SOCSERVARRAY"]); if(isset($_POST["STARTSEND"])) $userSocServSendStart = $_POST["STARTSEND"]; if(isset($_POST["ENDSEND"])) $userSocServSendEnd = $_POST["ENDSEND"]; if(isset($_POST["STARTTEXT"])) $userSocServStartText = $_POST["STARTTEXT"];
public static function CleanChatCache($userId) { $bColorEnabled = IM\Color::isEnabled(); $bOpenChatEnabled = CIMMessenger::CheckEnableOpenChat(); $cache_id = 'im_chats_v7_' . $userId . '_' . $bColorEnabled . '_' . $bOpenChatEnabled; $cache_dir = '/bx/imc/chats'; $obCLCache = new CPHPCache(); $obCLCache->Clean($cache_id, $cache_dir); }
$arCacheID = array("filter" => array_merge($arParams["FILTER"], $dfc === true ? array("<=DATE_PUBLISH" => "") : array()), $arParams["SORT"], array_intersect_key($arParams["PAGE_SETTINGS"], array("bDescPageNumbering" => false, "nPageSize" => 10)), CTimeZone::GetOffset(), $USER->GetID()); $cache_id = "blog_blog_" . md5(serialize($arCacheID)); /******************************************************************** Actions ********************************************************************/ if (is_array($_REQUEST["options"]) && !empty($_REQUEST["options"]) && check_bitrix_sessid() && $USER->IsAuthorized() && CModule::IncludeModule("blog")) { foreach ($_REQUEST["options"] as $val) { CBlogUserOptions::SetOption($val["post_id"], $val["name"], $val["value"], $USER->GetID()); } if (defined("BX_COMP_MANAGED_CACHE")) { $CACHE_MANAGER->ClearByTag($val["name"] . $val["post_id"]); $CACHE_MANAGER->ClearByTag($val["name"] . $val["post_id"] . "_" . $USER->GetID()); $CACHE_MANAGER->ClearByTag($val["name"] . "_USER_" . $USER->GetID()); } else { $obCache = new CPHPCache(); $obCache->Clean($cache_id, $cache_path); } $db_events = GetModuleEvents("socialnetwork", "OnAfterCBlogUserOptionsSet"); while ($arEvent = $db_events->Fetch()) { ExecuteModuleEventEx($arEvent, array($_REQUEST["options"], $cache_id, $cache_path)); } } /******************************************************************** /Actions ********************************************************************/ if ($_REQUEST["return"] == "users") { include str_replace(array("\\", "//"), "/", __DIR__ . "/") . "users.php"; } elseif ($PAGEN == null && $arParams["CACHE_TIME"] > 0) { if ($cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path)) { $arRes = $cache->GetVars(); $arResult["POST"] = $arRes["POST"];
$arResult['A_NAME'] = $_POST['AUTHOR_NAME']; $arResult['EMAIL'] = $_POST['EMAIL']; $arResult['TEXT'] = $_POST['COMMENT']; $_SESSION['ISERROR_TOCACHE'] = true; // @todo check this (clear cache for captcha) $uniq_str1 = serialize(array($arParams['OBJECT_ID'], true, false)); $uniq_str2 = serialize(array($arParams['OBJECT_ID'], false, false)); $uniq_str3 = serialize(array($arParams['OBJECT_ID'], false, true)); $uniq_str4 = serialize(array($arParams['OBJECT_ID'], true, true)); CPHPCache::Clean($uniq_str1, $cache_path); CPHPCache::Clean($uniq_str2, $cache_path); CPHPCache::Clean($uniq_str3, $cache_path); CPHPCache::Clean($uniq_str4, $cache_path); } else { $_POST['COMMENT'] = nl2br($_POST['COMMENT']); if(CTreelikeComments::StopWordExists($_POST['COMMENT'])) $arResult['ERRORS']['STOP_WORD'] = GetMessage('STOP_WORD_EXIST'); if($arResult['ALLOW_SMILES'] == 1) $_POST['COMMENT'] = TreelikeCommentsSetSmiles($_POST['COMMENT'], array( ":)" => "smile.png", ":D" => "xd.png", ":(" => "sad.png",
/** * @param $name * @param $property_fields * @param $values * @return bool|string */ function _ShowGroupPropertyFieldList($name, $property_fields, $values) { if (!is_array($values)) { $values = array(); } static $linkIblockId; static $sections = null; $res = ""; $result = ""; $bWas = false; $ttl = 10000; $cache_id = 'catalog_store_sections'; $obCache = new CPHPCache(); $cache_dir = '/bx/catalog_store_sections'; if (!$linkIblockId || $property_fields["LINK_IBLOCK_ID"] != $linkIblockId) { $linkIblockId = $property_fields["LINK_IBLOCK_ID"]; if (intval($linkIblockId) <= 0) { return false; } $obCache->Clean($cache_id, $cache_dir); } if ($obCache->InitCache($ttl, $cache_id, $cache_dir)) { $res = $obCache->GetVars(); } else { if ($sections === null) { $sections = CIBlockSection::GetTreeList(array("IBLOCK_ID" => $linkIblockId)); } while ($ar = $sections->GetNext()) { $res .= '<option value="' . $ar["ID"] . '"'; if (in_array($ar["ID"], $values)) { $bWas = true; $res .= ' selected'; } $res .= '>' . str_repeat(" . ", $ar["DEPTH_LEVEL"]) . $ar["NAME"] . '</option>'; } if ($obCache->StartDataCache()) { $obCache->EndDataCache($res); } } $result .= '<select name="' . $name . '[]" size="' . ($property_fields["MULTIPLE"] == "Y" ? "5" : "1") . '" ' . ($property_fields["MULTIPLE"] == "Y" ? "multiple" : "") . '>'; $result .= '<option value=""' . (!$bWas ? ' selected' : '') . '>' . GetMessage("SPS_A_PROP_NOT_SET") . '</option>'; $result .= $res; $result .= '</select>'; return $result; }
if (!isset($arFiltersCount[$roleFilter][$key])) { $arFiltersCount[$roleFilter][$key] = CTasks::GetCountInt(array_merge($f["FILTER"], $arParams["COMMON_FILTER"], $preDefinedFilterRole[$roleFilter]["FILTER"])); $changed = true; } $preDefinedFilterStatus[$key]["COUNT"] = $arFiltersCount[$roleFilter][$key]; } if (!isset($arFiltersCount[4][1])) { $arFiltersCount[4][1] = CTasks::GetCountInt(array_merge($arPreDefindFilters["STATUS"][1][1]["FILTER"], $arParams["COMMON_FILTER"], $preDefinedFilterRole[4]["FILTER"])); $changed = true; } $arResult["EXTRA_COUNT"][0] = $arFiltersCount[4][1]; if (!isset($arFiltersCount[4][2])) { $arFiltersCount[4][2] = CTasks::GetCountInt(array_merge($arPreDefindFilters["STATUS"][1][2]["FILTER"], $arParams["COMMON_FILTER"], $preDefinedFilterRole[4]["FILTER"])); $changed = true; } $arResult["EXTRA_COUNT"][1] = $arFiltersCount[4][2]; } if (defined('BX_COMP_MANAGED_CACHE') && $changed) { $obCache->Clean($cacheID, $cacheDir); if ($obCache->StartDataCache()) { global $CACHE_MANAGER; $CACHE_MANAGER->StartTagCache($cacheDir); foreach ($arCacheTags as $cacheTag) { $CACHE_MANAGER->RegisterTag($cacheTag); } $CACHE_MANAGER->EndTagCache(); $obCache->EndDataCache($arFiltersCount); } } $arResult["PREDEFINED_FILTERS"] = array("ROLE" => $preDefinedFilterRole, "STATUS" => $preDefinedFilterStatus); $this->IncludeComponentTemplate();