Ejemplo n.º 1
0
 public function read_file($file)
 {
     $zip = new clsTbsZip();
     $zip->Open($file);
     $content = $zip->FileRead('word/document.xml');
     $content = str_replace(array_keys($this->dbData), array_values($this->dbData), $content);
     $zip->FileReplace('word/document.xml', $content);
     $path_parts = pathinfo($file);
     $zip->Flush(TBSZIP_FILE, $this->fileFolder . '/' . $path_parts['filename'] . "MODIFIED." . $path_parts['extension']);
     $zip->close();
 }
Ejemplo n.º 2
0
 public static function avr(array $params, $filename)
 {
     $zip = new clsTbsZip();
     $default = array('investorName' => '', 'customerName' => '', 'contractorName' => '', 'constructionName' => '', 'objectName' => '', 'investorCode' => '', 'customerCode' => '', 'contractorCode' => '', 'constructionCode' => '', 'objectCode' => '', 'kindOfActivity' => '', 'contractNumber' => '', 'typeOfOperation' => '', 'dayOfContract' => '', 'mounthOfContract' => '', 'yearOfContract' => '', 'documentNumber' => '', 'dateOfDocument' => '', 'reportingPeriodFrom' => '', 'reportingPeriodTo' => '', 'outlayPrice' => '', 'totalQuantity' => '', 'totalPrice' => '', 'table' => array(), 'personWhoGiveTranscript' => '', 'personWhoGiveOfficialCapacity' => '', 'personWhoTakeTranscript' => '', 'personWhoTakeOfficialCapacity' => '');
     $params = array_merge($default, $params);
     while (sizeof($params['table']) < 10) {
         $params['table'][] = array('byOrder' => '', 'byOutlay' => '', 'workName' => '', 'unitPriceNumber' => '', 'measurement' => '', 'quantity' => '', 'unitPrice' => '', 'price' => '');
     }
     $zip->Open(dirname(__FILE__) . '/Avr/origin.odt');
     $zip->FileReplace('content.xml', Evil_Avr::_avrDocument($params), TBSZIP_STRING);
     $zip->Flush(TBSZIP_FILE, $filename);
     $zip->Close();
     return true;
 }
Ejemplo n.º 3
0
 function handleOOXMLUpload()
 {
     if (isset($_FILES['uploaded'])) {
         $target = './upload/pptx/' . $_SESSION['uid'] . '/';
         if (!file_exists($target)) {
             mkdir($target);
         }
         $target = $target . basename($_FILES['uploaded']['name']);
         $pptxType = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
         if ($_FILES['uploaded']['type'] != $pptxType) {
             $message = '<div id="error-type">File type not supported! Please, upload .pptx files.</div>';
             // die();
         } elseif ($_FILES['uploaded']['error'] === UPLOAD_ERR_OK) {
             if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
                 if (isset($_POST['import_with_style'])) {
                     $import_with_style = $_POST['import_with_style'];
                 } else {
                     $import_with_style = false;
                 }
                 // quick fix for cheking file formatting
                 $zip = new clsTbsZip();
                 $zip->Open($target);
                 if ($zip->FileExists('docProps/core.xml')) {
                     $proper_pptx = true;
                 } else {
                     $proper_pptx = false;
                 }
                 $zip->Close();
                 if ($proper_pptx) {
                     $pr = new pptxPresentation($target, $import_with_style);
                     $deck_num = $pr->saveToDB($this->_user['id']);
                 } else {
                     $message = '<div id="error-type">Not proper .pptx format! Open Office .pptx files are not supported yet.</div>';
                 }
             } else {
                 $message = 'Sorry, there was a problem uploading your file.';
             }
         } else {
             $message = $this->file_upload_error_message($_FILES['uploaded']['error']);
         }
     } else {
         $message = '<div id="error-type">There was no file to upload.</div>';
     }
     if (empty($message)) {
         $this->set('deck_num', $deck_num);
     } else {
         $this->set('message', $message);
     }
 }
