aboutsummaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorTheSFReader <TheSFReader@gmail.com>2013-01-25 17:15:02 +0100
committerTheSFReader <TheSFReader@gmail.com>2013-01-25 17:15:02 +0100
commit2aead5727ed99c9b9af3a2ba653a27cf794e1278 (patch)
treeec76080267f85324c6cecd34d149bc1537de3eba /lib/helper.php
parent9f5847b739c20a0b2de3672459445f08300ef790 (diff)
parent688fe0baa89f0150f3c8123c64d7cff5caa0511b (diff)
downloadnextcloud-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.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