[Fusionforge-commits] r13627 - branches/Branch_5_1/src/common/include

Alain Peyrat aljeux at fusionforge.org
Tue Jun 28 18:51:02 CEST 2011


Author: aljeux
Date: 2011-06-28 18:51:01 +0200 (Tue, 28 Jun 2011)
New Revision: 13627

Modified:
   branches/Branch_5_1/src/common/include/pre.php
Log:
Detect upload larger that upload allowed size.

Modified: branches/Branch_5_1/src/common/include/pre.php
===================================================================
--- branches/Branch_5_1/src/common/include/pre.php	2011-06-28 16:50:50 UTC (rev 13626)
+++ branches/Branch_5_1/src/common/include/pre.php	2011-06-28 16:51:01 UTC (rev 13627)
@@ -250,6 +250,26 @@
 ini_set('date.timezone', forge_get_config ('default_timezone'));
 
 if (isset($_SERVER['SERVER_SOFTWARE'])) { // We're on the web
+	// Detect upload larger that upload allowed size.
+	if ( $_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) &&
+		empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0 )
+	{
+		$displayMaxSize = ini_get('post_max_size');
+
+		switch ( substr($displayMaxSize,-1) )
+		{
+			case 'G':
+				$displayMaxSize = $displayMaxSize * 1024;
+			case 'M':
+				$displayMaxSize = $displayMaxSize * 1024;
+			case 'K':
+				$displayMaxSize = $displayMaxSize * 1024;
+		}
+
+		$error_msg = sprintf(_('Posted data is too large. %1$s exceeds the maximum size of %2$s'),
+			human_readable_bytes($_SERVER['CONTENT_LENGTH']), human_readable_bytes($displayMaxSize));
+	}
+
 	// exit_error() and variants (for the web)
 	require_once $gfcommon.'include/exit.php';
 




More information about the Fusionforge-commits mailing list