[Fusionforge-commits] r13490 - trunk/src/www/docman

Alain Peyrat aljeux at fusionforge.org
Fri Jun 10 14:02:14 CEST 2011


Author: aljeux
Date: 2011-06-10 14:02:13 +0200 (Fri, 10 Jun 2011)
New Revision: 13490

Modified:
   trunk/src/www/docman/view.php
Log:
fix from branch 5.1 r13479: protect code if zip is missing

Modified: trunk/src/www/docman/view.php
===================================================================
--- trunk/src/www/docman/view.php	2011-06-10 12:02:08 UTC (rev 13489)
+++ trunk/src/www/docman/view.php	2011-06-10 12:02:13 UTC (rev 13490)
@@ -93,39 +93,44 @@
 	echo $d->getFileData();
 
 } elseif ($docid === 'backup') {
-	session_require_perm('docman', $group_id, 'admin');
+	if (extension_loaded('zip')) {
+		session_require_perm('docman', $group_id, 'admin');
 
-	$df = new DocumentFactory($g);
-	if ($df->isError())
-		exit_error($df->getErrorMessage(), 'docman');
+		$df = new DocumentFactory($g);
+		if ($df->isError())
+			exit_error($df->getErrorMessage(), 'docman');
 
-	$dgf = new DocumentGroupFactory($g);
-	if ($dgf->isError())
-		exit_error($dgf->getErrorMessage(), 'docman');
+		$dgf = new DocumentGroupFactory($g);
+		if ($dgf->isError())
+			exit_error($dgf->getErrorMessage(), 'docman');
 
-	$nested_groups = $dgf->getNested();
+		$nested_groups = $dgf->getNested();
 
-	if ( $nested_groups != NULL ) {
-		$filename = 'docman-'.$g->getUnixName().'-'.$docid.'.zip';
-		$file = forge_get_config('data_path').'/'.$filename;
-		$zip = new ZipArchive;
-		if ( !$zip->open($file, ZIPARCHIVE::OVERWRITE)) {
-			exit_error(_('Unable to open zip archive for backup'),'docman');
-		}
+		if ( $nested_groups != NULL ) {
+			$filename = 'docman-'.$g->getUnixName().'-'.$docid.'.zip';
+			$file = forge_get_config('data_path').'/'.$filename;
+			$zip = new ZipArchive;
+			if ( !$zip->open($file, ZIPARCHIVE::OVERWRITE)) {
+				exit_error(_('Unable to open zip archive for backup'), 'docman');
+			}
 
-		if ( !docman_fill_zip($zip, $nested_groups, $df))
-			exit_error(_('Unable to fill zip archive for backup'), 'docman');
+			if ( !docman_fill_zip($zip, $nested_groups, $df))
+				exit_error(_('Unable to fill zip archive for backup'), 'docman');
 
-		if ( !$zip->close())
-			exit_error(_('Unable to close zip archive for backup'), 'docman');
+			if ( !$zip->close())
+				exit_error(_('Unable to close zip archive for backup'), 'docman');
 
-		header('Content-disposition: filename="'.$filename.'"');
-		header('Content-type: application/binary');
+			header('Content-disposition: filename="'.$filename.'"');
+			header('Content-type: application/binary');
 
-		readfile($file);
-		unlink($file);
+			readfile($file);
+			unlink($file);
+		} else {
+			$warning_msg = _('No documents to backup.');
+			session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($warning_msg));
+		}
 	} else {
-		$warning_msg = _('No documents to backup.');
+		$warning_msg = _('Zip extension is missing: no backup function');
 		session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($warning_msg));
 	}
 } elseif ($docid === 'webdav') {




More information about the Fusionforge-commits mailing list