Merge branch 'master' into calendar_sharing
This commit is contained in:
commit
de49652536
5 changed files with 85 additions and 35 deletions
|
@ -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();
|
|
@ -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{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -209,6 +217,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
|
||||
*
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue