public function __construct($epub_file, $uploadPath) { $this->uploadPath = $uploadPath; $this->id = uniqid(); $filter = new Decompress(array('adapter' => 'Zip', 'options' => array('target' => $this->uploadPath . 'temp/' . $this->id, 'archive' => $epub_file))); deleteDir($this->uploadPath . 'temp/' . $this->id); mkdir($this->uploadPath . 'temp/' . $this->id); $filter->filter($epub_file); }
public function testFilterMethodProxiesToDecompress() { $filter = new DecompressFilter('bz2'); $archive = __DIR__ . '/../_files/compressed.bz2'; $filter->setArchive($archive); $content = $filter->compress('compress me'); $this->assertTrue($content); $filter2 = new DecompressFilter('bz2'); $content2 = $filter2->filter($archive); $this->assertEquals('compress me', $content2); }
/** * Defined by Zend_Filter_Interface * * Decrypts $value with the defined settings * * @param string $value Content to decrypt * @return string The decrypted content * @throws \Zend\Filter\Exception */ public function decrypt($value) { $decrypted = ""; $envelope = current($this->getEnvelopeKey()); if (count($this->_keys['private']) !== 1) { throw new Exception\RuntimeException('Please give a private key for decryption with Openssl'); } if (!$this->_package && empty($envelope)) { throw new Exception\RuntimeException('Please give an envelope key for decryption with Openssl'); } foreach($this->_keys['private'] as $key => $cert) { $keys = openssl_pkey_get_private($cert, $this->getPassphrase()); } if ($this->_package) { $details = openssl_pkey_get_details($keys); if ($details !== false) { $fingerprint = md5($details['key']); } else { $fingerprint = md5("ZendFramework"); } $count = unpack('ncount', $value); $count = $count['count']; $length = 2; for($i = $count; $i > 0; --$i) { $header = unpack('H32print/nsize', substr($value, $length, 18)); $length += 18; if ($header['print'] == $fingerprint) { $envelope = substr($value, $length, $header['size']); } $length += $header['size']; } // remainder of string is the value to decrypt $value = substr($value, $length); } $crypt = openssl_open($value, $decrypted, $envelope, $keys); openssl_free_key($keys); if ($crypt === false) { throw new Exception\RuntimeException('Openssl was not able to decrypt you content with the given options'); } // decompress after decryption if (!empty($this->_compression)) { $decompress = new Decompress($this->_compression); $decrypted = $decompress($decrypted); } // decompress after decryption if (!empty($this->_compression)) { require_once 'Zend/Filter/Decompress.php'; $decompress = new Decompress($this->_compression); $decrypted = $decompress->filter($decrypted); } return $decrypted; }