From b13ab2b17eb485aec13c7fb1e88e25e1c9901d72 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 19 Mar 2012 11:56:02 +0100 Subject: enable admin to turn off ZIP downloads user interface offers multi-file/folder downloads only if available make function name more clear --- lib/files.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'lib/files.php') diff --git a/lib/files.php b/lib/files.php index 50223df1d36..662f0b59724 100644 --- a/lib/files.php +++ b/lib/files.php @@ -59,7 +59,7 @@ class OC_Files { } if(is_array($files)){ - self::checkZipInputSize($dir,$files); + self::validateZipDownload($dir,$files); $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); @@ -80,7 +80,7 @@ class OC_Files { $zip->close(); set_time_limit($executionTime); }elseif(OC_Filesystem::is_dir($dir.'/'.$files)){ - self::checkZipInputSize($dir,$files); + self::validateZipDownload($dir,$files); $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); @@ -223,7 +223,22 @@ class OC_Files { * @param dir $dir * @param files $files */ - static function checkZipInputSize($dir, $files) { + static function validateZipDownload($dir, $files) { + if(!OC_Preferences::getValue('', 'files', 'allowZipDownload', 1)) { + $l = new OC_L10N('files'); + header("HTTP/1.0 409 Conflict"); + $tmpl = new OC_Template( '', 'error', 'user' ); + $errors = array( + array( + 'error' => $l->t('ZIP download is turned off.'), + 'hint' => $l->t('Files need to be downloaded one by one.') . '
' . $l->t('Back to Files') . '', + ) + ); + $tmpl->assign('errors', $errors); + $tmpl->printPage(); + exit; + } + $zipLimit = OC_Preferences::getValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize('800 MB')); if($zipLimit > 0) { $totalsize = 0; -- cgit v1.2.3