- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/data/cacheenginefiles.php
- Класс: BitrixMainDataCacheEngineFiles
- Вызов: CacheEngineFiles::read
public function read(&$vars, $baseDir, $initDir, $filename, $ttl)
{
$documentRoot = MainLoader::getDocumentRoot();
$fn = $documentRoot."/".ltrim($baseDir.$initDir, "/").$filename;
if (!file_exists($fn))
return false;
$ser_content = "";
$dateexpire = 0;
$datecreate = 0;
$zeroDanger = false;
$handle = null;
if (is_array($vars))
{
$INCLUDE_FROM_CACHE = 'Y';
if (!@include($fn))
return false;
}
else
{
$handle = fopen($fn, "rb");
if (!$handle)
return false;
$datecreate = fread($handle, 2);
if ($datecreate == "BX")
{
$datecreate = fread($handle, 12);
$dateexpire = fread($handle, 12);
}
else
{
$datecreate .= fread($handle, 10);
}
}
/* We suppress warning here in order not to break the compression under Zend Server */
$this->read = @filesize($fn);
$this->path = $fn;
$res = true;
if (intval($datecreate) < (time() - $ttl))
{
if ($this->useLock)
{
if ($this->lock($fn))
{
$res = false;
}
}
else
{
$res = false;
}
}
if($res == true)
{
if (is_array($vars))
{
$vars = unserialize($ser_content);
}
else
{
$vars = fread($handle, $this->read);
}
}
if($handle)
{
fclose($handle);
}
return $res;
}