* FusionForge miscellaneous utils
*
* Copyright 1999-2001, VA Linux Systems, Inc.
- * Copyright 2009-2010, Roland Mas, Franck Villaume - Capgemini
+ * Copyright 2009-2010, Roland Mas
+ * Copyright 2009-2010, Franck Villaume - Capgemini
+ * Copyright 2010, Thorsten Glaser <t.glaser@tarent.de>
*
* This file is part of FusionForge.
*
return $trace;
}
+function util_ini_get_bytes($id) {
+ $val = trim(ini_get($id));
+ $last = strtolower($val[strlen($val)-1]);
+ switch ($last) {
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ }
+ return $val;
+}
+
+function util_get_maxuploadfilesize() {
+ $postmax = util_ini_get_bytes('post_max_size');
+ $maxfile = util_ini_get_bytes('upload_max_filesize');
+
+ $postfile = (int)(($postmax * 3) / 4);
+
+ if ($postfile < $maxfile)
+ $postfile = $maxfile;
+
+ return $postfile;
+}
+
// Local Variables:
// mode: php
// c-file-style: "bsd"
<td>
<span class="important">
<?php echo _('NOTE: In some browsers you must select the file in the file-upload dialog and click "OK". Double-clicking doesn\'t register the file.')?>
+ <?php printf(_('You can probably not upload files larger than about %.2f MiB in size.'), util_get_maxuploadfilesize() / 1048576); ?><br />
</span><br />
<?php echo _('Upload a new file') ?>: <input type="file" name="userfile" size="30" />
<?php if (forge_get_config('use_ftp_uploads')) {