open($filename) !== true ) { throw new OdfException("Error while Opening the file '$filename' - Check your odt file"); } // read content.xml from the oasis document if (($contentXml = $file->getFromName('content.xml')) === false) { throw new OdfException("Nothing to parse - check that the content.xml file is correctly formed"); } // close the original oasis document $file->close(); // for futur use, with load content.xml via DOMDocument library : $odt_content = new DOMDocument('1.0', 'utf-8'); if ($odt_content->loadXML( $contentXml ) == FALSE) { throw new OdfException('Unable to load content.xml by DOMDocument library ', __METHOD__); } // here, we dont use the temp function but local temporary file $tmpfile = md5(uniqid()).'.odt'; if( !@copy($filename, $tmpfile) ); { // we do not test, because sometime it return false anyway !! // $errors = error_get_last(); // throw new OdfException("Can not copy the tempfile in $tmpfile :[".$errors['message'] ."]/[".$errors['type']."]"); } // futur use here : $odt_content modifications ... // open the temporary zipfile if( $file->open($tmpfile, ZIPARCHIVE::CREATE) != TRUE ) { @unlink($tmpfile); // erase temporary file throw new OdfException("Error while Opening the tempfile '$tmpfile' - Check your odt file"); } // for futur use here : with overwrite content.xml in zip file via DOMDocument library : if (! $file->addFromString('content.xml', $odt_content->saveXML()) ) { @unlink($tmpfile); // erase temporary file throw new OdfException('Error during file export'); } // close the temporary zipfile $file->close(); // send the new checkresult.odt file via http : $name = "checkresult.odt"; $size = filesize($tmpfile); header('Content-type: application/vnd.oasis.opendocument.text'); header('Content-Disposition: attachment; filename="'.$name.'"'); header("Content-Length: ".$size); readfile($tmpfile); // output @unlink($tmpfile); // erase temporary file exit; // be sure nothing else is write after ?>