public function compactarAction() { $v = new Zend_Filter_Compress(array('adapter' => 'Zip', 'options' => array('archive' => 'D:\\arquivo.zip'))); $compactar = $v->filter('D:\\css.zip'); var_dump($compactar); exit; }
public function descomprimir() { $filter = new Zend_Filter_Compress('Bz2'); $compressed = $filter->filter('a:2:{s:4:"type";s:15:"MultiLineString";s:11:"coordinates";a:1:{i:0;a:25:{i:0;a:2:{i:0;d:323073.5208;i:1;d:6410523.3888999997;}i:1;a:2:{i:0;d:323000.85610000044;i:1;d:6410506.2089999998;}i:2;a:2:{i:0;d:322934.71009999979;i:1;d:6410512.8235999998;}i:3;a:2:{i:0;d:322875.17879999988;i:1;d:6410559.1257999996;}i:4;a:2:{i:0;d:322795.80360000022;i:1;d:6410631.8864000002;}i:5;a:2:{i:0;d:322718.0833;i:1;d:6410696.3888999997;}i:6;a:2:{i:0;d:322689.11459999997;i:1;d:6410711.8888999997;}i:7;a:2:{i:0;d:322456.5208;i:1;d:6410836.8888999997;}i:8;a:2:{i:0;d:322402.1458;i:1;d:6410989.8888999997;}i:9;a:2:{i:0;d:322379.08399999997;i:1;d:6411041.9912999999;}i:10;a:2:{i:0;d:322332.7818;i:1;d:6411088.2934999997;}i:11;a:2:{i:0;d:322272.30209999997;i:1;d:6411109.3888999997;}i:12;a:2:{i:0;d:322220.33370000031;i:1;d:6411088.2934999997;}i:13;a:2:{i:0;d:322200.48990000039;i:1;d:6411088.2934999997;}i:14;a:2:{i:0;d:322154.18769999966;i:1;d:6411114.7518999996;}i:15;a:2:{i:0;d:322107.88559999969;i:1;d:6411154.4395000003;}i:16;a:2:{i:0;d:322054.96879999997;i:1;d:6411174.2833000002;}i:17;a:2:{i:0;d:321943.61459999997;i:1;d:6411188.8888999997;}i:18;a:2:{i:0;d:321863.14549999963;i:1;d:6411233.8146000002;}i:19;a:2:{i:0;d:321830.07249999978;i:1;d:6411286.7313999999;}i:20;a:2:{i:0;d:321783.77029999997;i:1;d:6411346.2627999997;}i:21;a:2:{i:0;d:321677.93680000026;i:1;d:6411366.1065999996;}i:22;a:2:{i:0;d:321605.17619999964;i:1;d:6411419.0232999995;}i:23;a:2:{i:0;d:321494.05209999997;i:1;d:6411447.3888999997;}i:24;a:2:{i:0;d:321387.3333;i:1;d:6411434.3888999997;}}}}'); $filter = new Zend_Filter_Decompress('Bz2'); $decompressed = $filter->filter($compressed); echo $decompressed; }
/** * Encrypts $value with the defined settings * Note that you also need the "encrypted" keys to be able to decrypt * * @param string $value Content to encrypt * @return string The encrypted content * @throws Zend_Filter_Exception */ public function encrypt($value) { $encrypted = array(); $encryptedkeys = array(); if (count($this->_keys['public']) == 0) { require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception('Openssl can not encrypt without public keys'); } $keys = array(); $fingerprints = array(); $count = -1; foreach ($this->_keys['public'] as $key => $cert) { $keys[$key] = openssl_pkey_get_public($cert); if ($this->_package) { $details = openssl_pkey_get_details($keys[$key]); if ($details === false) { $details = array('key' => 'ZendFramework'); } ++$count; $fingerprints[$count] = md5($details['key']); } } // compress prior to encryption if (!empty($this->_compression)) { require_once 'Zend/Filter/Compress.php'; $compress = new Zend_Filter_Compress($this->_compression); $value = $compress->filter($value); } $crypt = openssl_seal($value, $encrypted, $encryptedkeys, $keys); foreach ($keys as $key) { openssl_free_key($key); } if ($crypt === false) { require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception('Openssl was not able to encrypt your content with the given options'); } $this->_keys['envelope'] = $encryptedkeys; // Pack data and envelope keys into single string if ($this->_package) { $header = pack('n', count($this->_keys['envelope'])); foreach ($this->_keys['envelope'] as $key => $envKey) { $header .= pack('H32n', $fingerprints[$key], strlen($envKey)) . $envKey; } $encrypted = $header . $encrypted; } return $encrypted; }
/** * Defined by Zend_Filter_Interface * * Encrypts $value with the defined settings * * @param string $value The content to encrypt * @return string The encrypted content */ public function encrypt($value) { // compress prior to encryption if (!empty($this->_compression)) { #require_once 'Zend/Filter/Compress.php'; $compress = new Zend_Filter_Compress($this->_compression); $value = $compress->filter($value); } $cipher = $this->_openCipher(); $this->_initCipher($cipher); $encrypted = mcrypt_generic($cipher, $value); mcrypt_generic_deinit($cipher); $this->_closeCipher($cipher); return $encrypted; }
public function archiveAction() { $arrPostVal = $this->getRequest()->getParams(); $albumId = $arrPostVal['albumId']; $usersNs = new Zend_Session_Namespace("members"); $userName = $usersNs->userUsername; $fileName = PUBLIC_PATH . '/tmp/' . $userName . '.zip'; $downloadPath = '/tmp/' . $userName . '.zip'; $folderPath = PUBLIC_PATH . '/tmp/' . $userName; $this->deleteDirectory($folderPath); // Remove Folder if exist if (is_file($fileName)) { unlink($fileName); } mkdir($folderPath, 0777); $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $whereAlbumPhoto = "album_id='{$albumId}'"; $arrAlbumPhoto = $objModelAlbumPhoto->fetchAll($whereAlbumPhoto); foreach ($arrAlbumPhoto as $albumPhoto) { $filePath = PUBLIC_PATH . "/media/album/default/" . $albumPhoto->image; $targetPath = $folderPath . "/" . $albumPhoto->image; $fileTransfer = Base_Image_PhpThumbFactory::create($filePath); $fileTransfer->save($targetPath); } set_time_limit(0); $filter = new Zend_Filter_Compress(array('adapter' => 'zip', 'options' => array('archive' => $fileName))); $compressed = $filter->filter($folderPath); print $downloadPath; exit; }
/** * Decompress archiv * * @return void */ public function testDecompressArchive() { $filter = new Zend_Filter_Compress('bz2'); $archive = dirname(__FILE__) . '/../_files/compressed.bz2'; $filter->setArchive($archive); $content = $filter->filter('compress me'); $this->assertTrue($content); $filter2 = new Zend_Filter_Compress('bz2'); $content2 = $filter2->decompress($archive); $this->assertEquals('compress me', $content2); }
/** * Export Action */ public function exportAction() { // Chave Primária $primaries = $this->_getPrimaries(function ($value) { return (int) $value; }); // Recuperação de Elemento $table = $this->_getDbTable(); $element = $table->find($primaries)->current(); // Verificação if ($element === null) { throw new Zend_Db_Exception('Invalid Element'); } // Dependências Zend_Loader::loadFile('antlr.php', null, true); Zend_Loader::loadClass('SubWikiParser'); Zend_Loader::loadClass('SubWikiLexer'); // Inicialização $ass = new ANTLRStringStream($element->conteudo); $lex = new SubWikiLexer($ass); $cts = new CommonTokenStream($lex); // Tradutor $parser = $this->_getParser(); $parser->setTokenStream($cts); // Usuário Atual $usuario = $element->findParentRow('Usuario'); $autor = $usuario->findParentRow('Autor'); $instituicao = $autor->findParentRow('Instituicao'); // Preenchimento de Imagens Disponíveis $figuras = $usuario->findDependentRowset('Figura'); foreach ($figuras as $figura) { $identifier = $figura->identificador; $filename = $figura->arquivo; $caption = $figura->legenda; $parser->addImageInfo($identifier, $filename, $caption); } $this->_images = $figuras; // Preenchimento de Citações Disponíveis $referencias = $usuario->findDependentRowset('Referencia'); foreach ($referencias as $referencia) { $identifier = $referencia->identificador; $parser->addCiteInfo($identifier); } $this->_citations = $referencias; // Processamento $parser->wikipage(); $this->view->document = trim($parser->render()); // Pacotes $this->view->packages = $this->_getPackages(); // Informações Pessoais e Artigo $this->view->title = $element->titulo; $this->view->author = $autor->nome; $this->view->email = $autor->email; $this->view->address = $instituicao->endereco; // Citações Inclusas? $citations = $parser->getCitations(); $this->view->citations = !empty($citations); // Construção da Saída $pathname = $this->_buildOutput(); // Tipo de Saída Esperada $extension = $this->_getParam('type', 'pdf'); if (!in_array($extension, array('pdf', 'zip'))) { $extension = 'pdf'; } // Código Completo Compactado? if ($extension == 'zip') { $filter = new Zend_Filter_Compress(array('adapter' => 'Zip', 'options' => array('archive' => $pathname . '/document.zip'))); $filter->filter($pathname); } // Capturar o Conteúdo $content = file_get_contents($pathname . '/document.' . $extension); // @todo Remover Diretório Temporário // Preparação para Ignorar Renderização de Saída $renderer = $this->_helper->getHelper('ViewRenderer'); $renderer->setNoRender(true); $this->view->layout()->disableLayout(); // Modificação de Cabeçalho $this->getResponse()->setHeader('Content-Type', 'application/' . $extension)->setHeader('Content-Disposition', "attachment;filename=document.{$extension}")->append('content', $content); }
/** * Compress file */ public function compressFile($archive, $usedFiles, $tmpZipPath) { $filter = new Zend_Filter_Compress(array('adapter' => 'Zip', 'options' => array('archive' => $archive))); $compressed = $filter->filter($tmpZipPath); foreach ($usedFiles as $file) { unlink($file); } rmdir($tmpZipPath); }
public function pack() { $response = array('success' => false); $files = explode(':', $this->_data['file']); $path = $this->cfg['path'] . $this->_data['dirPath']; $archiveName = trim($_POST['archiveName']); $archiveFormat = $this->_strtolower($_POST['archiveFormat']); if (!in_array($archiveFormat, array('zip', 'rar', 'bz2', 'gz', 'lzf', 'tar'))) { $archiveFormat = 'Zip'; } $list = $path . $files[0]; $list = rtrim($list, '\\/'); /* $list = array(); for ($i=-1, $iCount=count($files); ++$i<$iCount;) { $ext = $this->_substr($files[$i], $this->_strrpos($files[$i], '.') + 1); if (is_dir($path . $files[$i])) { $list[] = $path . $files[$i]; } elseif (!in_array($ext, $this->cfg['resource'][$this->_data['type']]['denied']) && in_array($ext, $this->cfg['resource'][$this->_data['type']]['allow'])) { $list[] = $path . $files[$i]; } } */ require_once 'Zend' . DIR_SEP . 'Filter.php'; require_once 'Zend' . DIR_SEP . 'Filter' . DIR_SEP . 'Compress.php'; $archiveFile = $archiveName . '.' . strtolower($archiveFormat); $archiveFile = $this->getFreeFileName($archiveFile, $path); $filter = new Zend_Filter_Compress(array('adapter' => ucfirst($archiveFormat), 'options' => array('archive' => $path . $archiveFile))); $result = $filter->filter($list); false === $result ? $response['success'] = false : ($response['success'] = true); return $response; }