• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/backup.php
  • Класс: CTar
  • Вызов: CTar::openRead
function openRead($file)
{
	if (!isset($this->gzip) && (substr($file,-3)=='.gz' || substr($file,-4)=='.tgz'))
		$this->gzip = true;

	$this->BufferSize = 51200;

	if ($this->open($file, 'r'))
	{
		if ('' !== $str = $this->gzip ? gzread($this->res,512) : fread($this->res,512))
		{
			$data = unpack("a100empty/a90signature/a10version/a56tail/a256enc", $str);
			if (trim($data['signature']) != self::BX_SIGNATURE)
			{
				if (strlen($this->EncryptKey))
					$this->Error('Invalid encryption signature','ENC_SIGN');

				// Probably archive is not encrypted
				$this->gzip ? gzseek($this->res, 0) : fseek($this->res, 0);
				$this->EncryptKey = null;

				return $this->res;
			}

			$version = trim($data['version']);
			if (version_compare($version, '1.2', '>'))
				return $this->Error('Unsupported archive version: '.$version, 'ENC_VER');

			$key = $this->getEncryptKey();
			$this->BlockHeader = $this->Block = 1;

			if (!$key || substr($str, 0, 256) != self::decrypt($data['enc'], $key))
				return $this->Error('Invalid encryption key', 'ENC_KEY');
		}
	}
	return $this->res;
}