aboutsummaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php24
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