diff options
author | TheSFReader <TheSFReader@gmail.com> | 2013-01-25 17:15:02 +0100 |
---|---|---|
committer | TheSFReader <TheSFReader@gmail.com> | 2013-01-25 17:15:02 +0100 |
commit | 2aead5727ed99c9b9af3a2ba653a27cf794e1278 (patch) | |
tree | ec76080267f85324c6cecd34d149bc1537de3eba /lib/helper.php | |
parent | 9f5847b739c20a0b2de3672459445f08300ef790 (diff) | |
parent | 688fe0baa89f0150f3c8123c64d7cff5caa0511b (diff) | |
download | nextcloud-server-2aead5727ed99c9b9af3a2ba653a27cf794e1278.tar.gz nextcloud-server-2aead5727ed99c9b9af3a2ba653a27cf794e1278.zip |
Merge remote-tracking branch 'refs/remotes/upstream/master'
Diffstat (limited to 'lib/helper.php')
-rw-r--r-- | lib/helper.php | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/helper.php b/lib/helper.php index 540a7dceb3e..1a634075bd1 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -190,8 +190,9 @@ class OC_Helper { if(isset($alias[$mimetype])) { $mimetype=$alias[$mimetype]; } - // Replace slash with a minus + // Replace slash and backslash with a minus $mimetype = str_replace( "/", "-", $mimetype ); + $mimetype = str_replace( "\\", "-", $mimetype ); // Is it a dir? if( $mimetype == "dir" ) { @@ -676,8 +677,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; } @@ -746,6 +747,23 @@ class OC_Helper { } /** + * @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); + } + + /** * Checks if a function is available * @param string $function_name * @return bool |