summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-03-17 00:00:04 +0100
committerGeorg Ehrke <dev@georgswebsite.de>2012-03-17 00:00:04 +0100
commitde49652536f90775e2f1e30cf4a82c1782103da7 (patch)
treed68a1bf0fecab40d8cdd17efa56e32e8c3382184
parent27218f85cb54d543f3a5cf631785174193d0b42c (diff)
parent3267d91bdaed42633656723ec4e239d1fe460824 (diff)
downloadnextcloud-server-de49652536f90775e2f1e30cf4a82c1782103da7.tar.gz
nextcloud-server-de49652536f90775e2f1e30cf4a82c1782103da7.zip
Merge branch 'master' into calendar_sharing
-rw-r--r--files/admin.php24
-rw-r--r--files/js/files.js33
-rw-r--r--files/templates/admin.php14
-rw-r--r--lib/app.php5
-rw-r--r--lib/files.php44
5 files changed, 85 insertions, 35 deletions
diff --git a/files/admin.php b/files/admin.php
index 861b6037f3c..7e410652cfb 100644
--- a/files/admin.php
+++ b/files/admin.php
@@ -25,23 +25,29 @@
// Init owncloud
require_once('../lib/base.php');
-OC_User::checkAdminUser();
+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" );
-// return template
-$tmpl = new OC_Template( "files", "admin", "user" );
+
+$tmpl = new OC_Template( 'files', 'admin' );
$tmpl->assign( 'htaccessWorking', $htaccessWorking );
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
-$tmpl->printPage();
-
-?>
+$tmpl->assign( 'maxZipInputSize', $maxZipInputSize);
+return $tmpl->fetchPage(); \ No newline at end of file
diff --git a/files/js/files.js b/files/js/files.js
index a678e12cc2d..539d5598899 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -3,11 +3,11 @@ $(document).ready(function() {
//little hack to set unescape filenames in attribute
$(this).attr('data-file',decodeURIComponent($(this).attr('data-file')));
});
-
+
if($('tr[data-file]').length==0){
$('.file_upload_filename').addClass('highlight');
}
-
+
$('#file_action_panel').attr('activeAction', false);
//drag/drop of files
@@ -16,7 +16,7 @@ $(document).ready(function() {
$('div.crumb').droppable(crumbDropOptions);
$('ul#apps>li:first-child').data('dir','');
$('ul#apps>li:first-child').droppable(crumbDropOptions);
-
+
// Triggers invisible file input
$('.file_upload_button_wrapper').live('click', function() {
$(this).parent().children('.file_upload_start').trigger('click');
@@ -81,9 +81,9 @@ $(document).ready(function() {
}
}
}
-
+
});
-
+
// Sets the select_all checkbox behaviour :
$('#select_all').click(function() {
if($(this).attr('checked')){
@@ -97,7 +97,7 @@ $(document).ready(function() {
}
procesSelection();
});
-
+
$('td.filename input:checkbox').live('click',function(event) {
if (event.shiftKey) {
var last = $(lastChecked).parent().parent().prevAll().length;
@@ -126,23 +126,22 @@ $(document).ready(function() {
}
procesSelection();
});
-
+
$('#file_newfolder_name').click(function(){
if($('#file_newfolder_name').val() == 'New Folder'){
$('#file_newfolder_name').val('');
}
});
-
+
$('.download').click('click',function(event) {
var files=getSelectedFiles('name').join(';');
-
- //send the browser to the download location
var dir=$('#dir').val()||'/';
-// alert(files);
+ $('#notification').text(t('files','generating ZIP-file, it may take some time.'));
+ $('#notification').fadeIn();
window.location='ajax/download.php?files='+encodeURIComponent(files)+'&dir='+encodeURIComponent(dir);
return false;
});
-
+
$('.delete').click(function(event) {
var files=getSelectedFiles('name');
event.preventDefault();
@@ -228,7 +227,7 @@ $(document).ready(function() {
form.hide();
}
});
-
+
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
if(navigator.userAgent.search(/konqueror/i)==-1){
$('.file_upload_start').attr('multiple','multiple')
@@ -255,7 +254,7 @@ $(document).ready(function() {
text=text.substr(0,text.length-6)+'...';
crumb.text(text);
}
-
+
$(window).click(function(){
$('#new>ul').hide();
$('#new').removeClass('active');
@@ -279,14 +278,14 @@ $(document).ready(function() {
if($(this).children('p').length==0){
return;
}
-
+
$('#new li').each(function(i,element){
if($(element).children('p').length==0){
$(element).children('input').remove();
$(element).append('<p>'+$(element).data('text')+'</p>');
}
});
-
+
var type=$(this).data('type');
var text=$(this).children('p').text();
$(this).data('text',text);
@@ -348,7 +347,7 @@ $(document).ready(function() {
tr.find('td.filename').attr('style','background-image:url('+path+')');
});
}else{
-
+
}
}
);
diff --git a/files/templates/admin.php b/files/templates/admin.php
index 0122865ee72..8c3ba56ad52 100644
--- a/files/templates/admin.php
+++ b/files/templates/admin.php
@@ -1,10 +1,12 @@
<?php OC_Util::addScript('files','admin'); ?>
<form name="filesForm" action='#' method='post'>
- <?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;?>
+ <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/>
+ <?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/app.php b/lib/app.php
index f841180ebad..64cbe8894ea 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -325,6 +325,7 @@ class OC_App{
$source=self::$settingsForms;
break;
case 'admin':
+ $forms[] = include 'files/admin.php'; //hardcode own apps
$source=self::$adminForms;
break;
case 'personal':
@@ -371,7 +372,7 @@ class OC_App{
}
return $apps;
}
-
+
/**
* check if any apps need updating and update those
*/
@@ -390,7 +391,7 @@ class OC_App{
}
}
}
-
+
/**
* update the database for the app and call the update script
* @param string appid
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