Index: config_defaults_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/config_defaults_inc.php,v
retrieving revision 1.365
diff -u -r1.365 config_defaults_inc.php
--- config_defaults_inc.php	4 Oct 2007 05:59:04 -0000	1.365
+++ config_defaults_inc.php	21 Oct 2007 03:57:04 -0000
@@ -825,6 +825,9 @@
 	# absolute path to the default upload folder.  Requires trailing / or \
 	$g_absolute_path_default_upload_folder = '';
 
+	# Maximum file number that can be uploaded at once
+	$g_max_file_num		= 3;
+
 	############################
 	# Mantis HTML Settings
 	############################
Index: bug_view_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_view_page.php,v
retrieving revision 1.89
diff -u -r1.89 bug_view_page.php
--- bug_view_page.php	29 Sep 2007 00:07:57 -0000	1.89
+++ bug_view_page.php	21 Oct 2007 03:57:04 -0000
@@ -51,6 +51,8 @@
 
 	$t_bugslist = gpc_get_cookie( config_get( 'bug_list_cookie' ), false );
 
+	$g_enable_multiple_upload = ON;
+
 	html_page_top1( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
 	html_page_top2();
 
Index: bug_file_upload_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_file_upload_inc.php,v
retrieving revision 1.39
diff -u -r1.39 bug_file_upload_inc.php
--- bug_file_upload_inc.php	12 Aug 2007 22:43:47 -0000	1.39
+++ bug_file_upload_inc.php	21 Oct 2007 03:57:04 -0000
@@ -45,8 +45,10 @@
 	<td width="85%">
 		<input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" />
 		<input type="hidden" name="max_file_size" value="<?php echo $t_max_file_size ?>" />
-		<input name="file" type="file" size="40" />
+		<input id="file" name="file[]" type="file" size="40" />
 		<input type="submit" class="button" value="<?php echo lang_get( 'upload_file_button' ) ?>" />
+		<div id="file_list"></div>
+		<?php html_multiupload_javascript( 'file', 'file_list', config_get( 'max_file_num'), 40 ) ?>
 	</td>
 </tr>
 </table>
Index: bug_report.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_report.php,v
retrieving revision 1.49
diff -u -r1.49 bug_report.php
--- bug_report.php	24 Aug 2007 14:44:45 -0000	1.49
+++ bug_report.php	21 Oct 2007 03:57:04 -0000
@@ -22,6 +22,13 @@
 
 	access_ensure_project_level( config_get('report_bug_threshold' ) );
 
+	$f_file_arr					= gpc_get_file( 'file', -1 ); #@@@ (thraxisp) Note that this always returns a structure
+															# size = 0, if no file
+	if ( $f_file_arr === -1 ) {
+		# _POST/_FILES does not seem to get populated if you exceed size limit so check if bug_id is -1
+		trigger_error( ERROR_FILE_TOO_BIG, ERROR );
+	}
+
 	$t_bug_data = new BugData;
 	$t_bug_data->build				= gpc_get_string( 'build', '' );
 	$t_bug_data->platform				= gpc_get_string( 'platform', '' );
@@ -41,8 +48,6 @@
 	$t_bug_data->steps_to_reproduce	= gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) );
 	$t_bug_data->additional_information	= gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) );
 
-	$f_file					= gpc_get_file( 'file', null ); #@@@ (thraxisp) Note that this always returns a structure
-															# size = 0, if no file
 	$f_report_stay			= gpc_get_bool( 'report_stay', false );
 	$t_bug_data->project_id			= gpc_get_int( 'project_id' );
 
@@ -91,9 +96,11 @@
 	$t_bug_id = bug_create( $t_bug_data );
 
 	# Handle the file upload
-	if ( !is_blank( $f_file['tmp_name'] ) && ( 0 < $f_file['size'] ) ) {
-    	$f_file_error =  ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0;
-		file_add( $t_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'bug', $f_file_error );
+	for ( $i = 0, $size = sizeof( $f_file_arr['tmp_name'] ); $i < $size; $i++ ) {
+		if ( !is_blank( $f_file_arr['tmp_name'][$i] ) && ( 0 < $f_file_arr['size'][$i] ) ) {
+    		$f_file_error =  ( isset( $f_file_arr['error'][$i] ) ) ? $f_file_arr['error'][$i] : 0;
+			file_add( $t_bug_id, $f_file_arr['tmp_name'][$i], $f_file_arr['name'][$i], $f_file_arr['type'][$i], 'bug', $f_file_error );
+		}
 	}
 
 	# Handle custom field submission
Index: bug_report_advanced_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_report_advanced_page.php,v
retrieving revision 1.66
diff -u -r1.66 bug_report_advanced_page.php
--- bug_report_advanced_page.php	24 Aug 2007 14:44:46 -0000	1.66
+++ bug_report_advanced_page.php	21 Oct 2007 03:57:04 -0000
@@ -110,6 +110,8 @@
 
 	$f_report_stay			= gpc_get_bool( 'report_stay', false );
 
+	$g_enable_multiple_upload = ON;
+
 	html_page_top1( lang_get( 'report_bug_link' ) );
 	html_page_top2();
 
@@ -471,7 +473,9 @@
 	</td>
 	<td>
 		<input type="hidden" name="max_file_size" value="<?php echo $t_max_file_size ?>" />
-		<input <?php echo helper_get_tab_index() ?> name="file" type="file" size="60" />
+		<input <?php echo helper_get_tab_index() ?> id="file" name="file[]" type="file" size="60" />
+		<div id="file_list"></div>
+		<?php html_multiupload_javascript( 'file', 'file_list', config_get( 'max_file_num'), 60 ) ?>
 	</td>
 </tr>
 <?php } ?>
