[evolvis-commits] r16893: Merged from Evolvis (wui-tweaks branch): display plausible upload size limit in FRS

mirabilos at evolvis.org mirabilos at evolvis.org
Tue Mar 1 01:46:28 CET 2011


Author: mirabilos
Date: 2011-03-01 01:46:28 +0100 (Tue, 01 Mar 2011)
New Revision: 16893

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/include/utils.php
   trunk/gforge_base/evolvisforge-5.1/src/www/frs/admin/qrs.php
Log:
Merged from Evolvis (wui-tweaks branch): display plausible upload size limit in FRS

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/utils.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/utils.php	2011-03-01 00:46:26 UTC (rev 16892)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/utils.php	2011-03-01 00:46:28 UTC (rev 16893)
@@ -3,7 +3,9 @@
  * 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 at tarent.de>
  *
  * This file is part of FusionForge.
  *
@@ -1331,6 +1333,32 @@
 	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"

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/frs/admin/qrs.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/frs/admin/qrs.php	2011-03-01 00:46:26 UTC (rev 16892)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/frs/admin/qrs.php	2011-03-01 00:46:28 UTC (rev 16893)
@@ -195,6 +195,7 @@
 		<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')) {



More information about the evolvis-commits mailing list