View Issue Details

IDProjectCategoryView StatusLast Update
0010576mantisbtplug-inspublic2016-07-19 04:19
Reporterdominik Assigned Tovboctor  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionduplicate 
Product Version1.2.0a1 
Summary0010576: File uploads by drag & drop and copy & paste
Description

I implemented a feature for drag & drop file upload to attach files to a ticket. I found a java applet which supports drag & drop of multiple files and copy & paste too. The lite version of this applet is free but has some limitations (maximum upload size is 1 MB and it supports no redirecting after file is uploaded so the files are not visible unless you reload the page manually). The standard version and the plus version do not have this limitations and are recommended for use. All applets may be downloaded/bought here: http://www.radinks.com/downloads/upload.php [^]

For everybody who is interested in that feature, please follow theses steps for installation:

a) Implement patch "2009-06-10_Drag_and_Drop_File_Upload_for_1.2.0a1.patch"
b) execute the sql query: ALTER TABLE mantis_user_pref_table ADD drag_and_drop_file_upload TINYINT( 4 ) NOT NULL DEFAULT '0' COMMENT 'flag for drag_and_drop_file_upload enabled/disabled';
c) download the java applet and copy it to the folder /plugins/fileupload (only standard or plus version - the patch contains already the lite version)
d) add the following parameters to config_inc.php:

###########################

Drag and Drop File Upload

###########################

There are three different Rad Upload Applets available:

- Rad Upload Lite (FREE but maximum upload limit is 1 MB and no redirect after upload allowed so you don't see your uploaded files immediately)

- Rad Upload (standard version, should satisfy all your needs)

- Rad Upload Plus (enterprise version with enhanced features like resume uploads etc.)

#

For best results use the standard or the plus version (no file upload limitations, additional "select files"-menu when clicking with your left

mouse button in the dropbox and redirect after upload so you immediately see your uploaded files attached to the ticket)

#

You need to download (http://www.radinks.com/downloads/upload.php) [^] the version you want and copy the

JAR-file (dndlite.jar, dnd.jar or dndplus.jar) into the folder /plugins/fileupload/

After that configure the settings below AND in the file /plugins/fileupload/config.php

see (http://www.radinks.com/upload/settings) [^] for details

Turn on Drag and Drop File Upload (Java Applet)

$g_drag_and_drop_file_upload_enabled = ON;

What kind of applet do you want to use (lite, standard or plus)?

$g_drag_and_drop_file_upload_applet_type = 'plus';

Property file for Drag and Drop File Upload

$g_drag_and_drop_file_upload_config_file = 'config.php';

Name of the Applet (displayed when asking if applet shall be executed)

$g_drag_and_drop_file_upload_applet_name = 'Mantis Drag & Drop File Upload';

Width and height of the dropbox zone

$g_drag_and_drop_file_upload_width = 210;
$g_drag_and_drop_file_upload_height = 40;

use this option when you encounter problems with ssl proxies (list of ip addresses when to use only http)

$g_drag_and_drop_file_upload_only_by_http = '';

e) Further configuration/customizing may be done with /plugins/fileupload/config.php (optional)

This feature may be enabled/disabled globally with the parameter $g_drag_and_drop_file_upload_enabled. Additionally every user may enable/disable it by himself in the "My Account - Preferences" page...

Tagspatch
Attached Files
2009-06-10_Drag_and_Drop_File_Upload_for_1.2.0a1.patch (21,560 bytes)   
Index: account_prefs_inc.php
===================================================================
--- account_prefs_inc.php	(revision 281)
+++ account_prefs_inc.php	(working copy)
@@ -297,6 +297,14 @@
 		</select>
 	</td>
 </tr>
+<tr class="row-1">
+	<td class="category">
+		<?php echo lang_get( 'drag_and_drop_file_upload' ) ?>
+	</td>
+	<td>
+		<input type="checkbox" name="drag_and_drop_file_upload" <?php check_checked( $t_pref->drag_and_drop_file_upload, ON ); ?> />
+	</td>
+</tr>
 <tr>
 	<td colspan="2" class="center">
 		<input type="submit" class="button" value="<?php echo lang_get( 'update_prefs_button' ) ?>" />
Index: account_prefs_update.php
===================================================================
--- account_prefs_update.php	(revision 281)
+++ account_prefs_update.php	(working copy)
@@ -81,6 +81,8 @@
 
 	$t_prefs->bugnote_order = gpc_get_string( 'bugnote_order' );
 	$t_prefs->email_bugnote_limit = gpc_get_int( 'email_bugnote_limit' );
+	
+	$t_prefs->drag_and_drop_file_upload	= gpc_get_bool( 'drag_and_drop_file_upload' );
 
 	# prevent users from changing other user's accounts
 	if ( $f_user_id != auth_get_current_user_id() ) {
Index: bug_file_add.php
===================================================================
--- bug_file_add.php	(revision 281)
+++ bug_file_add.php	(working copy)
@@ -24,13 +24,23 @@
 	# Add file to a bug and then view the bug
 
 	require_once( 'core.php' );
+	
+	// Drag and Drop File Upload used?
+	if (config_get('drag_and_drop_file_upload_enabled') && isset($_FILES['userfile']) && isset($_GET['bug_id']) && $_GET['bug_id'] > 0 && isset($_GET['mantis_cookie_string']) && !empty($_GET['mantis_cookie_string'])) {
+		$drag_and_drop_file_upload_used = 1;
+		// drag and drop uploaded files are in array 'userfile' but must be in array 'file'
+		$_FILES['file'] = &$_FILES['userfile'];
+		$_POST['bug_id'] = $_GET['bug_id'];
+		$_POST['max_file_size'] = $_GET['max_file_size'];
+		$_COOKIE['PHPSESSID'] = $_GET['phpsessid'];
+		$_COOKIE['MANTIS_STRING_COOKIE'] = $_GET['mantis_cookie_string'];
+	}
 
 	$t_core_path = config_get( 'core_path' );
 
 	require_once( $t_core_path.'file_api.php' );
 
 	# helper_ensure_post();
-
 	$f_bug_id	= gpc_get_int( 'bug_id', -1 );
 	$f_file		= gpc_get_file( 'file', -1 );
 
@@ -42,7 +52,6 @@
 	if ( ! file_allow_bug_upload( $f_bug_id ) ) {
 		access_denied();
 	}
-
 	access_ensure_bug_level( config_get( 'upload_bug_file_threshold' ), $f_bug_id );
 
 	$t_bug = bug_get( $f_bug_id, true );
@@ -51,12 +60,28 @@
 		# ... override the current project. This to avoid problems with categories and handlers lists etc.
 		$g_project_override = $t_bug->project_id;
 	}
+	
+	if (is_array($f_file['tmp_name'])) {
+		// multiple files uploaded
+		for ($i = 0; $i < count($f_file['tmp_name']); $i++) {
+			$f_file_error =  ( isset( $f_file['error'][$i] ) ) ? $f_file['error'][$i] : 0;
+			file_add( $f_bug_id, $f_file['tmp_name'][$i], $f_file['name'][$i], $f_file['type'][$i], 'bug', $f_file_error );
+			$dnd_uploaded_files[] = $f_file['name'][$i];
+		}
+	}
+	else {
+	    $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 );
+	}
 
-    $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 );
-
 	# Determine which view page to redirect back to.
