diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-02-05 13:36:55 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-02-05 13:36:55 +0100 |
commit | 1e79369338e8435952e2eda60a2cfc49bb6c4882 (patch) | |
tree | 12d3ac88978887f16e795c54873bbd6b99bb8ee5 /lib/private/helper.php | |
parent | 3c1ab66edac1ba2f1b398c859cd933c410ea3d8d (diff) | |
parent | 3d88b10f201b7979f250b49b10360b3581030ec7 (diff) | |
download | nextcloud-server-1e79369338e8435952e2eda60a2cfc49bb6c4882.tar.gz nextcloud-server-1e79369338e8435952e2eda60a2cfc49bb6c4882.zip |
merge master into storagestatistics-reuse
Diffstat (limited to 'lib/private/helper.php')
-rw-r--r-- | lib/private/helper.php | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php index 12784c9a5eb..58cb1b88d66 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -161,6 +161,7 @@ class OC_Helper { 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', + 'application/mspowerpoint' => 'x-office/presentation', 'application/vnd.ms-powerpoint' => 'x-office/presentation', 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', @@ -171,6 +172,7 @@ class OC_Helper { 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', + 'application/msexcel' => 'x-office/spreadsheet', 'application/vnd.ms-excel' => 'x-office/spreadsheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', @@ -180,6 +182,7 @@ class OC_Helper { 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', + 'application/msaccess' => 'database', ); if (isset($alias[$mimetype])) { @@ -445,29 +448,6 @@ class OC_Helper { * */ - //FIXME: should also check for value validation (i.e. the email is an email). - public static function init_var($s, $d = "") { - $r = $d; - if (isset($_REQUEST[$s]) && !empty($_REQUEST[$s])) { - $r = OC_Util::sanitizeHTML($_REQUEST[$s]); - } - - return $r; - } - - /** - * returns "checked"-attribute if request contains selected radio element - * OR if radio element is the default one -- maybe? - * - * @param string $s Name of radio-button element name - * @param string $v Value of current radio-button element - * @param string $d Value of default radio-button element - */ - public static function init_radio($s, $v, $d) { - if ((isset($_REQUEST[$s]) && $_REQUEST[$s] == $v) || (!isset($_REQUEST[$s]) && $v == $d)) - print "checked=\"checked\" "; - } - /** * detect if a given program is found in the search PATH * @@ -825,29 +805,46 @@ class OC_Helper { * @brief calculates the maximum upload size respecting system settings, free space and user quota * * @param string $dir the current folder where the user currently operates - * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly - * @return number of bytes representing + * @param int $freeSpace the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly + * @return int number of bytes representing */ public static function maxUploadFilesize($dir, $freeSpace = null) { - $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); - $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); - if (is_null($freeSpace)) { - $freeSpace = \OC\Files\Filesystem::free_space($dir); - } - if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) { - $maxUploadFilesize = \OC\Files\SPACE_UNLIMITED; - } elseif ((int)$upload_max_filesize === 0 or (int)$post_max_size === 0) { - $maxUploadFilesize = max($upload_max_filesize, $post_max_size); //only the non 0 value counts - } else { - $maxUploadFilesize = min($upload_max_filesize, $post_max_size); + if (is_null($freeSpace)){ + $freeSpace = self::freeSpace($dir); } + return min($freeSpace, self::uploadLimit()); + } + /** + * Calculate free space left within user quota + * + * @param string $dir the current folder where the user currently operates + * @return int number of bytes representing + */ + public static function freeSpace($dir) { + $freeSpace = \OC\Files\Filesystem::free_space($dir); if ($freeSpace !== \OC\Files\SPACE_UNKNOWN) { $freeSpace = max($freeSpace, 0); + return $freeSpace; + } else { + return INF; + } + } - return min($maxUploadFilesize, $freeSpace); + /** + * Calculate PHP upload limit + * + * @return PHP upload file size limit + */ + public static function uploadLimit() { + $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); + $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); + if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) { + return INF; + } elseif ((int)$upload_max_filesize === 0 or (int)$post_max_size === 0) { + return max($upload_max_filesize, $post_max_size); //only the non 0 value counts } else { - return $maxUploadFilesize; + return min($upload_max_filesize, $post_max_size); } } |