Index: bug_view_advanced_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_view_advanced_page.php,v
retrieving revision 1.87
diff -u -r1.87 bug_view_advanced_page.php
--- bug_view_advanced_page.php	29 Sep 2007 00:07:56 -0000	1.87
+++ bug_view_advanced_page.php	21 Oct 2007 03:57:04 -0000
@@ -43,6 +43,8 @@
 
 	compress_enable();
 
+	$g_enable_multiple_upload = ON;
+
 	html_page_top1( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
 	html_page_top2();
 
Index: bug_file_add.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_file_add.php,v
retrieving revision 1.49
diff -u -r1.49 bug_file_add.php
--- bug_file_add.php	8 May 2007 21:42:24 -0000	1.49
+++ bug_file_add.php	21 Oct 2007 03:57:04 -0000
@@ -21,9 +21,9 @@
 ?>
 <?php
 	$f_bug_id	= gpc_get_int( 'bug_id', -1 );
-	$f_file		= gpc_get_file( 'file', -1 );
+	$f_file_arr	= gpc_get_file( 'file', -1 );
 
-	if ( $f_bug_id == -1 && $f_file	== -1 ) {
+	if ( $f_bug_id === -1 && $f_file_arr === -1 ) {
 		# _POST/_FILES does not seem to get populated if you exceed size limit so check if bug_id is -1
 		trigger_error( ERROR_FILE_TOO_BIG, ERROR );
 	}
@@ -41,8 +41,12 @@
 		$g_project_override = $t_bug->project_id;
 	}
 
-    $f_file_error =  ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0;
-	file_add( $f_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'bug', $f_file_error );
+	for ( $i = 0, $size = sizeof( $f_file_arr['tmp_name'] ); $i < $size; $i++ ) {
+		if ( ! is_blank( $f_file_arr['name'][$i] ) ) {
+		    $f_file_error =  ( isset( $f_file_arr['error'][$i] ) ) ? $f_file_arr['error'][$i] : 0;
+			file_add( $f_bug_id, $f_file_arr['tmp_name'][$i], $f_file_arr['name'][$i], $f_file_arr['type'][$i], 'bug', $f_file_error );
+		}
+	}
 
 	# Determine which view page to redirect back to.
 	$t_redirect_url = string_get_bug_view_url( $f_bug_id );
Index: bug_report_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_report_page.php,v
retrieving revision 1.64
diff -u -r1.64 bug_report_page.php
--- bug_report_page.php	13 Jul 2007 07:58:27 -0000	1.64
+++ bug_report_page.php	21 Oct 2007 03:57:04 -0000
@@ -91,6 +91,8 @@
 
 	$f_report_stay			= gpc_get_bool( 'report_stay', false );
 
+	$g_enable_multiple_upload = ON;
+
 	html_page_top1( lang_get( 'report_bug_link' ) );
 	html_page_top2();
 
@@ -301,7 +303,9 @@
 	</td>
 	<td>
 		<input type="hidden" name="max_file_size" value="<?php echo $t_max_file_size ?>" />
-		<input <?php echo helper_get_tab_index() ?> name="file" type="file" size="60" />
+		<input <?php echo helper_get_tab_index() ?> id="file" name="file[]" type="file" size="60" />
+		<div id="file_list"></div>
+		<?php html_multiupload_javascript( 'file', 'file_list', config_get( 'max_file_num'), 60 ) ?>
 	</td>
 </tr>
 <?php } ?>