-	$t_redirect_url = string_get_bug_view_url( $f_bug_id );
+	if ($drag_and_drop_file_upload_used) {
+		print('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; vertical-align: middle; font-size: 8px; padding: 1px;">Successfully uploaded: ' . implode(', ', $dnd_uploaded_files) . '</div></td></tr></table>');
+		exit();
+	}
+	else {
+		$t_redirect_url = string_get_bug_view_url( $f_bug_id );
+	}
 
 	html_page_top1();
 	html_meta_redirect( $t_redirect_url );
Index: bug_file_upload_inc.php
===================================================================
--- bug_file_upload_inc.php	(revision 281)
+++ bug_file_upload_inc.php	(working copy)
@@ -43,7 +43,7 @@
 <form method="post" enctype="multipart/form-data" action="bug_file_add.php">
 <table class="width100" cellspacing="1">
 <tr>
-	<td class="form-title" colspan="2">
+	<td class="form-title" colspan="3">
 <?php
 		collapse_icon( 'upload_form' );
 		echo lang_get( 'upload_file' ) ?>
@@ -54,12 +54,94 @@
 		<?php echo lang_get( 'select_file' ) ?><br />
 		<?php echo '<span class="small">(' . lang_get( 'max_file_size' ) . ': ' . number_format( $t_max_file_size/1000 ) . 'k)</span>'?>
 	</td>
-	<td width="85%">
+	<td width="60%">
 		<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 type="submit" class="button" value="<?php echo lang_get( 'upload_file_button' ) ?>" />
 	</td>
