Esempio n. 1
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;
 }
Esempio n. 2
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);
     }
 }
        $odf->FileReplace($manifest, $txt, TBSZIP_STRING);
        // si on ne compresse pas ça fait un bug !! à vérifier pourquoi
        echo "<span style='color:red;'>{$replace_manifest} modifications ont été apportées au fichier manifest</span><br>\r\n";
    }
    // recherche du bug dans le fichier style
    $replace_style = 0;
    if ($odf->FileExists($styles)) {
        $txt = $odf->FileRead($styles);
        $item = ' fo:font-size="0pt"';
        if (strpos($txt, $item) !== false) {
            $item2 = str_replace('"0pt"', '"14pt"', $item);
            $txt = str_replace($item, $item2, $txt);
            $odf->FileReplace($styles, $txt, TBSZIP_STRING);
            // si on ne compresse pas ça fait un bug !! à vérifier pourquoi
            echo "<span style='color:red;'>une modification a été apportée au fichier styles</span><br>\r\n";
            $replace_style++;
        }
    }
    if ($replace_manifest + $replace_style > 0) {
        $temp = $file . '.tmp';
        $odf->Flush(TBSZIP_FILE, $temp);
        $odf->OutputClose();
        // à ajouter car bug si TbsZip <= 2.3
        $odf->Close();
        unlink($file);
        rename($temp, $file);
    } else {
        echo "<span style='color:green;'>L'archive n'a pas été modifiée.</span><br>\r\n";
    }
}
//echo $txt;
// add the uncompressed file by copying a local file
// delete an existing file in the archive
$zip->FileReplace('newfile.txt', $data, TBSZIP_STRING);
// replace the file by giving the content
$zip->FileReplace('newpic1.png', './images/localpic1.png', TBSZIP_FILE);
// replace the file by copying a local file
$zip->FileReplace('newpic2.png', './images/localpic2.png', TBSZIP_FILE, false);
// replace the uncompressed file by copying a local file
$zip->FileReplace('newpic3.png', false);
// delete the file in the archive
// cancel the last modification on the file (add/replace/delete)
$zip->FileCancelModif('newpic2.png');
// ----------------------
// Applying modifications
// ----------------------
$zip->Flush(TBSZIP_FILE, './save/new_archive.zip');
// apply modifications as a new local file
// apply modifications as an HTTP downloaded file
$zip->Flush(TBSZIP_DOWNLOAD, 'download.zip');
$zip->Flush(TBSZIP_DOWNLOAD, 'download.zip', 'application/zip');
// with a specific Content-Type
// apply modifications as a downloaded file with your customized HTTP headers
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=download.zip");
header("Expires: Fri, 01 Jan 2010 05:00:00 GMT");
$zip->Flush(TBSZIP_DOWNLOAD + TBSZIP_NOHEADER);
// -----------------
// Close the archive
// -----------------
$zip->Close();
// stop to work with the opened archive. Modifications are not applied to the opened archive, use Flush() to commit