summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--files/admin.php18
-rw-r--r--files/templates/admin.php11
-rw-r--r--lib/files.php44
3 files changed, 60 insertions, 13 deletions
diff --git a/files/admin.php b/files/admin.php
index ea846202ab3..7e410652cfb 100644
--- a/files/admin.php
+++ b/files/admin.php
@@ -28,13 +28,20 @@ require_once('../lib/base.php');
OC_Util::checkAdminUser();
$htaccessWorking=(getenv('htaccessWorking')=='true');
-if(isset($_POST['maxUploadSize'])){
- $maxUploadFilesize=$_POST['maxUploadSize'];
- OC_Files::setUploadLimit(OC_Helper::computerFileSize($maxUploadFilesize));
+if($_POST) {
+ if(isset($_POST['maxUploadSize'])){
+ $maxUploadFilesize=$_POST['maxUploadSize'];
+ OC_Files::setUploadLimit(OC_Helper::computerFileSize($maxUploadFilesize));
+ }
+ if(isset($_POST['maxZipInputSize'])) {
+ $maxZipInputSize=$_POST['maxZipInputSize'];
+ OC_Preferences::setValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize($maxZipInputSize));
+ }
}else{
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+ $maxZipInputSize = OC_Helper::humanfilesize(OC_Preferences::getValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize('800 MB')));
}
OC_App::setActiveNavigationEntry( "files_administration" );
@@ -42,6 +49,5 @@ OC_App::setActiveNavigationEntry( "files_administration" );
$tmpl = new OC_Template( 'files', 'admin' );
$tmpl->assign( 'htaccessWorking', $htaccessWorking );
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
-return $tmpl->fetchPage();
-
-?>
+$tmpl->assign( 'maxZipInputSize', $maxZipInputSize);
+return $tmpl->fetchPage(); \ No newline at end of file
diff --git a/files/templates/admin.php b/files/templates/admin.php
index eb655447044..8c3ba56ad52 100644
--- a/files/templates/admin.php
+++ b/files/templates/admin.php
@@ -3,11 +3,10 @@
<form name="filesForm" action='#' method='post'>
<fieldset class="personalblock">
<legend><strong><?php echo $l->t('File handling');?></strong></legend>
- <?php if($_['htaccessWorking']):?>
- <label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
- <input type='submit' value='Save'/>
- <?php else:?>
- No settings currently available.
- <?php endif;?>
+ <?php if($_['htaccessWorking']):?>
+ <label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
+ <?php endif;?>
+ <label for="maxZipInputSize"><?php echo $l->t( 'Maximum input size for zip files (affects folder- and multi-file download)' ); ?> </label><input name="maxZipInputSize" id="maxZipInputSize" value='<?php echo $_['maxZipInputSize'] ?>'/><br/>
+ <input type="submit" value="Save"/>
</fieldset>
</form>
diff --git a/lib/files.php b/lib/files.php
index 1f8331afb21..50223df1d36 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -59,6 +59,9 @@ class OC_Files {
}
if(is_array($files)){
+ self::checkZipInputSize($dir,$files);
+ $executionTime = intval(ini_get('max_execution_time'));
+ set_time_limit(0);
$zip = new ZipArchive();
$filename = get_temp_dir()."/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
@@ -75,7 +78,11 @@ class OC_Files {
}
}
$zip->close();
+ set_time_limit($executionTime);
}elseif(OC_Filesystem::is_dir($dir.'/'.$files)){
+ self::checkZipInputSize($dir,$files);
+ $executionTime = intval(ini_get('max_execution_time'));
+ set_time_limit(0);
$zip = new ZipArchive();
$filename = get_temp_dir()."/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
@@ -84,6 +91,7 @@ class OC_Files {
$file=$dir.'/'.$files;
self::zipAddDir($file,$zip);
$zip->close();
+ set_time_limit($executionTime);
}else{
$zip=false;
$filename=$dir.'/'.$files;
@@ -210,6 +218,40 @@ class OC_Files {
}
/**
+ * checks if the selected files are within the size constraint. If not, outputs an error page.
+ *
+ * @param dir $dir
+ * @param files $files
+ */
+ static function checkZipInputSize($dir, $files) {
+ $zipLimit = OC_Preferences::getValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
+ if($zipLimit > 0) {
+ $totalsize = 0;
+ if(is_array($files)){
+ foreach($files as $file){
+ $totalsize += OC_Filesystem::filesize($dir.'/'.$file);
+ }
+ }else{
+ $totalsize += OC_Filesystem::filesize($dir.'/'.$files);
+ }
+ if($totalsize > $zipLimit) {
+ $l = new OC_L10N('files');
+ header("HTTP/1.0 409 Conflict");
+ $tmpl = new OC_Template( '', 'error', 'user' );
+ $errors = array(
+ array(
+ 'error' => $l->t('Selected files too large to generate zip file.'),
+ 'hint' => 'Download the files in smaller chunks, seperately or kindly ask your administrator.<br/><a href="javascript:history.back()">' . $l->t('Back to Files') . '</a>',
+ )
+ );
+ $tmpl->assign('errors', $errors);
+ $tmpl->printPage();
+ exit;
+ }
+ }
+ }
+
+ /**
* try to detect the mime type of a file
*
* @param string path
@@ -256,7 +298,7 @@ class OC_Files {
return false;
}
}
-
+
/**
* set the maximum upload size limit for apache hosts using .htaccess
* @param int size filesisze in bytes