/** * Decompress the given value with the specific compression * * @param String $sValue * * @return String * * @throws Exception */ public function decompress($sValue) { if (!is_string($sValue)) { throw new Exception('Invalid first argument, must be a string'); } return lzf_decompress($sValue); }
public function uncompress($data = '', $small = 0) { if (!isValue($data)) { return Error::set(lang('Error', 'valueParameter', '1.(data)')); } return lzf_decompress($data); }
/** * Decompresses the given content * * @param string $content * @return string */ public function decompress($content) { $compressed = lzf_decompress($content); if (!$compressed) { throw new Zend_Filter_Exception('Error during compression'); } return $compressed; }
/** * Decompresses the given content * * @param string $content * @return string * @throws Exception\RuntimeException if error occurs during decompression */ public function decompress($content) { $compressed = lzf_decompress($content); if (!$compressed) { throw new Exception\RuntimeException('Error during decompression'); } return $compressed; }
/** * Decompresses the given content * * @param string $content * @return string */ public function decompress($content) { $compressed = lzf_decompress($content); if (!$compressed) { require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception('Error during compression'); } return $compressed; }
/** * Decompresses the given content * * @param string $content * @return string */ public function decompress($content) { $compressed = lzf_decompress($content); if (!$compressed) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Filter/Exception.php'; throw new IfwPsn_Vendor_Zend_Filter_Exception('Error during compression'); } return $compressed; }
public function _decodeData($data) { switch (substr($data, 0, 4)) { // asking the data which library it uses allows for transparent changes of libraries case ':sn:': return snappy_uncompress(substr($data, 4)); case ':lz:': return lzf_decompress(substr($data, 4)); case ':gz:': return gzuncompress(substr($data, 4)); } return $data; }
/** * バックアップファイルの内容を圧縮形式に応じて取得する * TODO:gzとbz2解凍がスレッドセーフでない * @access private * * @return Array ファイルの内容 */ private function read_sub($ext, $join) { // ファイルを取得 $data = ''; switch ($ext) { case '.txt': $data = parent::get(); break; case '.lzf': $data = lzf_decompress(parent::get()); break; case '.gz': $handle = gzopen($this->filename, 'r'); while (!gzeof($handle)) { $data .= gzread($handle, 1024); } gzclose($handle); break; case '.bz2': $handle = bzopen($this->filename, 'r'); while (!feof($handle)) { $data .= bzread($handle, 1024); } bzclose($handle); break; } // 取得した内容を改行ごとに配列として返す return $join ? $data : explode("\n", $data); }
/** * Decompress data * * @param string $data * @return string * @throws Exception */ protected function decompress($data) { switch ($this->compression) { case self::COMPRESSION_LZ4: $decompressedData = @lz4_uncompress($data); if (false === $decompressedData) { throw new Exception('Error decompressing with lz4_uncompress.'); } break; case self::COMPRESSION_SNAPPY: $decompressedData = @snappy_uncompress($data); if (false === $decompressedData) { throw new Exception('Error decompressing with snappy_uncompress.'); } break; case self::COMPRESSION_LZF: $decompressedData = @lzf_decompress($data); if (false === $decompressedData) { throw new Exception('Error decompressing with lzf_decompress.'); } break; case self::COMPRESSION_GZ: $decompressedData = @gzuncompress($data); if (false === $decompressedData) { throw new Exception('Error decompressing with gzuncompress.'); } break; case self::COMPRESSION_NONE: default: $decompressedData = $data; } return $decompressedData; }
/** */ public function decompress($text) { return strlen($text) ? @lzf_decompress($text) : ''; }
/** * Return cached data. * * @param string $key Cache key. * * @return mixed Cache data, or false if not found. */ public function get($key) { if ($this->_mask & self::APC) { $data = apc_fetch($key); } elseif ($this->_mask & self::XCACHE) { $data = xcache_get($key); } elseif ($this->_mask & self::EACCELERATOR) { $data = eaccelerator_get($key); } elseif ($this->_mask & self::TEMPFILE) { $data = @file_get_contents($this->_tempdir . '/' . $key); if ($data === false) { unlink($this->_tempdir . '/' . $key); } } else { return false; } if ($data) { if ($this->_mask & self::LZ4) { $data = @horde_lz4_uncompress($data); } elseif ($this->_mask & self::LZF) { $data = @lzf_decompress($data); } } return $data === false ? false : $this->_mask & self::MSGPACK ? msgpack_unpack($data) : @json_decode($data, true); }
/** * @param bool|string $data * @return string */ protected function _decodeData($data) { if (substr($data, 2, 3) == self::COMPRESS_PREFIX) { switch (substr($data, 0, 2)) { case 'sn': return snappy_uncompress(substr($data, 5)); case 'lz': return lzf_decompress(substr($data, 5)); case 'gz': case 'zc': return gzuncompress(substr($data, 5)); } } return $data; }
/** * Unserialize data. * * @param mixed $data The data to be unserialized. * @param mixed $mode The mode of unserialization. Can be either a * single mode or array of modes. If array, will be * unserialized in the order provided. * @param mixed $params Any additional parameters the unserialization * method requires. * * @return mixed Unserialized data. * @throws Horde_Serialize_Exception */ protected static function _unserialize(&$data, $mode, $params = null) { switch ($mode) { case self::NONE: break; case self::RAW: $data = rawurldecode($data); break; case self::URL: $data = urldecode($data); break; case self::WDDX: $data = wddx_deserialize($data); break; case self::BZIP: // $params['small'] = Use bzip2 'small memory' mode? $data = bzdecompress($data, isset($params['small']) ? $params['small'] : false); break; case self::IMAP8: $data = quoted_printable_decode($data); break; case self::IMAPUTF7: $data = Horde_String::convertCharset(Horde_Imap_Client_Utf7imap::Utf7ImapToUtf8($data), 'UTF-8', 'ISO-8859-1'); break; case self::IMAPUTF8: $data = Horde_Mime::encode($data); break; case self::BASIC: $data2 = @unserialize($data); // Unserialize can return false both on error and if $data is the // false value. if ($data2 === false && $data == serialize(false)) { return $data2; } $data = $data2; break; case self::GZ_DEFLATE: $data = gzinflate($data); break; case self::BASE64: $data = base64_decode($data); break; case self::GZ_COMPRESS: $data = gzuncompress($data); break; // $params = Output character set // $params = Output character set case self::UTF7: $data = Horde_String::convertCharset($data, 'utf-7', $params); break; // $params = Output character set // $params = Output character set case self::UTF7_BASIC: $data = self::unserialize($data, array(self::BASIC, self::UTF7), $params); break; case self::JSON: $out = json_decode($data); if (!is_null($out) || strcasecmp($data, 'null') === 0) { return $out; } break; case self::LZF: $data = @lzf_decompress($data); break; } if ($data === false) { throw new Horde_Serialize_Exception('Unserialization failed.'); } return $data; }
/** * Static method to decompress data * * @param string $data * @return mixed */ public static function decompress($data) { return lzf_decompress($data); }
protected function decompress() { switch ($this->compress) { case self::COMPRESS_GZIP: $this->payload = gzinflate($this->payload); break; case self::COMPRESS_BZIP: $this->payload = bzdecompress($this->payload); break; case self::COMPRESS_LZF: $this->payload = lzf_decompress($this->payload); break; case self::COMPRESS_OFF: default: //anything but known values result in OFF break; } return true; }
/** * Public for testing purposes only. * * @param string $data * @return string */ public function _decodeData($data) { $this->profilerStart(__METHOD__); switch (substr($data, 0, 4)) { // asking the data which library it uses allows for transparent changes of libraries case ':sn:': $data = snappy_uncompress(substr($data, 4)); break; case ':lz:': $data = lzf_decompress(substr($data, 4)); break; case ':l4:': $data = lz4_uncompress(substr($data, 4)); break; case ':gz:': $data = gzuncompress(substr($data, 4)); break; } $this->profilerStop(__METHOD__); return $data; }
/** * Returns decoded image data * * @param string $data The image data * @param string $encoding The encoding type for the image data. * (none, base64, or binhex) * @param string $compression The compression type for the image data. * (none, gzip, or lzf) * @param boolean $upload Process direction (true of encode/compress or false if decode/decompress) * * @return string The decoded/encoded image data */ protected function _getImageData($data, $encoding = 'none', $compression = 'none', $upload = true) { switch ($encoding) { case 'base64': $data = $upload ? base64_decode($data) : base64_encode($data); break; case 'binhex': $data = $upload ? pack('H*', $data) : unpack('H*', $data); } switch ($compression) { case 'gzip': if (Horde_Util::loadExtension('zlib')) { return $upload ? gzuncompress($data) : gzcompress($data); } break; case 'lzf': if (Horde_Util::loadExtension('lzf')) { return $upload ? lzf_decompress($data) : lzf_compress($data); } break; default: return $data; } }
/** * Reads the socket * * @param bool $compress * * @return int|string */ protected function readSocket($compress = true) { $buffer = ''; do { if (time() - $this->timeStart > 100) { exit - 1; } $buf = socket_read($this->msgsock, 15 + 1024, PHP_BINARY_READ); if ($buf === false) { echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($this->msgsock)) . "\n"; return -2; } if (!trim($buf)) { return ''; } if (substr_count($buf, ":") < 3) { var_dump($buf); die('error in format'); } list($size, $block, $blocks) = explode(":", $buf); $aux = substr($buf, 15); if ($this->debug) { echo sprintf("%d/%d blocks (start of block %s)\n", $block, $blocks, substr($aux, 0, 10)); } if ($size == strlen($aux)) { $this->send(self::ACK); } else { $this->send(self::NO_ACK); die(sprintf('error in size (block %d of %d): informed %d vs %d read', $block, $blocks, $size, strlen($aux))); } $buffer .= $aux; } while ($block < $blocks); $this->received += strlen($buffer); $size = $this->prettySize($this->received); echo "v ", $size, " "; if ($compress) { if ($this->lzfUse) { $result = lzf_decompress($buffer); } else { $result = gzuncompress($buffer); } } else { $result = $buffer; } if ($this->debug) { $aux = json_decode($result, true); if (isset($aux['data'])) { //var_dump($aux); echo sprintf("received %d keys\n", count($aux['data'])); } } return $result; }
public function undo($data) { return lzf_decompress($data); }
public function Decompress($data) { $this->Check(); return lzf_decompress($data); }
/** * @param string $message * * @return string */ protected function uncompress($message) { return function_exists('lzf_compress') ? lzf_decompress($message) : gzuncompress($message); }
/** * Decode data * * @param string $data * @return string */ protected function _decodeData($data) { switch (substr($data, 0, 4)) { // asking the data which library it uses allows for transparent changes of libraries case ':sn:': $data = snappy_uncompress(substr($data, 4)); break; case ':lz:': $data = lzf_decompress(substr($data, 4)); break; case ':l4:': $data = lz4_uncompress(substr($data, 4)); break; case ':gz:': $data = gzuncompress(substr($data, 4)); break; } return $data; }
protected function readSocket() { $buffer = ''; $overload = strlen('000000:000:000:'); do { $buf = socket_read($this->socket, $overload + self::BLOCK_SIZE, PHP_BINARY_READ); if ($buf === false) { echo "socket_read() error: " . socket_strerror(socket_last_error($this->socket)) . "\n"; return -2; } if (!trim($buf)) { return ''; } if (substr_count($buf, ":") < 3) { var_dump($buf); die('error in format'); } list($size, $block, $blocks) = explode(":", $buf); $aux = substr($buf, $overload); if (self::DEBUG) { echo sprintf("%d/%d blocks (start of block %s)\n", $block, $blocks, substr($aux, 0, 10)); } else { echo 'R'; } if ($size == strlen($aux)) { $this->send(self::ACK); } else { $this->send(self::NO_ACK); die(sprintf('error in size (block %d of %d): informed %d vs %d read', $block, $blocks, $size, strlen($aux))); } $buffer .= $aux; } while ($block < $blocks); if (function_exists(self::LZF_FUNCTION)) { $result = lzf_decompress($buffer); } else { $result = gzuncompress($buffer); } if (self::DEBUG) { $aux = json_decode($result, true); if (isset($aux['data'])) { //var_dump($aux); echo sprintf("received %d keys\n", count($aux['data'])); } } return $result; }