From 39d874cd902a4e3d4f7ae313ec5e15bafe35df13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 20 Dec 2012 17:16:01 +0100 Subject: [PATCH 1/5] the maximum upload size is now part of the response of the upload and delete operation. the maximum upload size is updated within the browser once an upload or delete operation has been finished --- apps/files/ajax/delete.php | 16 ++++++++++++++-- apps/files/ajax/upload.php | 38 ++++++++++++++++++++++++++++++++------ apps/files/index.php | 8 +------- apps/files/js/files.js | 26 ++++++++++++++++++++++++-- lib/helper.php | 17 +++++++++++++++++ lib/public/util.php | 10 ++++++++++ 6 files changed, 98 insertions(+), 17 deletions(-) diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php index 6532b76df21..bb1f3fff87b 100644 --- a/apps/files/ajax/delete.php +++ b/apps/files/ajax/delete.php @@ -21,8 +21,20 @@ foreach($files as $file) { } } +// updated max file size after upload +$l=new OC_L10N('files'); +$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); +$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); +$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + if($success) { - OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files ))); + OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files, + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } else { - OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError ))); + OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError, + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index e7823bc4ffb..4a9816454d9 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -9,8 +9,17 @@ OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); +// current max upload size +$l=new OC_L10N('files'); +$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); +$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); +$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + if (!isset($_FILES['files'])) { - OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' ))); + OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error', + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } foreach ($_FILES['files']['error'] as $error) { @@ -27,7 +36,10 @@ foreach ($_FILES['files']['error'] as $error) { UPLOAD_ERR_NO_TMP_DIR=>$l->t('Missing a temporary folder'), UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'), ); - OCP\JSON::error(array('data' => array( 'message' => $errors[$error] ))); + OCP\JSON::error(array('data' => array( 'message' => $errors[$error], + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } } @@ -41,7 +53,10 @@ foreach($files['size'] as $size) { $totalSize+=$size; } if($totalSize>OC_Filesystem::free_space($dir)) { - OCP\JSON::error(array('data' => array( 'message' => 'Not enough space available' ))); + OCP\JSON::error(array('data' => array( 'message' => 'Not enough space available', + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } @@ -55,11 +70,19 @@ if(strpos($dir, '..') === false) { if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = OC_FileCache::get($target); $id = OC_FileCache::getId($target); - $result[]=array( 'status' => 'success', + // updated max file size after upload + $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); + $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); + $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + + $result[]=array( 'status' => 'success', 'mime'=>$meta['mimetype'], 'size'=>$meta['size'], 'id'=>$id, - 'name'=>basename($target)); + 'name'=>basename($target), + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ); } } OCP\JSON::encodedPrint($result); @@ -68,4 +91,7 @@ if(strpos($dir, '..') === false) { $error='invalid dir'; } -OCP\JSON::error(array('data' => array('error' => $error, 'file' => $fileName))); +OCP\JSON::error(array('data' => array('error' => $error, 'file' => $fileName, + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize +))); diff --git a/apps/files/index.php b/apps/files/index.php index b64bde44cc0..8b92bcc3728 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -79,13 +79,7 @@ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false); -$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); -$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); -$maxUploadFilesize = min($upload_max_filesize, $post_max_size); - -$freeSpace = OC_Filesystem::free_space($dir); -$freeSpace = max($freeSpace, 0); -$maxUploadFilesize = min($maxUploadFilesize, $freeSpace); +$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); $permissions = OCP\PERMISSION_READ; if (OC_Filesystem::isUpdatable($dir . '/')) { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6a37d9e7f53..e35dbe673d9 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,6 +26,23 @@ Files={ }); procesSelection(); }, + updateMaxUploadFilesize:function(response) { + if(response == undefined) { + return; + } + if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { + $('#max_upload').val(response.data.uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); + } + if(response[0] == undefined) { + return; + } + if(response[0].uploadMaxFilesize !== undefined) { + $('#max_upload').val(response[0].uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); + } + + }, containsInvalidCharacters:function (name) { var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { @@ -304,6 +321,7 @@ $(document).ready(function() { $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); } + Files.updateMaxUploadFilesize(response); var file=response[0]; // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; @@ -354,7 +372,9 @@ $(document).ready(function() { .success(function(result, textStatus, jqXHR) { var response; response=jQuery.parseJSON(result); - if(response[0] != undefined && response[0].status == 'success') { + Files.updateMaxUploadFilesize(response); + + if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id); @@ -384,7 +404,8 @@ $(document).ready(function() { data.submit().success(function(data, status) { // in safari data is a string response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText); - if(response[0] != undefined && response[0].status == 'success') { + Files.updateMaxUploadFilesize(response); + if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id); @@ -712,6 +733,7 @@ scanFiles.scanning=false; function boolOperationFinished(data, callback) { result = jQuery.parseJSON(data.responseText); + Files.updateMaxUploadFilesize(result); if(result.status == 'success'){ callback.call(); } else { diff --git a/lib/helper.php b/lib/helper.php index be4e4e52677..91b22e48f89 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -758,4 +758,21 @@ class OC_Helper { } return $str; } + + /** + * @brief calculates the maximum upload size respecting system settings, free space and user quota + * + * @param $dir the current folder where the user currently operates + * @return number of bytes representing + */ + public static function maxUploadFilesize($dir) { + $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); + $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); + $maxUploadFilesize = min($upload_max_filesize, $post_max_size); + + $freeSpace = OC_Filesystem::free_space($dir); + $freeSpace = max($freeSpace, 0); + + return min($maxUploadFilesize, $freeSpace); + } } diff --git a/lib/public/util.php b/lib/public/util.php index 9727cfda284..9e641c6881c 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -367,4 +367,14 @@ class Util { public static function recursiveArraySearch($haystack, $needle, $index = null) { return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index)); } + + /** + * @brief calculates the maximum upload size respecting system settings, free space and user quota + * + * @param $dir the current folder where the user currently operates + * @return number of bytes representing + */ + public static function maxUploadFilesize($dir) { + return \OC_Helper::maxUploadFilesize($dir); + } } From 362860c5b5a919dfbefc9aa2873618dc0fc34fda Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 16:44:25 +0100 Subject: [PATCH 2/5] adding jquery-visibility https://github.com/mathiasbynens/jquery-visibility MIT and GPL licensed --- apps/files/js/jquery-visibility.js | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 apps/files/js/jquery-visibility.js diff --git a/apps/files/js/jquery-visibility.js b/apps/files/js/jquery-visibility.js new file mode 100644 index 00000000000..a824bf68730 --- /dev/null +++ b/apps/files/js/jquery-visibility.js @@ -0,0 +1,32 @@ +/*! http://mths.be/visibility v1.0.5 by @mathias */ +(function (window, document, $, undefined) { + + var prefix, + property, +// In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior + eventName = 'onfocusin' in document && 'hasFocus' in document ? 'focusin focusout' : 'focus blur', + prefixes = ['', 'moz', 'ms', 'o', 'webkit'], + $support = $.support, + $event = $.event; + + while ((property = prefix = prefixes.pop()) != undefined) { + property = (prefix ? prefix + 'H' : 'h') + 'idden'; + if ($support.pageVisibility = typeof document[property] == 'boolean') { + eventName = prefix + 'visibilitychange'; + break; + } + } + + $(/blur$/.test(eventName) ? window : document).on(eventName, function (event) { + var type = event.type, + originalEvent = event.originalEvent, + toElement = originalEvent.toElement; +// If it’s a `{focusin,focusout}` event (IE), `fromElement` and `toElement` should both be `null` or `undefined`; +// else, the page visibility hasn’t changed, but the user just clicked somewhere in the doc. +// In IE9, we need to check the `relatedTarget` property instead. + if (!/^focus./.test(type) || (toElement == undefined && originalEvent.fromElement == undefined && originalEvent.relatedTarget == undefined)) { + $event.trigger((property && document[property] || /^(?:blur|focusout)$/.test(type) ? 'hide' : 'show') + '.visibility'); + } + }); + +}(this, document, jQuery)); From 938254a1c015c447b24fe1f3e64d8026f4dda8c3 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 16:45:32 +0100 Subject: [PATCH 3/5] load jquery-visibility --- apps/files/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files/index.php b/apps/files/index.php index 8b92bcc3728..959c7e4f7ea 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -28,6 +28,7 @@ OCP\User::checkLoggedIn(); OCP\Util::addStyle('files', 'files'); OCP\Util::addscript('files', 'jquery.iframe-transport'); OCP\Util::addscript('files', 'jquery.fileupload'); +OCP\Util::addscript('files', 'jquery-visibility'); OCP\Util::addscript('files', 'files'); OCP\Util::addscript('files', 'filelist'); OCP\Util::addscript('files', 'fileactions'); From e560cba76beb918a2c127b931b6d409abd9f03ab Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 16:47:28 +0100 Subject: [PATCH 4/5] adding a ajax call to get the current file storage stats like free space logic to call it every 5 minutes make use of visibility API/jquery-visibility to perform the ajax call only if the browser is visible/in use --- apps/files/ajax/getstoragestats.php | 16 ++++++++++++++++ apps/files/js/files.js | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 apps/files/ajax/getstoragestats.php diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php new file mode 100644 index 00000000000..e55e346ed67 --- /dev/null +++ b/apps/files/ajax/getstoragestats.php @@ -0,0 +1,16 @@ +t('Upload') . ' max. ' . $maxHumanFilesize; + +// send back json +OCP\JSON::success(array('data' => array('uploadMaxFilesize' => $maxUploadFilesize, + 'maxHumanFilesize' => $maxHumanFilesize +))); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 96b3cc5b627..440aeeaf6a6 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -732,6 +732,32 @@ $(document).ready(function() { }); resizeBreadcrumbs(true); + + // file space size sync + function update_storage_statistics() { + $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) { + Files.updateMaxUploadFilesize(response); + }); + } + + // start on load - we ask the server every 5 minutes + var update_storage_statistics_interval = 5*60*1000; + var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); + + // Use jquery-visibility to de-/re-activate file stats sync + if ($.support.pageVisibility) { + $(document).on({ + 'show.visibility': function() { + if (!update_storage_statistics_interval_id) { + update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); + } + }, + 'hide.visibility': function() { + clearInterval(update_storage_statistics_interval_id); + update_storage_statistics_interval_id = 0; + } + }); + } }); function scanFiles(force,dir){ From 5ff29b4348a1dcb9ed32273133b1c787aaf5c72c Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 18 Jan 2013 20:09:03 +0100 Subject: [PATCH 5/5] fixing indent --- apps/files/ajax/delete.php | 12 +++++----- apps/files/ajax/upload.php | 36 ++++++++++++++--------------- apps/files/js/files.js | 46 +++++++++++++++++++------------------- lib/helper.php | 32 +++++++++++++------------- lib/public/util.php | 20 ++++++++--------- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php index bb1f3fff87b..293543c547f 100644 --- a/apps/files/ajax/delete.php +++ b/apps/files/ajax/delete.php @@ -29,12 +29,12 @@ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; if($success) { OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files, - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } else { OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError, - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 35463095988..93398019608 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -18,9 +18,9 @@ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; if (!isset($_FILES['files'])) { OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } @@ -38,9 +38,9 @@ foreach ($_FILES['files']['error'] as $error) { UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'), ); OCP\JSON::error(array('data' => array( 'message' => $errors[$error], - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } } @@ -55,8 +55,8 @@ foreach($files['size'] as $size) { } if($totalSize>OC_Filesystem::free_space($dir)) { OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize))); exit(); } @@ -70,19 +70,19 @@ if(strpos($dir, '..') === false) { if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = OC_FileCache::get($target); $id = OC_FileCache::getId($target); - // updated max file size after upload - $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); - $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); - $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + // updated max file size after upload + $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); + $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); + $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; - $result[]=array( 'status' => 'success', + $result[]=array( 'status' => 'success', 'mime'=>$meta['mimetype'], 'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ); } } OCP\JSON::encodedPrint($result); @@ -92,6 +92,6 @@ if(strpos($dir, '..') === false) { } OCP\JSON::error(array('data' => array('message' => $error, - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize ))); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 440aeeaf6a6..a4836e6c504 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,23 +26,23 @@ Files={ }); procesSelection(); }, - updateMaxUploadFilesize:function(response) { - if(response == undefined) { - return; - } - if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { - $('#max_upload').val(response.data.uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); - } - if(response[0] == undefined) { - return; - } - if(response[0].uploadMaxFilesize !== undefined) { - $('#max_upload').val(response[0].uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); - } - - }, + updateMaxUploadFilesize:function(response) { + if(response == undefined) { + return; + } + if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { + $('#max_upload').val(response.data.uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); + } + if(response[0] == undefined) { + return; + } + if(response[0].uploadMaxFilesize !== undefined) { + $('#max_upload').val(response[0].uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); + } + + }, isFileNameValid:function (name) { if (name === '.') { $('#notification').text(t('files', '\'.\' is an invalid file name.')); @@ -333,7 +333,7 @@ $(document).ready(function() { $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); } - Files.updateMaxUploadFilesize(response); + Files.updateMaxUploadFilesize(response); var file=response[0]; // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; @@ -386,9 +386,9 @@ $(document).ready(function() { .success(function(result, textStatus, jqXHR) { var response; response=jQuery.parseJSON(result); - Files.updateMaxUploadFilesize(response); + Files.updateMaxUploadFilesize(response); - if(response[0] != undefined && response[0].status == 'success') { + if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id); @@ -421,8 +421,8 @@ $(document).ready(function() { data.submit().success(function(data, status) { // in safari data is a string response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText); - Files.updateMaxUploadFilesize(response); - if(response[0] != undefined && response[0].status == 'success') { + Files.updateMaxUploadFilesize(response); + if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id); @@ -787,7 +787,7 @@ scanFiles.scanning=false; function boolOperationFinished(data, callback) { result = jQuery.parseJSON(data.responseText); - Files.updateMaxUploadFilesize(result); + Files.updateMaxUploadFilesize(result); if(result.status == 'success'){ callback.call(); } else { diff --git a/lib/helper.php b/lib/helper.php index eb07550d229..f19ab529bfe 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -695,8 +695,8 @@ class OC_Helper { $start = intval($start); $length = intval($length); $string = mb_substr($string, 0, $start, $encoding) . - $replacement . - mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding); + $replacement . + mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding); return $string; } @@ -764,22 +764,22 @@ class OC_Helper { return $str; } - /** - * @brief calculates the maximum upload size respecting system settings, free space and user quota - * - * @param $dir the current folder where the user currently operates - * @return number of bytes representing - */ - public static function maxUploadFilesize($dir) { - $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); - $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); - $maxUploadFilesize = min($upload_max_filesize, $post_max_size); + /** + * @brief calculates the maximum upload size respecting system settings, free space and user quota + * + * @param $dir the current folder where the user currently operates + * @return number of bytes representing + */ + public static function maxUploadFilesize($dir) { + $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); + $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); + $maxUploadFilesize = min($upload_max_filesize, $post_max_size); - $freeSpace = OC_Filesystem::free_space($dir); - $freeSpace = max($freeSpace, 0); + $freeSpace = OC_Filesystem::free_space($dir); + $freeSpace = max($freeSpace, 0); - return min($maxUploadFilesize, $freeSpace); - } + return min($maxUploadFilesize, $freeSpace); + } /** * Checks if a function is available diff --git a/lib/public/util.php b/lib/public/util.php index 2dcf11faa75..c4ac2715f31 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -203,7 +203,7 @@ class Util { $host_name = self::getServerHostName(); // handle localhost installations if ($host_name === 'localhost') { - $host_name = "example.com"; + $host_name = "example.com"; } return $user_part.'@'.$host_name; } @@ -368,13 +368,13 @@ class Util { return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index)); } - /** - * @brief calculates the maximum upload size respecting system settings, free space and user quota - * - * @param $dir the current folder where the user currently operates - * @return number of bytes representing - */ - public static function maxUploadFilesize($dir) { - return \OC_Helper::maxUploadFilesize($dir); - } + /** + * @brief calculates the maximum upload size respecting system settings, free space and user quota + * + * @param $dir the current folder where the user currently operates + * @return number of bytes representing + */ + public static function maxUploadFilesize($dir) { + return \OC_Helper::maxUploadFilesize($dir); + } }