Пример #1
0
 public function testEncryptedZipArchiveExportCanBeImported()
 {
     $this->auth();
     $crypto = CryptoModel::importRijndael256Key('testdupe', 'BqPwhnSskTFzxPUlljXG1zgG8cfgTSaGj8UyRWsKanA=');
     $instance = new InstanceModel(array('instanceID' => 1));
     $zip = new ZipArchiveModel($instance, array('new' => '1'));
     $zip->addInstanceFullResponsesXMLDocument();
     $zip->close();
     $encrypted = $crypto->encrypt($zip->getZipFileContents());
     $zip->deleteZipFile();
     $decrypted = $crypto->decrypt($encrypted);
     $tempfile = tempnam(PROJECT_PATH . DIRECTORY_SEPARATOR . 'tmp', 'zip');
     unlink($tempfile);
     file_put_contents($tempfile, $decrypted);
     $zip = new ZipArchiveModel(null, array('filename' => $tempfile));
     InstanceModel::importXML($zip, 'test encryption import');
     $zip->deleteZipFile();
 }
Пример #2
0
 public function ResponsesFullXMLArchiveAction()
 {
     $session = new Zend_Session_Namespace('login');
     $cryptoID = $this->_hasParam('cryptoID') ? $this->_getParam('cryptoID') : null;
     if ($this->_hasParam('download') && isset($session->tempFile)) {
         if (isset($cryptoID) && $cryptoID != 0) {
             $this->view->cryptoID = $cryptoID;
         }
         $this->view->archive = file_get_contents($session->tempFile);
         unlink($session->tempFile);
         unset($session->tempFile);
     } else {
         $instance = new InstanceModel(array('instanceID' => $session->dataInstanceID, 'depth' => 'instance'));
         $zip = new ZipArchiveModel($instance, array('new' => 1));
         $zip->addInstanceFullResponsesXMLDocument();
         $zip->addAttachments();
         $zip->close();
         $tempFile = tempnam(PROJECT_PATH . DIRECTORY_SEPARATOR . 'tmp', 'exp');
         $archive = '';
         if (isset($cryptoID) && $cryptoID != 0) {
             $crypto = new CryptoModel(array('cryptoID' => $cryptoID));
             $archive = $crypto->encrypt($zip->getZipFileContents());
             $this->view->cryptoID = $cryptoID;
         } else {
             $archive = $zip->getZipFileContents();
         }
         $zip->deleteZipFile();
         file_put_contents($tempFile, $archive);
         $session->tempFile = $tempFile;
     }
     $this->view->setRenderLayout(false);
 }