[Fusionforge-commits] FusionForge branch Branch_5_3 updated. v5.3-rc4-20-g7e7ff26

Franck Villaume nerville at fusionforge.org
Mon Mar 24 17:01:13 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, Branch_5_3 has been updated
       via  7e7ff260b280a11a768b9a7c5359a95e47d03fe5 (commit)
      from  1730a77feee3935bcb8863617e37d4dbe08062e7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7e7ff260b280a11a768b9a7c5359a95e47d03fe5
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Mon Mar 24 16:57:56 2014 +0100

    docman: put archive in docman dir not everywhere in the filesystem & cleanup on error

diff --git a/src/www/docman/view.php b/src/www/docman/view.php
index 7d59172..77d3a25 100644
--- a/src/www/docman/view.php
+++ b/src/www/docman/view.php
@@ -189,10 +189,13 @@ if (is_numeric($docid)) {
 
 			if ($dg->hasDocuments($nested_groups, $df)) {
 				$filename = 'docman-'.$g->getUnixName().'-'.$dg->getID().'.zip';
-				$file = forge_get_config('data_path').'/'.$filename;
+				$file = forge_get_config('data_path').'/docman/'.$filename;
+				@unlink($file);
 				$zip = new ZipArchive;
-				if ( !$zip->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE))
+				if ( !$zip->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)) {
+					@unlink($file);
 					exit_error(_('Unable to open ZIP archive for download as ZIP'), 'docman');
+				}
 
 				// ugly workaround to get the files at doc_group_id level
 				$df->setDocGroupID($dg->getID());
@@ -206,11 +209,15 @@ if (is_numeric($docid)) {
 							exit_error(_('Unable to fill ZIP file.'), 'docman');
 					}
 				}
-				if ( !docman_fill_zip($zip, $nested_groups, $df, $dg->getID()))
+				if ( !docman_fill_zip($zip, $nested_groups, $df, $dg->getID())) {
+					@unlink($file);
 					exit_error(_('Unable to fill ZIP archive for download as ZIP'), 'docman');
+				}
 
-				if ( !$zip->close())
+				if ( !$zip->close()) {
+					@unlink($file);
 					exit_error(_('Unable to close ZIP archive for download as ZIP'), 'docman');
+				}
 
 				header('Content-disposition: attachment; filename="'.$filename.'"');
 				header('Content-type: application/zip');
@@ -231,24 +238,31 @@ if (is_numeric($docid)) {
 			$dirid = $arr[6];
 			$arr_fileid = explode(',',$arr[7]);
 			$filename = 'docman-'.$g->getUnixName().'-selected-'.time().'.zip';
-			$file = forge_get_config('data_path').'/'.$filename;
+			$file = forge_get_config('data_path').'/docman/'.$filename;
+			@unlink($file);
 			$zip = new ZipArchive;
-			if (!$zip->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE))
+			if (!$zip->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)) {
+				@unlink($file);
 				exit_error(_('Unable to open ZIP archive for download as ZIP'), 'docman');
+			}
 
 			foreach($arr_fileid as $docid) {
 				if (!empty($docid)) {
 					$d = new Document($g, $docid);
 					if (!$d || !is_object($d)) {
+						@unlink($file);
 						exit_error(_('Document is not available.'), 'docman');
 					} elseif ($d->isError()) {
+						@unlink($file);
 						exit_error($d->getErrorMessage(), 'docman');
 					}
 					if ($d->isURL()) {
 						continue;
 					}
-					if (!$zip->addFromString(iconv("UTF-8", "ASCII//TRANSLIT", $d->getFileName()), $d->getFileData()))
+					if (!$zip->addFromString(iconv("UTF-8", "ASCII//TRANSLIT", $d->getFileName()), $d->getFileData())) {
+						@unlink($file);
 						exit_error(_('Unable to fill ZIP file.'), 'docman');
+					}
 				} else {
 					$zip->close();
 					unlink($file);
@@ -256,8 +270,10 @@ if (is_numeric($docid)) {
 					session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($warning_msg));
 				}
 			}
-			if ( !$zip->close())
+			if ( !$zip->close()) {
+				@unlink($file);
 				exit_error(_('Unable to close ZIP archive for download as ZIP'), 'docman');
+			}
 
 			header('Content-disposition: attachment; filename="'.$filename.'"');
 			header('Content-type: application/zip');
@@ -274,7 +290,7 @@ if (is_numeric($docid)) {
 			exit_error(_('No document to display - invalid or inactive document number.'), 'docman');
 		}
 	} else {
-		exit_error(_('PHP extension is missing.'), 'docman');
+		exit_error(_('PHP ZIP extension is missing.'), 'docman');
 	}
 } else {
 	exit_error(_('No document to display - invalid or inactive document number.'), 'docman');

-----------------------------------------------------------------------

Summary of changes:
 src/www/docman/view.php |   34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list