+	<td width="25%">
+<?php
+	if (config_get('drag_and_drop_file_upload_enabled') && user_pref_get_pref(auth_get_current_user_id(), 'drag_and_drop_file_upload')) {
+		/**
+		 * Applet initialization for drag and drop file upload
+		 */
+		$useApplet = 0;
+	    $user_agent = $_SERVER['HTTP_USER_AGENT'];
+	    $mantis_cookie_string = $_COOKIE['MANTIS_STRING_COOKIE'];
+	    $protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
+	    $protocol_for_upload = $protocol;
+	    if(config_get('drag_and_drop_file_upload_only_by_http')) {
+		    $arr_ip_addr = explode(',', config_get('drag_and_drop_file_upload_only_by_http'));
+			if($protocol_for_upload == 'https' && in_array($_SERVER['REMOTE_ADDR'], $arr_ip_addr)) {
+		    	$protocol_for_upload = 'http';
+		    }
+	    }
+	    // Location of the JAR file and code base for Drag and Drop File Upload
+	    switch (config_get('drag_and_drop_file_upload_applet_type')) {
+	    	case 'standard':
+	    		$applet_code = 'com.radinks.dnd.DNDApplet';
+				$jar_file = $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/plugins/fileupload/dnd.jar';
+	    		break;
+	    	case 'plus':
+	    		$applet_code = 'com.radinks.dnd.DNDAppletPlus';
+				$jar_file = $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/plugins/fileupload/dndplus.jar';
+	    		break;
+	    	case 'lite':
+	    	default:
+				$applet_code = 'com.radinks.dnd.DNDAppletLite';
+				$jar_file = $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/plugins/fileupload/dndlite.jar';
+	    }
+	    if (stristr($user_agent,"konqueror") || stristr($user_agent,"macintosh") || stristr($user_agent,"opera")) {
+	        $useApplet=1;
+	        echo '<applet name="' . config_get('drag_and_drop_file_upload_applet_name') . '" archive="' . $jar_file . '" code="' . $applet_code . '" MAYSCRIPT="yes" width="' . config_get('drag_and_drop_file_upload_width') . '" height="' . config_get('drag_and_drop_file_upload_height') . '">';
+	    } 
+	    else {
+	        if (strstr($user_agent,"MSIE")) {
+?>
+				<script type="text/javascript">
+				function IELoader()
+				{
+				    document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="<?= config_get('drag_and_drop_file_upload_width') ?>" height="<?= config_get('drag_and_drop_file_upload_height') ?>"');
+				    document.writeln(' codebase="<?= $protocol ?>://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab#version=1,5">');
+				    document.writeln('<param name="archive" value="<?= $jar_file ?>">');
+				    document.writeln('<param name="code" value="<?= $applet_code ?>">');
+				    document.writeln('<param name="name" value="<?= config_get('drag_and_drop_file_upload_applet_name') ?>">');
+				}
+				IELoader();
+				</script>
+<?php
+	        
+			}
+	        else {
+?>
+				<object type="application/x-java-applet;version=1.4.1" width="<?= config_get('drag_and_drop_file_upload_width') ?>" height="<?= config_get('drag_and_drop_file_upload_height') ?>" id="rup" name="rup">
+				<param name="archive" value="<?= $jar_file ?>">
+	            <param name="code" value="<?= $applet_code ?>">
+	            <param name="name" value="<?= config_get('drag_and_drop_file_upload_applet_name') ?>">
+<?php
+	        }
+	    }
+?>
+			<!-- BEGIN APPLET CONFIGURATION PARAMETERS -->
+			<param name="props_file" value="<?= $protocol ?>://<?= $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) ?>/plugins/fileupload/<?= config_get('drag_and_drop_file_upload_config_file') ?>">        
+	        <param name="external_redir" value="<?= $protocol ?>://<?= $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) ?>/view.php?id=<?= $f_bug_id ?>">
+	        <param name="external_target" value="_top">
+	        <param name="url" value="<?= $protocol_for_upload ?>://<?= $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) ?>/bug_file_add.php?bug_id=<?= $f_bug_id ?>&phpsessid=<?= $_COOKIE['PHPSESSID'] ?>&mantis_cookie_string=<?= $mantis_cookie_string ?>&max_file_size=<?= $t_max_file_size ?>">
+			<!-- END APPLET CONFIGURATION PARAMETERS -->
+<?php
+		if(isset($_SERVER['PHP_AUTH_USER'])) {
+			printf('<param name="chap" value="%s">', base64_encode($_SERVER['PHP_AUTH_USER'].":".$_SERVER['PHP_AUTH_PW']));
+		}
+		if($useApplet == 1) {
+			echo '</applet>';
+		}
+		else {
+			echo '</object>';
+	    }
+	}
+?>
+	&nbsp;</td>
 </tr>
 </table>
 </form>
Index: config_inc.php
===================================================================
--- config_inc.php	(revision 281)
+++ config_inc.php	(working copy)
@@ -105,4 +105,36 @@
 	# disable "lost password" feature
 	$g_lost_password_feature = OFF;
 	
+	###########################
+	# Drag and Drop File Upload
+	###########################
+	
+	# There are three different Rad Upload Applets available:
+	# - Rad Upload Lite (FREE but maximum upload limit is 1 MB and no redirect after upload allowed so you don't see your uploaded files immediately)
+	# - Rad Upload (standard version, should satisfy all your needs)
+	# - Rad Upload Plus (enterprise version with enhanced features like resume uploads etc.)
+	#
+	# For best results use the standard or the plus version (no file upload limitations, additional "select files"-menu when clicking with your left
+	# mouse button in the dropbox and redirect after upload so you immediately see your uploaded files attached to the ticket)
+	#
+	# You need to download (http://www.radinks.com/downloads/upload.php) the version you want and copy the 
+	# JAR-file (dndlite.jar, dnd.jar or dndplus.jar) into the folder /plugins/fileupload/
+	# After that configure the settings below AND in the file /plugins/fileupload/config.php
+	# see (http://www.radinks.com/upload/settings) for details
+
+	# Turn on Drag and Drop File Upload (Java Applet)
+	$g_drag_and_drop_file_upload_enabled = ON;
+	
+	# What kind of applet do you want to use (lite, standard or plus)?
+	$g_drag_and_drop_file_upload_applet_type = 'plus';
+	# Property file for Drag and Drop File Upload
+	$g_drag_and_drop_file_upload_config_file = 'config.php';
+	# Name of the Applet (displayed when asking if applet shall be executed)
+	$g_drag_and_drop_file_upload_applet_name = 'EasyCuC Drag & Drop File Upload';
+	# Width and height of the dropbox zone
+	$g_drag_and_drop_file_upload_width = 210;
+	$g_drag_and_drop_file_upload_height = 40;
+	# use this option when you encounter problems with ssl proxies (list of ip addresses when to use only http)
+	$g_drag_and_drop_file_upload_only_by_http = '138.190.32.7';
+	
 ?>
Index: core/user_pref_api.php
===================================================================
--- core/user_pref_api.php	(revision 281)
+++ core/user_pref_api.php	(working copy)
@@ -90,6 +90,7 @@
 		var $email_on_priority_min_severity = NULL;
 		var $email_bugnote_limit = NULL;
 		var $language = NULL;
