From 16e5a1b10025c84465caf93458c40efb8a6aa87d Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Tue, 2 Jul 2013 18:44:10 +0300 Subject: Fix lazy styles loading in IE8 --- core/js/js.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core/js') diff --git a/core/js/js.js b/core/js/js.js index 3904787c4e5..5158b66d73a 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -226,8 +226,12 @@ var OC={ var path=OC.filePath(app,'css',style+'.css'); if(OC.addStyle.loaded.indexOf(path)===-1){ OC.addStyle.loaded.push(path); - style=$(''); - $('head').append(style); + if (document.createStyleSheet) { + document.createStyleSheet(path); + } else { + style=$(''); + $('head').append(style); + } } }, basename: function(path) { -- cgit v1.2.3 From d18bd17eb7d13010e3daef5351d7f7ec64480fd7 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 11 Jul 2013 00:00:01 +0200 Subject: - eventsource.php: in case of potential CSRF attack we send an error message from the EventSource to the browser - eventsource.js: handle undefined data on event - update.js: in case of error we close the event source - advise the user to reload the page - update.php: EventSource initialization is now done before we enter the maintenance mode in order to allow browser reload in case of possible CSRF attack --- core/js/eventsource.js | 6 +++++- core/js/update.js | 5 ++++- lib/eventsource.php | 9 +++++---- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'core/js') diff --git a/core/js/eventsource.js b/core/js/eventsource.js index ce8c8387c8e..536b180bc8f 100644 --- a/core/js/eventsource.js +++ b/core/js/eventsource.js @@ -110,7 +110,11 @@ OC.EventSource.prototype={ this.listeners[type].push(callback); }else{ this.source.addEventListener(type,function(e){ - callback(JSON.parse(e.data)); + if (typeof e.data != 'undefined') { + callback(JSON.parse(e.data)); + } else { + callback(''); + } },false); } }else{ diff --git a/core/js/update.js b/core/js/update.js index 8ab02bbf935..2c28e72f7cd 100644 --- a/core/js/update.js +++ b/core/js/update.js @@ -5,6 +5,9 @@ $(document).ready(function () { }); updateEventSource.listen('error', function(message) { $('').addClass('error').append(message).append('
').appendTo($('.update')); + message = 'Please reload the page.'; + $('').addClass('error').append(message).append('
').appendTo($('.update')); + updateEventSource.close(); }); updateEventSource.listen('failure', function(message) { $('').addClass('error').append(message).append('
').appendTo($('.update')); @@ -20,4 +23,4 @@ $(document).ready(function () { window.location.href = OC.webroot; }, 3000); }); -}); \ No newline at end of file +}); diff --git a/lib/eventsource.php b/lib/eventsource.php index 63f19792529..31d6edc1874 100644 --- a/lib/eventsource.php +++ b/lib/eventsource.php @@ -25,7 +25,7 @@ * wrapper for server side events (http://en.wikipedia.org/wiki/Server-sent_events) * includes a fallback for older browsers and IE * - * use server side events with causion, to many open requests can hang the server + * use server side events with caution, to many open requests can hang the server */ class OC_EventSource{ private $fallback; @@ -43,6 +43,7 @@ class OC_EventSource{ header("Content-Type: text/event-stream"); } if( !OC_Util::isCallRegistered()) { + $this->send('error', 'Possible CSRF attack. Connection will be closed.'); exit(); } flush(); @@ -51,10 +52,10 @@ class OC_EventSource{ /** * send a message to the client - * @param string type - * @param object data + * @param string $type + * @param object $data * - * if only one paramater is given, a typeless message will be send with that paramater as data + * if only one parameter is given, a typeless message will be send with that parameter as data */ public function send($type, $data=null) { if(is_null($data)) { -- cgit v1.2.3 From fc2d5383119f548f58b5000ebb94422b7feb08a7 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 12 Jul 2013 17:03:51 +0200 Subject: new admin setting added which allows to turn off anonymous uploads --- apps/files/index.php | 1 + apps/files/templates/index.php | 2 +- core/js/share.js | 7 ++++++- settings/admin.php | 3 ++- settings/templates/admin.php | 10 +++++++++- 5 files changed, 19 insertions(+), 4 deletions(-) (limited to 'core/js') diff --git a/apps/files/index.php b/apps/files/index.php index 2338cf439e4..892f75a3513 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -138,5 +138,6 @@ if ($needUpgrade) { $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']); $tmpl->assign('isPublic', false); + $tmpl->assign('publicUploadEnabled', \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes')); $tmpl->printPage(); } diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 7d679bc4bf6..dacd2be0b32 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -61,7 +61,7 @@
t('Nothing in here. Upload something!'))?>
- +
+ + + ').attr({ "class": "filesize", - "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')' }).text(simpleSize); tr.append(td); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 51b3f31fb96..98fc53b71a9 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -756,9 +756,7 @@ function procesSelection(){ for(var i=0;i0){ if(selectedFolders.length==1){ diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 7d679bc4bf6..fa4cda6f6b2 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -77,7 +77,7 @@ - + diff --git a/core/js/js.js b/core/js/js.js index 5158b66d73a..cf4e72324dc 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -666,8 +666,6 @@ $(document).ready(function(){ $('.selectedActions a').tipsy({gravity:'s', fade:true, live:true}); $('a.delete').tipsy({gravity: 'e', fade:true, live:true}); $('a.action').tipsy({gravity:'s', fade:true, live:true}); - $('#headerSize').tipsy({gravity:'s', fade:true, live:true}); - $('td.filesize').tipsy({gravity:'s', fade:true, live:true}); $('td .modified').tipsy({gravity:'s', fade:true, live:true}); $('input').tipsy({gravity:'w', fade:true}); @@ -697,14 +695,6 @@ function humanFileSize(size) { return relativeSize + ' ' + readableFormat; } -function simpleFileSize(bytes) { - var mbytes = Math.round(bytes/(1024*1024/10))/10; - if(bytes == 0) { return '0'; } - else if(mbytes < 0.1) { return '< 0.1'; } - else if(mbytes > 1000) { return '> 1000'; } - else { return mbytes.toFixed(1); } -} - function formatDate(date){ if(typeof date=='number'){ date=new Date(date); diff --git a/lib/public/template.php b/lib/public/template.php index ccf19cf052c..d81a169579e 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -76,16 +76,6 @@ function relative_modified_date($timestamp) { } -/** - * @brief Return a human readable outout for a file size. - * @param $byte size of a file in byte - * @returns human readable interpretation of a file size - */ -function simple_file_size($bytes) { - return(\simple_file_size($bytes)); -} - - /** * @brief Generate html code for an options block. * @param $options the options diff --git a/lib/template.php b/lib/template.php index ae9ea187445..08df168afc6 100644 --- a/lib/template.php +++ b/lib/template.php @@ -84,24 +84,6 @@ function human_file_size( $bytes ) { return OC_Helper::humanFileSize( $bytes ); } -function simple_file_size($bytes) { - if ($bytes < 0) { - return '?'; - } - $mbytes = round($bytes / (1024 * 1024), 1); - if ($bytes == 0) { - return '0'; - } - if ($mbytes < 0.1) { - return '< 0.1'; - } - if ($mbytes > 1000) { - return '> 1000'; - } else { - return number_format($mbytes, 1); - } -} - function relative_modified_date($timestamp) { $l=OC_L10N::get('lib'); $timediff = time() - $timestamp; -- cgit v1.2.3 From 5160ea60639d58a054359834d7ac6e82096c4d57 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 22 Jul 2013 21:02:18 +0300 Subject: Show generic error when there is no error --- core/js/share.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/js') diff --git a/core/js/share.js b/core/js/share.js index 4c8fd874107..71e6136bf71 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -122,7 +122,12 @@ OC.Share={ callback(result.data); } } else { - OC.dialogs.alert(result.data.message, t('core', 'Error while sharing')); + if (result.data && result.data.message) { + var msg = result.data.message; + } else { + var msg = t('core', 'Error'); + } + OC.dialogs.alert(msg, t('core', 'Error while sharing')); } }); }, -- cgit v1.2.3 From ab997bdc68042fa292877e17bb991d79cbed0738 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 22 Jul 2013 21:02:56 +0300 Subject: Create an array entry before filling it --- core/js/share.js | 1 + 1 file changed, 1 insertion(+) (limited to 'core/js') diff --git a/core/js/share.js b/core/js/share.js index 71e6136bf71..e59669cbc2b 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -92,6 +92,7 @@ OC.Share={ } } if (shares) { + OC.Share.statuses[itemSource] = OC.Share.statuses[itemSource] || {}; OC.Share.statuses[itemSource]['link'] = link; } else { delete OC.Share.statuses[itemSource]; -- cgit v1.2.3
diff --git a/core/js/share.js b/core/js/share.js index 21e352ee1c6..4c8fd874107 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -161,7 +161,12 @@ OC.Share={ // respective checkbox should be checked or // not. + var publicUploadEnabled = $('#filestable').data('allow-public-upload'); + if (typeof publicUploadEnabled == 'undefined') { + publicUploadEnabled = 'no'; + } var allowPublicUploadStatus = false; + $.each(data.shares, function(key, value) { if (allowPublicUploadStatus) { return true; @@ -181,7 +186,7 @@ OC.Share={ html += '
'; html += ''; html += '
'; - if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE)) { + if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE) && publicUploadEnabled === 'yes') { html += '
> /> + value="1" />
t('Allow users to share items to the public with links')); ?>
> + /> +
+ t('Allow users to enable others to anonymously upload into their publicly shared folders')); ?> +
> Date: Thu, 18 Jul 2013 22:15:26 +0200 Subject: finally remove the file size obfuscation as it had more disadvantages. I was wrong, sorry. --- apps/files/js/filelist.js | 3 +-- apps/files/js/files.js | 4 +--- apps/files/templates/index.php | 2 +- apps/files/templates/part.list.php | 6 ++---- core/js/js.js | 10 ---------- lib/public/template.php | 10 ---------- lib/template.php | 18 ------------------ 7 files changed, 5 insertions(+), 48 deletions(-) (limited to 'core/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c847e2eff8b..04a9fb91649 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -47,7 +47,7 @@ var FileList={ //size column if(size!=t('files', 'Pending')){ - simpleSize=simpleFileSize(size); + simpleSize = humanFileSize(size); }else{ simpleSize=t('files', 'Pending'); } @@ -55,7 +55,6 @@ var FileList={ var lastModifiedTime = Math.round(lastModified.getTime() / 1000); td = $('t('Size (MB)')); ?>t('Size')); ?> t( 'Modified' )); ?> diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 97a9026860b..0c7d6936697 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -9,7 +9,6 @@ $totalsize = 0; ?> } else { $totalfiles++; } - $simple_file_size = OCP\simple_file_size($file['size']); // the bigger the file, the darker the shade of grey; megabytes*2 $simple_size_color = intval(160-$file['size']/(1024*1024)*2); if($simple_size_color<0) $simple_size_color = 0; @@ -52,9 +51,8 @@ $totalsize = 0; ?> - + } ?> - +