Example #1
0
 public function testUncompressBadInput()
 {
     // Bad data is missing the Horde-LZ4 header and is not LZ4 data.
     $bad_data = "12345678";
     $this->assertFalse(horde_lz4_uncompress($bad_data));
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
File: Lz4.php Project: horde/horde
 /**
  */
 public function decompress($text)
 {
     return strlen($text) ? @horde_lz4_uncompress($text) : '';
 }