+		var $drag_and_drop_file_upload = NULL;
 
 		function UserPreferences() {
 			$this->default_profile                   	= 0;
Index: custom_strings_inc.php
===================================================================
--- custom_strings_inc.php	(revision 281)
+++ custom_strings_inc.php	(working copy)
@@ -19,7 +19,8 @@
 	$s_process_step  				= 'Prozess-Schritt';
 	$s_location 					= 'Standort';
 	
-	$s_severity_enum_string		= '10:Feature-Wunsch,15:Change Request,20:Trivial,30:Fehler im Text,40:Unschönheit,50:kleinerer Fehler,60:schwerer Fehler,70:Absturz,80:Blocker';
+	$s_severity_enum_string			= '10:Feature-Wunsch,15:Change Request,20:Trivial,30:Fehler im Text,40:Unschönheit,50:kleinerer Fehler,60:schwerer Fehler,70:Absturz,80:Blocker';
+	$s_drag_and_drop_file_upload	= 'Drag and Drop File Upload aktiviert (Java Applet)';
 	
 	# language overwriting
 	$s_update_bug_button 			= 'Editieren';
@@ -42,7 +43,8 @@
 	$s_process_step  				= 'Process step';
 	$s_location 					= 'Location';
 	
-	$s_severity_enum_string		= '10:feature,15:change_request,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block';
+	$s_severity_enum_string			= '10:feature,15:change_request,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block';
+	$s_drag_and_drop_file_upload	= 'Drag and Drop File Upload enabled (Java Applet)';
 	
 	# language overwriting
 	$s_actiongroup_bugs = 'Selected Tickets';
Index: plugins/fileupload/config.php
===================================================================
--- plugins/fileupload/config.php	(revision 0)
+++ plugins/fileupload/config.php	(revision 0)
@@ -0,0 +1,197 @@
+<?php
+
+# Configuration file for Thin File Upload
+#
+# Online documentation is available at http://upload.thinfile.com/docs/
+# Lines begining with the '#' symbol denote comments. They will not
+# be processed.
+#
+$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
+
+#
+# Required parameters
+#
+$params[] = 'MAYSCRIPT=true';
+$params[] = 'scriptable=true';
+
+#
+# The url is the upload destination. It should point to the script on
+# your server that will accept the uploaded files.
+#
+# Example: 
+#     url=http://upload.thinfile.com/demo/upload.php
+#     url=http://upload.thinfile.com/cgi-bin/upload.cgi
+#
+$params[] = 'url=' . $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/upload.php';
+
+#
+# To change the welcome message displayed when the applet starts up,
+# change the message property. It should be a valid url and should point
+# to a web page.
+#
+# Example: 
+$params[] = 'message=<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; vertical-align: middle; font-size: 10px; font-weight: bold; padding: 8px;">-&gt; Drop your files here &lt;-</div></td></tr></table>';
+#
+#
+# The reject_message will be shown when the user attempts to upload
+# files that should not be allowed and the filter_action is set to
+# reject.
+# 
+# If you enter a text message here it will be displayed as a popup.
+# A URl, will result in the a page being loaded inside the applet.
+#
+# Example: 
+$params[] = 'reject_message=File rejected';
+#
+#
+# The message that is displayed when the max_upload property is exceeded is
+# defined by the max_upload_message property. If you enter a text message
+# here it will be displayed as a popup. If you enter a url here the page you
+# specify will be loaded in the applet.
+#
+# Example: 
+$params[] = 'max_upload_message=Max upload size exceeded';
+#
+#
+# If the certificate is not accepted by the user, the applet does not
+# have the required permission to access files on the client computer. As
+# a result it will not be possible to carry out the file upload. The user
+# will be notified, by displaying the message specified for the
+# permission_denied property.
+# 
+# Enter a url or a simple text to customize this error message. If left
+# blank, a standard message will be displayed. If you choose a url it
+# should be on the same website as the page that contains the applet.
+#
+$params[] = 'permission_denied=Permission Denied.';
+
+#
+# If you want to impose a limit on the total size of the file upload
+# enter a value in kilobytes for the max_upload parameter. A value
+# of 0, the default means unlimited. Please make sure that the server
+# side configuration does not impose a lower limit than what you choose
+# for max_upload
+#
+# Example: 
+#     max_upload=10240
+#     will impose a limit of 10 Mega Bytes
+#
+$params[] = 'max_upload=8000';
+
+#
+# The max_upload property checks the sum of file sizes. You can impose
+# a limit on the size of individual files using the max_file property.
+# The value is in kilobytes. 0 means no limit.
+#
+# Example: 
+#     max_file=2048
+#     for a limit of 2 Mega Bytes
+#
+$params[] = 'max_file=0';
+
+#
+# size_exceeded message will be displayed when either the max_upload or
+# max_file setting has been exceeded. If you enter a text message it
+# will be displayed as a popup. If you enter a URL, the chosen page be
+# loaded with in the applet. (Note: size_exceeded is an alias for
+# max_upload_message)
+#
+$params[] = 'size_exceeded=Max upload size or number of files exceeded';
+
+#
+# As the name suggests the full_path setting determines if absolute pathnames
+# should be sent to the server. If you switch this off, folder information will
+# be stripped from the filenames.
+#
+#$params[] = 'full_path=no';
+
+#
+# When the translate_path setting is switched on, windows style pathnames will
+# be converted to unix style paths. In other words '\' becomes '/'.  This
+# setting is required for Resumable file upload.
+#
+#$params[] = 'translate_path=yes';
+
+#
+# When encode_path setting is switched on, pathnames are URLEncoded. This is
+# usefull if you are dealing with filenames that contain special characters.
+# this setting is required for resumable file upload.
+#
+#$params[] = 'encode_path=yes';
+
+#
+# If you need to disable the multiple upload feature, and to upload files
+# one at a time, switch to bachelor mode. When bachelor property is set
+# the applet will complain if you try to upload more than one file. Use
+# the angry_bachelor property to set the error message to be displayed.
+#
+# Example: 
+#     bachelor=1
+#     angry_bachelor=http://upload.thinfile.com/demo/single.html
+#
+
+#
+# If you switch on the browse setting the applet listens for mouse clicks
+# and brings up a file selection dialog. If instead of clicking on the drop
+# target you wish to display a browse button set the browse_button
+# property as well.
+#
+$params[] = 'browse=1';
+$params[] = 'browse_button=0';
+
+#
+# While the upload is in progress you can keep track of it using one of
+# three different progress monitors. Set your preference with the
+# monitor.type property. Possible values are; standard, thumbnails
+# and compact. These values identify the Standard Progress Monitor, A
+# monitor that displays a thumbnail of each image and a compact monitor.
+#
+# Example: 
+#     monitor.type=thumbnails
+#
+#
+# By default the progress indicator will be hidden (closed) when the upload
+# completes. By uncommenting the following line you can continue to keep the
+# progress bar visible even after upload has been completed. The user will
+# then have to manually close the progress bar.
+#
+#$params[] = 'monitor.keep_visible=yes';
+
+#
+#
+# Use monitor.position to control the placement of the monitor. Asign one of
+# the following values; TL (Top Left), TR (Top Right), BL (Bottom Left),
+# BR (Bottom Right) and center.
+#
+# Example: 
+#     monitor.position=center
+#
+#
+# To achieve even greater control over the monitor's placement, use
+# cartesian cordinates.
+#
+# Example: 
+#     monitor.position=(100,100)
+#
+
+#
+# The applet or the entire browser can be redirected to another page
+# when upload completes. Select the destination URL with the
+# external_redir parameter.
+# 
+# If you do not enter a value for the external_target property, the URL
+# given external_target will be loaded with in the applet. Otherwise
+# the page will be loaded in the target frame. To redirect the entire
+# browser window use '_top' as the target.
+# 
+# If you wish to delay the redirect, enter a value for the
+# redirect_delay property (in milliseconds).
+#
+# Example: 
+#     external_redir=http://upload.thinfile.com
+#     external_target=_top
+$params[] = 'redirect_delay=500';
+
+
+// print config file to  output
+print(implode("\r\n\r\n", $params));
\ No newline at end of file
Index: plugins/fileupload/dnd.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: plugins\fileupload\dnd.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

2009-06-11_Drag_and_Drop_File_Upload_for_1.2.0a1.patch (19,169 bytes)   
Index: account_prefs_inc.php
===================================================================
--- account_prefs_inc.php	(revision 281)
+++ account_prefs_inc.php	(working copy)
@@ -297,6 +297,14 @@
 		</select>
 	</td>
 </tr>
+<tr class="row-1">
+	<td class="category">
+		<?php echo lang_get( 'drag_and_drop_file_upload' ) ?>
+	</td>
+	<td>
+		<input type="checkbox" name="drag_and_drop_file_upload" <?php check_checked( $t_pref->drag_and_drop_file_upload, ON ); ?> />
+	</td>
+</tr>
 <tr>
 	<td colspan="2" class="center">
 		<input type="submit" class="button" value="<?php echo lang_get( 'update_prefs_button' ) ?>" />
Index: account_prefs_update.php
===================================================================
--- account_prefs_update.php	(revision 281)
+++ account_prefs_update.php	(working copy)
@@ -81,6 +81,8 @@
 
 	$t_prefs->bugnote_order = gpc_get_string( 'bugnote_order' );
 	$t_prefs->email_bugnote_limit = gpc_get_int( 'email_bugnote_limit' );
+	
+	$t_prefs->drag_and_drop_file_upload	= gpc_get_bool( 'drag_and_drop_file_upload' );
 
 	# prevent users from changing other user's accounts
 	if ( $f_user_id != auth_get_current_user_id() ) {
Index: bug_file_add.php
===================================================================
--- bug_file_add.php	(revision 281)
+++ bug_file_add.php	(working copy)
@@ -24,13 +24,23 @@
 	# Add file to a bug and then view the bug
 
 	require_once( 'core.php' );
+	
+	// Drag and Drop File Upload used?
+	if (config_get('drag_and_drop_file_upload_enabled') && isset($_FILES['userfile']) && isset($_GET['bug_id']) && $_GET['bug_id'] > 0 && isset($_GET['mantis_cookie_string']) && !empty($_GET['mantis_cookie_string'])) {
+		$drag_and_drop_file_upload_used = 1;
+		// drag and drop uploaded files are in array 'userfile' but must be in array 'file'
+		$_FILES['file'] = &$_FILES['userfile'];
+		$_POST['bug_id'] = $_GET['bug_id'];
+		$_POST['max_file_size'] = $_GET['max_file_size'];
+		$_COOKIE['PHPSESSID'] = $_GET['phpsessid'];
+		$_COOKIE['MANTIS_STRING_COOKIE'] = $_GET['mantis_cookie_string'];
+	}
 
 	$t_core_path = config_get( 'core_path' );
 
 	require_once( $t_core_path.'file_api.php' );
 
 	# helper_ensure_post();
-
 	$f_bug_id	= gpc_get_int( 'bug_id', -1 );
 	$f_file		= gpc_get_file( 'file', -1 );
 
@@ -42,7 +52,6 @@
 	if ( ! file_allow_bug_upload( $f_bug_id ) ) {
 		access_denied();
 	}
-
 	access_ensure_bug_level( config_get( 'upload_bug_file_threshold' ), $f_bug_id );
 
 	$t_bug = bug_get( $f_bug_id, true );
@@ -51,12 +60,28 @@
 		# ... override the current project. This to avoid problems with categories and handlers lists etc.
 		$g_project_override = $t_bug->project_id;
 	}
+	
+	if (is_array($f_file['tmp_name'])) {
+		// multiple files uploaded
+		for ($i = 0; $i < count($f_file['tmp_name']); $i++) {
+			$f_file_error =  ( isset( $f_file['error'][$i] ) ) ? $f_file['error'][$i] : 0;
+			file_add( $f_bug_id, $f_file['tmp_name'][$i], $f_file['name'][$i], $f_file['type'][$i], 'bug', $f_file_error );
+			$dnd_uploaded_files[] = $f_file['name'][$i];
+		}
+	}
+	else {
+	    $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 );
+	}
 
