summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-04-23 13:23:20 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-04-23 13:23:20 +0200
commitf940e4a0129ffeefd746c0ebdb25132413e388c0 (patch)
tree63c4485fa6c3f4ef733fa6e7e5e3b33032aa804f /inc
parent22ef1e32c51ac82df8d6a03e1e95876100e8f6c1 (diff)
downloadrpg-f940e4a0129ffeefd746c0ebdb25132413e388c0.tar.gz
rpg-f940e4a0129ffeefd746c0ebdb25132413e388c0.tar.bz2
display uploadable file size in media manager FS#2425
Diffstat (limited to 'inc')
-rw-r--r--inc/lang/en/lang.php1
-rw-r--r--inc/media.php28
2 files changed, 29 insertions, 0 deletions
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index 2ba220e64..c1fc543fb 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -99,6 +99,7 @@ $lang['searchmedia_in'] = 'Search in %s';
$lang['txt_upload'] = 'Select file to upload';
$lang['txt_filename'] = 'Upload as (optional)';
$lang['txt_overwrt'] = 'Overwrite existing file';
+$lang['maxuploadsize'] = 'Upload max. %s per file.';
$lang['lockedby'] = 'Currently locked by';
$lang['lockexpire'] = 'Lock expires at';
diff --git a/inc/media.php b/inc/media.php
index 66984e957..841a5218e 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -1602,7 +1602,35 @@ function media_uploadform($ns, $auth, $fullscreen = false){
echo NL.'<div id="mediamanager__uploader">'.NL;
html_form('upload', $form);
+
echo '</div>'.NL;
+
+ echo '<p class="maxsize">';
+ printf($lang['maxuploadsize'],filesize_h(media_getuploadsize()));
+ echo '</p>'.NL;
+
+}
+
+/**
+ * Returns the size uploaded files may have
+ *
+ * This uses a conservative approach using the lowest number found
+ * in any of the limiting ini settings
+ *
+ * @returns int size in bytes
+ */
+function media_getuploadsize(){
+ $okay = 0;
+
+ $post = (int) php_to_byte(@ini_get('post_max_size'));
+ $suho = (int) php_to_byte(@ini_get('suhosin.post.max_value_length'));
+ $upld = (int) php_to_byte(@ini_get('upload_max_filesize'));
+
+ if($post && ($post < $okay || $okay == 0)) $okay = $post;
+ if($suho && ($suho < $okay || $okay == 0)) $okay = $suho;
+ if($upld && ($upld < $okay || $okay == 0)) $okay = $upld;
+
+ return $okay;
}
/**