Ejemplo n.º 4
0
 public function actionZip()
 {
     Yii::import('application.helpers.vendors.zip.clsTbsZip');
     $zip = new clsTbsZip();
     /**create**/
     //		$zip->CreateNew();
     //
     //		$zip->FileAdd('sub/test2.txt', './public/test2.txt',TBSZIP_FILE);
     //
     //		$zip->Flush(TBSZIP_FILE, './public/zip/test.zip');
     $zipfile = './public/zip/test.zip';
     $tmpfile = './public/zip/tmp.zip';
     $zip->Open($zipfile);
     //		echo $zip->FileExists('test2.txt');
     if (!$zip->FileExists('test.txt')) {
         $zip->FileAdd('test.txt', './public/test.txt', TBSZIP_FILE);
     }
     if (!$zip->FileExists('pclzip-2-8.zip')) {
         $zip->FileAdd('pclzip-2-8.zip', './public/zip/pclzip-2-8.zip', TBSZIP_FILE);
     }
     //		$zip->FileAdd('hello.jpg', './public/uploadfiles/82671333902992.jpg', TBSZIP_FILE);
     echo $zip->FileRead('pclzip-2-8.zip');
     //		$zip->Flush(TBSZIP_DOWNLOAD, 'download.zip');
     //		echo $zip->FileRead('test.txt');
     //		foreach ($zip->CdFileLst as $file)
     //		{
     //			UtilHelper::dump($zip->FileRead($file['v_name']));
     //		}
     $zip->Flush(TBSZIP_FILE, $tmpfile);
     //		$zip->Flush(TBSZIP_DOWNLOAD, 'download.zip', 'application/zip');
     $zip->close();
     //		if (file_exists($zipfile)){
     //			unlink($zipfile);
     //
     //			copy($tmpfile, $zipfile);
     //
     //			unlink($tmpfile);
     //		}
 }
Ejemplo n.º 5
0
 Cela vient du fait que certaines version d'OpenOffice ne respecte les standard strcits d'ODf et aussi est buggé par d'autre moments.
 Ce script corrige les problèmes connus afin que els fichiers passent positivement le test du validateur.
 */
if (file_exists('tbszip.php')) {
    include_once 'tbszip.php';
} else {
    include_once '../tbs_plugin_opentbs.php';
}
$file_lst = array('demo_oo_text.odt', 'demo_oo_formula.odf', 'demo_oo_graph.odg', 'demo_oo_presentation.odp', 'demo_oo_spreadsheet.ods');
$version = '1.2';
// valeur par défaut à mettre dans le manifest
$manifest = 'META-INF/manifest.xml';
$styles = 'styles.xml';
$odf = new clsTbsZip();
foreach ($file_lst as $file) {
    $odf->Open($file);
    echo "<h4>Étude du fichier '{$file}'.</h4>\r\n";
    $extension = strtolower(substr($file, -4));
    if (!$odf->FileExists($manifest)) {
        echo "Le fichier manifest n'a pas été trouvé.<br>\r\n";
        continue;
    }
    /* debug
    	if (file_exists('manifest.xml')) {
    		$odf->FileReplace($manifest, 'manifest.xml', TBSZIP_FILE);
    		$temp = $file.'.tmp.odt';
    		$odf->Flush(TBSZIP_FILE, $temp);
    		echo "Fichier fanifest remplacé par le fichier 'manifest.xml' trouvé dans le répertoire.<br>\r\n";
    		exit;
    	}
    	*/
Ejemplo n.º 6
0
<?php

/* Some code examples for TbsZip
Skrol29, 2010-09-03
*/
include_once 'tbszip.php';
// load the TbsZip library
$zip = new clsTbsZip();
// create a new instance of the TbsZip class
$zip->CreateNew();
// start a new empty archive for adding files
// or
$zip->Open('an_existing_archive.zip');
// open an existing archive for reading and/or modifying
// --------------------------------------------------
// Reading information and data in the opened archive
// --------------------------------------------------
// check if a file is existing in the archive, the name must precise subfolders if any
$ok = $zip->FileExists('subfolder/help.html');
// count the files stored in the archive
$file_nbr = count($zip->CdFileLst);
// retrieve the content of an compressed file in the archive
$text1 = $zip->FileRead('readme.txt');
// retrieve the content of an compressed file in a subfolder of the archive
$text2 = $zip->FileRead('subfolder/readme.txt');
if ($ok) {
    $zip->FileExists('subfolder/help.html');
}
// -----------------------------
// Modifying data in the archive
// -----------------------------
Ejemplo n.º 7
0
 /**
  * Extract content of docx/odt file
  *
  * @param string $filePath  Document file path
  * @param string $docType  File type of document
  *
  * @return array
  *   [string, clsTbsZip]
  */
 public static function unzipDoc($filePath, $docType)
 {
     $dataFile = self::$ooxmlMap[$docType]['dataFile'];
     $zip = new clsTbsZip();
     $zip->Open($filePath);
     $content = $zip->FileRead($dataFile);
     return array($content, $zip);
 }