-    $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 );
-
 	# Determine which view page to redirect back to.
-	$t_redirect_url = string_get_bug_view_url( $f_bug_id );
+	if ($drag_and_drop_file_upload_used) {
+		print('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; vertical-align: middle; font-size: 8px; padding: 1px;">Successfully uploaded: ' . implode(', ', $dnd_uploaded_files) . '</div></td></tr></table>');
+		exit();
+	}
+	else {
+		$t_redirect_url = string_get_bug_view_url( $f_bug_id );
+	}
 
 	html_page_top1();
 	html_meta_redirect( $t_redirect_url );
Index: bug_file_upload_inc.php
===================================================================
--- bug_file_upload_inc.php	(revision 281)
+++ bug_file_upload_inc.php	(working copy)
@@ -43,7 +43,7 @@
 <form method="post" enctype="multipart/form-data" action="bug_file_add.php">
 <table class="width100" cellspacing="1">
 <tr>
-	<td class="form-title" colspan="2">
+	<td class="form-title" colspan="3">
 <?php
 		collapse_icon( 'upload_form' );
 		echo lang_get( 'upload_file' ) ?>
@@ -54,12 +54,94 @@
 		<?php echo lang_get( 'select_file' ) ?><br />
 		<?php echo '<span class="small">(' . lang_get( 'max_file_size' ) . ': ' . number_format( $t_max_file_size/1000 ) . 'k)</span>'?>
 	</td>
