diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-01-20 03:11:04 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-01-20 03:11:04 +0100 |
commit | 83d622132224fa61b1518e6bca430518cf138401 (patch) | |
tree | 53f79474af81e07f1304a1cf10e866b2d8af652b /lib/helper.php | |
parent | 8ca30d244c19b33e7e3b0da247b70160a3acc44f (diff) | |
parent | ebc0c4b85bc382efcf64ad0b2613d70a193b18f2 (diff) | |
download | nextcloud-server-83d622132224fa61b1518e6bca430518cf138401.tar.gz nextcloud-server-83d622132224fa61b1518e6bca430518cf138401.zip |
merge master into filesytem
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 6b1eaa4e6ee..d7b57d381dc 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -193,8 +193,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" ) { @@ -679,8 +680,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; } @@ -749,6 +750,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 |