Index: core/file_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/file_api.php,v
retrieving revision 1.85
diff -u -r1.85 file_api.php
--- core/file_api.php	17 Sep 2007 02:38:17 -0000	1.85
+++ core/file_api.php	21 Oct 2007 03:57:05 -0000
@@ -580,10 +580,12 @@
 		}
 
 		if ( !file_type_check( $p_file_name ) ) {
+			error_parameters( $p_file_name );
 			trigger_error( ERROR_FILE_NOT_ALLOWED, ERROR );
 		}
 
 		if ( !file_is_name_unique( $p_file_name, $p_bug_id ) ) {
+			error_parameters( $p_file_name );
 			trigger_error( ERROR_DUPLICATE_FILE, ERROR );
 		}
 
@@ -650,6 +652,7 @@
 
 					$c_content = "''";
 				} else {
+					error_parameters( $p_file_name );
 					trigger_error( ERROR_FILE_DUPLICATE, ERROR );
 				}
 				break;
Index: core/html_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/html_api.php,v
retrieving revision 1.218
diff -u -r1.218 html_api.php
--- core/html_api.php	28 Sep 2007 02:52:37 -0000	1.218
+++ core/html_api.php	21 Oct 2007 03:57:05 -0000
@@ -262,8 +262,14 @@
 			global $g_enable_projax;
 
 			if ( $g_enable_projax ) {
-				echo '<script type="text/javascript" src="javascript/projax/prototype.js"></script>';
-				echo '<script type="text/javascript" src="javascript/projax/scriptaculous.js"></script>';
+				echo '<script type="text/javascript" src="javascript/projax/prototype.js"></script>' . "\n";
+				echo '<script type="text/javascript" src="javascript/projax/scriptaculous.js"></script>' . "\n";
+			}
+
+			global $g_enable_multiple_upload;
+
+			if ( $g_enable_multiple_upload ) {
+				echo "\t" . '<script type="text/javascript" src="javascript/multifile.js"></script>' . "\n";
 			}
 		}
 	}
@@ -1248,4 +1254,21 @@
 		html_button_tag_update( $p_tag_id );
 		html_button_tag_delete( $p_tag_id );
 	}
+	
+	/**
+	 * Print JavaScript for mutilple file upload
+	 * @param string element id of input tag 
+	 * @param string element id of div tag which lists upload file names
+	 * @param int max number of upload files
+	 * @param int input field size
+	 * @access public
+	 */
+	function html_multiupload_javascript( $p_intput_id, $p_list_id, $p_max_file_num, $p_size ) {
+		echo '<script>' . "\n";
+		echo '<!--' . "\n";
+		echo "\t" . "var multi_selector = new MultiSelector( document.getElementById( '$p_list_id' ), $p_size, $p_max_file_num )" . "\n";
+		echo "\t" . "multi_selector.addElement( document.getElementById( '$p_intput_id' ) )" . "\n";
+		echo '// -->' . "\n";
+		echo '</script>' . "\n";
+	}    	
 ?>
Index: lang/strings_english.txt
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v
retrieving revision 1.316
diff -u -r1.316 strings_english.txt
--- lang/strings_english.txt	22 Sep 2007 22:51:15 -0000	1.316
+++ lang/strings_english.txt	21 Oct 2007 03:57:05 -0000
@@ -195,7 +195,7 @@
 $MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'No file specified';
 $MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'The file type is disallowed';
 $MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'The directory does not exist. Please check the project settings.';
-$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'This is a duplicate file.  Please delete the file first.';
+$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'This is a duplicate file (%s).  Please delete the file first.';
 $MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'A project with that name already exists.';
 $MANTIS_ERROR[ERROR_EMPTY_FIELD] = 'A necessary field \'%s\' was empty.  Please recheck your inputs.';
 $MANTIS_ERROR[ERROR_PROTECTED_ACCOUNT] = 'This account is protected.  You are not allowed to access this until the account protection is lifted.';
@@ -228,7 +228,7 @@
 $MANTIS_ERROR[ERROR_EMAIL_INVALID]	 = 'Invalid email.';
 $MANTIS_ERROR[ERROR_EMAIL_DISPOSABLE] = 'It is not allowed to use disposable email addresses.';
 $MANTIS_ERROR[ERROR_USER_PROFILE_NOT_FOUND] = 'Profile not found.';
-$MANTIS_ERROR[ERROR_FILE_NOT_ALLOWED]	 = 'File type not allowed for uploads.';
+$MANTIS_ERROR[ERROR_FILE_NOT_ALLOWED]	 = 'File type not allowed for uploads (%s).';
 $MANTIS_ERROR[ERROR_FILE_DUPLICATE]	 = 'This is a duplicate file.  Please delete the file first.';
 $MANTIS_ERROR[ERROR_FILE_INVALID_UPLOAD_PATH] = 'Invalid upload path.  Directory either does not exist or not writable to webserver';
 $MANTIS_ERROR[ERROR_FILE_NO_UPLOAD_FAILURE] = 'No file was uploaded. Please go back and Choose a file before pressing Upload';