-	<td width="85%">
+	<td width="60%">
 		<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 type="submit" class="button" value="<?php echo lang_get( 'upload_file_button' ) ?>" />
 	</td>
+	<td width="25%">
+<?php
+	if (config_get('drag_and_drop_file_upload_enabled') && user_pref_get_pref(auth_get_current_user_id(), 'drag_and_drop_file_upload')) {
+		/**
+		 * Applet initialization for drag and drop file upload
+		 */
+		$useApplet = 0;
+	    $user_agent = $_SERVER['HTTP_USER_AGENT'];
+	    $mantis_cookie_string = $_COOKIE['MANTIS_STRING_COOKIE'];
+	    $protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
+	    $protocol_for_upload = $protocol;
+	    if(config_get('drag_and_drop_file_upload_only_by_http')) {
+		    $arr_ip_addr = explode(',', config_get('drag_and_drop_file_upload_only_by_http'));
+			if($protocol_for_upload == 'https' && in_array($_SERVER['REMOTE_ADDR'], $arr_ip_addr)) {
+		    	$protocol_for_upload = 'http';
+		    }
+	    }
+	    // Location of the JAR file and code base for Drag and Drop File Upload
+	    switch (config_get('drag_and_drop_file_upload_applet_type')) {
+	    	case 'standard':
+	    		$applet_code = 'com.radinks.dnd.DNDApplet';
+				$jar_file = $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/plugins/fileupload/dnd.jar';
+	    		break;
+	    	case 'plus':
+	    		$applet_code = 'com.radinks.dnd.DNDAppletPlus';
+				$jar_file = $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/plugins/fileupload/dndplus.jar';
+	    		break;
+	    	case 'lite':
+	    	default:
+				$applet_code = 'com.radinks.dnd.DNDAppletLite';
+				$jar_file = $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/plugins/fileupload/dndlite.jar';
+	    }
+	    if (stristr($user_agent,"konqueror") || stristr($user_agent,"macintosh") || stristr($user_agent,"opera")) {
+	        $useApplet=1;
+	        echo '<applet name="' . config_get('drag_and_drop_file_upload_applet_name') . '" archive="' . $jar_file . '" code="' . $applet_code . '" MAYSCRIPT="yes" width="' . config_get('drag_and_drop_file_upload_width') . '" height="' . config_get('drag_and_drop_file_upload_height') . '">';
+	    } 
+	    else {
+	        if (strstr($user_agent,"MSIE")) {
+?>
+				<script type="text/javascript">
+				function IELoader()
+				{
+				    document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="<?= config_get('drag_and_drop_file_upload_width') ?>" height="<?= config_get('drag_and_drop_file_upload_height') ?>"');
+				    document.writeln(' codebase="<?= $protocol ?>://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab#version=1,5">');
+				    document.writeln('<param name="archive" value="<?= $jar_file ?>">');
+				    document.writeln('<param name="code" value="<?= $applet_code ?>">');
+				    document.writeln('<param name="name" value="<?= config_get('drag_and_drop_file_upload_applet_name') ?>">');
+				}
+				IELoader();
+				</script>
+<?php
+	        
+			}
+	        else {
+?>
+				<object type="application/x-java-applet;version=1.4.1" width="<?= config_get('drag_and_drop_file_upload_width') ?>" height="<?= config_get('drag_and_drop_file_upload_height') ?>" id="rup" name="rup">
+				<param name="archive" value="<?= $jar_file ?>">
+	            <param name="code" value="<?= $applet_code ?>">
+	            <param name="name" value="<?= config_get('drag_and_drop_file_upload_applet_name') ?>">
+<?php
+	        }
+	    }
+?>
+			<!-- BEGIN APPLET CONFIGURATION PARAMETERS -->
+			<param name="props_file" value="<?= $protocol ?>://<?= $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) ?>/plugins/fileupload/<?= config_get('drag_and_drop_file_upload_config_file') ?>">        
+	        <param name="external_redir" value="<?= $protocol ?>://<?= $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) ?>/view.php?id=<?= $f_bug_id ?>">
+	        <param name="external_target" value="_top">
+	        <param name="url" value="<?= $protocol_for_upload ?>://<?= $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) ?>/bug_file_add.php?bug_id=<?= $f_bug_id ?>&phpsessid=<?= $_COOKIE['PHPSESSID'] ?>&mantis_cookie_string=<?= $mantis_cookie_string ?>&max_file_size=<?= $t_max_file_size ?>">
+			<!-- END APPLET CONFIGURATION PARAMETERS -->
+<?php
+		if(isset($_SERVER['PHP_AUTH_USER'])) {
+			printf('<param name="chap" value="%s">', base64_encode($_SERVER['PHP_AUTH_USER'].":".$_SERVER['PHP_AUTH_PW']));
+		}
+		if($useApplet == 1) {
+			echo '</applet>';
+		}
+		else {
+			echo '</object>';
+	    }
+	}
+?>
+	&nbsp;</td>
 </tr>
 </table>
 </form>
Index: core/user_pref_api.php
===================================================================
--- core/user_pref_api.php	(revision 281)
+++ core/user_pref_api.php	(working copy)
@@ -90,6 +90,7 @@
 		var $email_on_priority_min_severity = NULL;
 		var $email_bugnote_limit = NULL;
 		var $language = NULL;
+		var $drag_and_drop_file_upload = NULL;
 
 		function UserPreferences() {
 			$this->default_profile                   	= 0;
Index: lang/strings_english.txt
===================================================================
--- lang/strings_english.txt	(revision 281)
+++ lang/strings_english.txt	(working copy)
@@ -461,6 +461,7 @@
 $s_email_on_priority_change = 'Email on Priority Change';
 $s_email_bugnote_limit = 'Email Notes Limit';
 $s_language = 'Language';
+$s_drag_and_drop_file_upload	= 'Drag and Drop File Upload enabled (Java Applet)';
 $s_update_prefs_button = 'Update Prefs';
 $s_reset_prefs_button = 'Reset Prefs';
 
Index: lang/strings_german.txt
===================================================================
--- lang/strings_german.txt	(revision 281)
+++ lang/strings_german.txt	(working copy)
@@ -450,6 +450,7 @@
 $s_email_on_priority_change = 'E-Mail bei Prioritätswechsel';
 $s_email_bugnote_limit = 'E-Mail Problemnotiz Limit';
 $s_language = 'Sprache';
+$s_drag_and_drop_file_upload	= 'Drag and Drop File Upload aktiviert (Java Applet)';
 $s_update_prefs_button = 'Einstellungen aktualisieren';
 $s_reset_prefs_button = 'Einstellungen zurücksetzen';
 
Index: plugins/fileupload/config.php
===================================================================
--- plugins/fileupload/config.php	(revision 0)
+++ plugins/fileupload/config.php	(revision 0)
@@ -0,0 +1,197 @@
+<?php
+
+# Configuration file for Thin File Upload
+#
+# Online documentation is available at http://upload.thinfile.com/docs/
+# Lines begining with the '#' symbol denote comments. They will not
+# be processed.
+#
+$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
+
+#
+# Required parameters
+#
+$params[] = 'MAYSCRIPT=true';
+$params[] = 'scriptable=true';
+
+#
+# The url is the upload destination. It should point to the script on
+# your server that will accept the uploaded files.
+#
+# Example: 
+#     url=http://upload.thinfile.com/demo/upload.php
+#     url=http://upload.thinfile.com/cgi-bin/upload.cgi
+#
+#$params[] = 'url=' . $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/upload.php';
+
+#
+# To change the welcome message displayed when the applet starts up,
+# change the message property. It should be a valid url and should point
+# to a web page.
+#
+# Example: 
+$params[] = 'message=<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; vertical-align: middle; font-size: 10px; font-weight: bold; padding: 8px;">-&gt; Drop your files here &lt;-</div></td></tr></table>';
+#
+#
+# The reject_message will be shown when the user attempts to upload
+# files that should not be allowed and the filter_action is set to
+# reject.
+# 
+# If you enter a text message here it will be displayed as a popup.
+# A URl, will result in the a page being loaded inside the applet.
+#
+# Example: 
+$params[] = 'reject_message=File rejected';
+#
+#
+# The message that is displayed when the max_upload property is exceeded is
+# defined by the max_upload_message property. If you enter a text message
+# here it will be displayed as a popup. If you enter a url here the page you
+# specify will be loaded in the applet.
+#
+# Example: 
+$params[] = 'max_upload_message=Max upload size exceeded';
+#
+#
+# If the certificate is not accepted by the user, the applet does not
+# have the required permission to access files on the client computer. As
+# a result it will not be possible to carry out the file upload. The user
+# will be notified, by displaying the message specified for the
+# permission_denied property.
+# 
+# Enter a url or a simple text to customize this error message. If left
+# blank, a standard message will be displayed. If you choose a url it
+# should be on the same website as the page that contains the applet.
+#
+$params[] = 'permission_denied=Permission Denied.';
+
+#
+# If you want to impose a limit on the total size of the file upload
+# enter a value in kilobytes for the max_upload parameter. A value
+# of 0, the default means unlimited. Please make sure that the server
+# side configuration does not impose a lower limit than what you choose
+# for max_upload
+#
+# Example: 
+#     max_upload=10240
+#     will impose a limit of 10 Mega Bytes
+#
+$params[] = 'max_upload=8000';
+
+#
+# The max_upload property checks the sum of file sizes. You can impose
+# a limit on the size of individual files using the max_file property.
+# The value is in kilobytes. 0 means no limit.
+#
+# Example: 
+#     max_file=2048
+#     for a limit of 2 Mega Bytes
+#
+$params[] = 'max_file=0';
+
+#
+# size_exceeded message will be displayed when either the max_upload or
+# max_file setting has been exceeded. If you enter a text message it
+# will be displayed as a popup. If you enter a URL, the chosen page be
+# loaded with in the applet. (Note: size_exceeded is an alias for
+# max_upload_message)
+#
+$params[] = 'size_exceeded=Max upload size or number of files exceeded';
+
+#
+# As the name suggests the full_path setting determines if absolute pathnames
+# should be sent to the server. If you switch this off, folder information will
+# be stripped from the filenames.
+#
+#$params[] = 'full_path=no';
+
+#
+# When the translate_path setting is switched on, windows style pathnames will
+# be converted to unix style paths. In other words '\' becomes '/'.  This
+# setting is required for Resumable file upload.
+#
+#$params[] = 'translate_path=yes';
+
+#
+# When encode_path setting is switched on, pathnames are URLEncoded. This is
+# usefull if you are dealing with filenames that contain special characters.
+# this setting is required for resumable file upload.
+#
+#$params[] = 'encode_path=yes';
+
+#
+# If you need to disable the multiple upload feature, and to upload files
+# one at a time, switch to bachelor mode. When bachelor property is set
+# the applet will complain if you try to upload more than one file. Use
+# the angry_bachelor property to set the error message to be displayed.
+#
+# Example: 
+#     bachelor=1
+#     angry_bachelor=http://upload.thinfile.com/demo/single.html
+#
+
+#
+# If you switch on the browse setting the applet listens for mouse clicks
+# and brings up a file selection dialog. If instead of clicking on the drop
+# target you wish to display a browse button set the browse_button
+# property as well.
+#
+$params[] = 'browse=1';
+$params[] = 'browse_button=0';
+
+#
+# While the upload is in progress you can keep track of it using one of
+# three different progress monitors. Set your preference with the
+# monitor.type property. Possible values are; standard, thumbnails
+# and compact. These values identify the Standard Progress Monitor, A
+# monitor that displays a thumbnail of each image and a compact monitor.
+#
+# Example: 
+#     monitor.type=thumbnails
+#
+#
+# By default the progress indicator will be hidden (closed) when the upload
+# completes. By uncommenting the following line you can continue to keep the
+# progress bar visible even after upload has been completed. The user will
+# then have to manually close the progress bar.
+#
+#$params[] = 'monitor.keep_visible=yes';
+
+#
+#
+# Use monitor.position to control the placement of the monitor. Asign one of
+# the following values; TL (Top Left), TR (Top Right), BL (Bottom Left),
+# BR (Bottom Right) and center.
+#
+# Example: 
+#     monitor.position=center
+#
+#
+# To achieve even greater control over the monitor's placement, use
+# cartesian cordinates.
+#
+# Example: 
+#     monitor.position=(100,100)
+#
+
+#
+# The applet or the entire browser can be redirected to another page
+# when upload completes. Select the destination URL with the
+# external_redir parameter.
+# 
+# If you do not enter a value for the external_target property, the URL
+# given external_target will be loaded with in the applet. Otherwise
+# the page will be loaded in the target frame. To redirect the entire
+# browser window use '_top' as the target.
+# 
+# If you wish to delay the redirect, enter a value for the
+# redirect_delay property (in milliseconds).
+#
+# Example: 
+#     external_redir=http://upload.thinfile.com
+#     external_target=_top
+$params[] = 'redirect_delay=500';
+
+
+// print config file to  output
+print(implode("\r\n\r\n", $params));
\ No newline at end of file
Index: plugins/fileupload/dndlite.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: plugins\fileupload\dndlite.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Relationships

duplicate of 0019590 closedsyncguru Attach via drag-and-drop 

Activities

dominik

dominik

2009-06-11 03:21

reporter   ~0022075

Patch 2009-06-10_Drag_and_Drop_File_Upload_for_1.2.0a1.patch has errors - don't use it, use 2009-06-11_Drag_and_Drop_File_Upload_for_1.2.0a1.patch instead...

vboctor

vboctor

2009-06-11 19:18

manager   ~0022106

You may want to consider this as a plugin for 1.2.x.