WordPress File Upload - Version 2.5.3

Version Description

  • fixed bug not allowing redirection to work
  • fixed bug that was including failed files in email notifications on certain occasions
  • default value for uploadrole changed to "all"
Download this release

Release Info

Developer nickboss
Plugin Icon 128x128 WordPress File Upload
Version 2.5.3
Comparing to
See all releases

Code changes from version 2.5.2 to 2.5.3

js/wordpress_file_upload_functions.js CHANGED
@@ -706,7 +706,6 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
706
  // adjust upload parameters if this is the last combined call to this function
707
  if (G.files_processed == G.files_count) {
708
  G.last = true;
709
-
710
  // prepare and execute actions related to WPFilebase, email notifications and redirection if this is the last call
711
  if (G.update_wpfilebase != "") {
712
  G.admin_messages.wpfilebase = "";
706
  // adjust upload parameters if this is the last combined call to this function
707
  if (G.files_processed == G.files_count) {
708
  G.last = true;
 
709
  // prepare and execute actions related to WPFilebase, email notifications and redirection if this is the last call
710
  if (G.update_wpfilebase != "") {
711
  G.admin_messages.wpfilebase = "";
lib/wfu_constants.php CHANGED
@@ -8,7 +8,7 @@ DEFINE("WFU_UPLOADTITLE", __('Upload files', 'wordpress-file-upload'));
8
  DEFINE("WFU_SELECTBUTTON", __('Select File', 'wordpress-file-upload'));
9
  DEFINE("WFU_UPLOADBUTTON", __('Upload File', 'wordpress-file-upload'));
10
  DEFINE("WFU_SINGLEBUTTON", "false");
11
- DEFINE("WFU_UPLOADROLE", "administrator");
12
  DEFINE("WFU_UPLOADPATH", 'uploads');
13
  DEFINE("WFU_CREATEPATH", "false");
14
  DEFINE("WFU_UPLOADPATTERNS", "*.*");
8
  DEFINE("WFU_SELECTBUTTON", __('Select File', 'wordpress-file-upload'));
9
  DEFINE("WFU_UPLOADBUTTON", __('Upload File', 'wordpress-file-upload'));
10
  DEFINE("WFU_SINGLEBUTTON", "false");
11
+ DEFINE("WFU_UPLOADROLE", "all");
12
  DEFINE("WFU_UPLOADPATH", 'uploads');
13
  DEFINE("WFU_CREATEPATH", "false");
14
  DEFINE("WFU_UPLOADPATTERNS", "*.*");
lib/wfu_processfiles.php CHANGED
@@ -41,7 +41,7 @@ function wfu_process_files($params, $method) {
41
  $params_output_array["general"]['state'] = 0;
42
  $params_output_array["general"]['files_count'] = 0;
43
  $params_output_array["general"]['update_wpfilebase'] = "";
44
- $params_output_array["general"]['redirect_link'] = "";
45
  $params_output_array["general"]['upload_finish_time'] = 0;
46
  $params_output_array["general"]['message'] = "";
47
  $params_output_array["general"]['message_type'] = "";
@@ -244,121 +244,121 @@ function wfu_process_files($params, $method) {
244
  // if ( $upload_path_ok and $allowed_file_ok and $size_file_ok ) {
245
  if ( $file_output['message_type'] != "error" ) {
246
 
247
- if ( $only_check ) {
248
- $file_copied = true;
249
- }
250
- elseif ( is_uploaded_file($fileprops['tmp_name']) ) {
251
- $file_copied = false;
252
- $message_processed = false;
253
- $source_path = $fileprops['tmp_name'];
254
- $only_filename = wfu_upload_plugin_clean( $fileprops['name'] );
255
- $target_path = wfu_upload_plugin_full_path($params).$only_filename;
256
-
257
- $search = array ('/%filename%/', '/%filepath%/');
258
- $replace = array ($only_filename, $target_path);
259
- $success_message = preg_replace($search, $replace, $params["successmessage"]);
260
-
261
- if ($source_path) {
262
- $file_exists = file_exists($target_path);
263
- if ( !$file_exists || $params["dublicatespolicy"] == "" || $params["dublicatespolicy"] == "overwrite" ) {
264
- //redirect echo in internal buffer to receive and process any unwanted warning messages from wfu_upload_file
265
- ob_start();
266
- ob_clean();
267
- /* Apply wfu_before_file_upload filter right before the upload, in order to allow the user to change the file name.
268
- If additional data are required, such as user_id or userdata values, they can be retrieved by implementing the
269
- previous filter wfu_before_file_check, corresponding them to the unique file id */
270
- if ( $file_unique_id != '' ) $target_path = apply_filters('wfu_before_file_upload', $target_path, $file_unique_id);
271
- //move the uploaded file to its final destination
272
- $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
273
- $file_copied = $wfu_upload_file_ret["uploaded"];
274
- //process warning messages from wfu_upload_file
275
- $echo_message = ob_get_contents();
276
- //finish redirecting of echo to internal buffer
277
- ob_end_clean();
278
- if ( $echo_message != "" && !$file_copied ) {
279
- $file_output['message_type'] = "error";
280
- if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
281
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
282
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
 
 
 
 
 
283
  }
284
- else {
285
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
286
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], strip_tags($echo_message));
287
  }
288
- $message_processed = true;
289
- }
290
- if ( $wfu_upload_file_ret["admin_message"] != "" ) {
291
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
292
  }
293
- }
294
- else if ( $file_exists && $params["dublicatespolicy"] == "maintain both" ) {
295
- $full_path = wfu_upload_plugin_full_path($params);
296
- $name_part = $only_filename;
297
- $ext_part = "";
298
- $dot_pos = strrpos($name_part, ".");
299
- if ( $dot_pos ) {
300
- $ext_part = substr($name_part, $dot_pos);
301
- $name_part = substr($name_part, 0, $dot_pos);
302
- }
303
- if ( $params["uniquepattern"] != "datetimestamp" ) {
304
- $unique_ind = 1;
305
- do {
306
- $unique_ind += 1;
307
- $only_filename = $name_part . "(" . $unique_ind . ")" . $ext_part;
308
- $target_path = $full_path . $only_filename;
309
  }
310
- while ( file_exists($target_path) );
311
- }
312
- else {
313
- $current_datetime = gmdate("U") - 1;
314
- do {
315
- $current_datetime += 1;
316
- $only_filename = $name_part . "-" . gmdate("YmdHis", $current_datetime) . $ext_part;
317
- $target_path = $full_path . $only_filename;
318
  }
319
- while ( file_exists($target_path) );
320
- }
321
- //redirect echo in internal buffer to receive and process any unwanted warning messages from move_uploaded_file
322
- ob_start();
323
- ob_clean();
324
- /* Apply wfu_before_file_upload filter right before the upload, in order to allow the user to change the file name.
325
- If additional data are required, such as user_id or userdata values, they can be retrieved by implementing the
326
- previous filter wfu_before_file_check, corresponding them to the unique file id */
327
- if ( $file_unique_id != '' ) $target_path = apply_filters('wfu_before_file_upload', $target_path, $file_unique_id);
328
- //move the uploaded file to its final destination
329
- $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
330
- $file_copied = $wfu_upload_file_ret["uploaded"];
331
- //process warning messages from move_uploaded_file
332
- $echo_message = ob_get_contents();
333
- //finish redirecting of echo to internal buffer
334
- ob_end_clean();
335
- if ( $echo_message != "" && !$file_copied ) {
336
- $file_output['message_type'] = "error";
337
- if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
338
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
339
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
340
  }
341
- else {
342
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
343
- $file_output['admin_messages'] = wfu_join_strings("<br />n", $file_output['admin_messages'], strip_tags($echo_message));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  }
345
- $message_processed = true;
346
  }
347
- if ( $wfu_upload_file_ret["admin_message"] != "" ) {
348
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
 
 
 
349
  }
350
  }
351
- else {
352
- $file_output['message_type'] = "error";
353
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_WARNING_FILE_EXISTS);
354
- $message_processed = true;
355
- $file_copied = false;
356
- }
357
  }
358
 
359
  if ( $file_copied ) {
360
  /* prepare email notification parameters if email notification is enabled */
361
- if ( $params["notify"] == "true" ) {
362
  $notify_only_filename_list .= ( $notify_only_filename_list == "" ? "" : ", " ).$only_filename;
363
  $notify_target_path_list .= ( $notify_target_path_list == "" ? "" : ", " ).$target_path;
364
  if ( $params["attachfile"] == "true" )
41
  $params_output_array["general"]['state'] = 0;
42
  $params_output_array["general"]['files_count'] = 0;
43
  $params_output_array["general"]['update_wpfilebase'] = "";
44
+ $params_output_array["general"]['redirect_link'] = ( $params["redirect"] == "true" ? $params["redirectlink"] : "" );
45
  $params_output_array["general"]['upload_finish_time'] = 0;
46
  $params_output_array["general"]['message'] = "";
47
  $params_output_array["general"]['message_type'] = "";
244
  // if ( $upload_path_ok and $allowed_file_ok and $size_file_ok ) {
245
  if ( $file_output['message_type'] != "error" ) {
246
 
247
+ if ( is_uploaded_file($fileprops['tmp_name']) || $only_check ) {
248
+ if ( $only_check ) $file_copied = true;
249
+ else {
250
+ $file_copied = false;
251
+ $message_processed = false;
252
+ $source_path = $fileprops['tmp_name'];
253
+ $only_filename = wfu_upload_plugin_clean( $fileprops['name'] );
254
+ $target_path = wfu_upload_plugin_full_path($params).$only_filename;
255
+
256
+ $search = array ('/%filename%/', '/%filepath%/');
257
+ $replace = array ($only_filename, $target_path);
258
+ $success_message = preg_replace($search, $replace, $params["successmessage"]);
259
+
260
+ if ($source_path) {
261
+ $file_exists = file_exists($target_path);
262
+ if ( !$file_exists || $params["dublicatespolicy"] == "" || $params["dublicatespolicy"] == "overwrite" ) {
263
+ //redirect echo in internal buffer to receive and process any unwanted warning messages from wfu_upload_file
264
+ ob_start();
265
+ ob_clean();
266
+ /* Apply wfu_before_file_upload filter right before the upload, in order to allow the user to change the file name.
267
+ If additional data are required, such as user_id or userdata values, they can be retrieved by implementing the
268
+ previous filter wfu_before_file_check, corresponding them to the unique file id */
269
+ if ( $file_unique_id != '' ) $target_path = apply_filters('wfu_before_file_upload', $target_path, $file_unique_id);
270
+ //move the uploaded file to its final destination
271
+ $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
272
+ $file_copied = $wfu_upload_file_ret["uploaded"];
273
+ //process warning messages from wfu_upload_file
274
+ $echo_message = ob_get_contents();
275
+ //finish redirecting of echo to internal buffer
276
+ ob_end_clean();
277
+ if ( $echo_message != "" && !$file_copied ) {
278
+ $file_output['message_type'] = "error";
279
+ if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
280
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
281
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
282
+ }
283
+ else {
284
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
285
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], strip_tags($echo_message));
286
+ }
287
+ $message_processed = true;
288
  }
289
+ if ( $wfu_upload_file_ret["admin_message"] != "" ) {
290
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
 
291
  }
 
 
 
 
292
  }
293
+ else if ( $file_exists && $params["dublicatespolicy"] == "maintain both" ) {
294
+ $full_path = wfu_upload_plugin_full_path($params);
295
+ $name_part = $only_filename;
296
+ $ext_part = "";
297
+ $dot_pos = strrpos($name_part, ".");
298
+ if ( $dot_pos ) {
299
+ $ext_part = substr($name_part, $dot_pos);
300
+ $name_part = substr($name_part, 0, $dot_pos);
 
 
 
 
 
 
 
 
301
  }
302
+ if ( $params["uniquepattern"] != "datetimestamp" ) {
303
+ $unique_ind = 1;
304
+ do {
305
+ $unique_ind += 1;
306
+ $only_filename = $name_part . "(" . $unique_ind . ")" . $ext_part;
307
+ $target_path = $full_path . $only_filename;
308
+ }
309
+ while ( file_exists($target_path) );
310
  }
311
+ else {
312
+ $current_datetime = gmdate("U") - 1;
313
+ do {
314
+ $current_datetime += 1;
315
+ $only_filename = $name_part . "-" . gmdate("YmdHis", $current_datetime) . $ext_part;
316
+ $target_path = $full_path . $only_filename;
317
+ }
318
+ while ( file_exists($target_path) );
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  }
320
+ //redirect echo in internal buffer to receive and process any unwanted warning messages from move_uploaded_file
321
+ ob_start();
322
+ ob_clean();
323
+ /* Apply wfu_before_file_upload filter right before the upload, in order to allow the user to change the file name.
324
+ If additional data are required, such as user_id or userdata values, they can be retrieved by implementing the
325
+ previous filter wfu_before_file_check, corresponding them to the unique file id */
326
+ if ( $file_unique_id != '' ) $target_path = apply_filters('wfu_before_file_upload', $target_path, $file_unique_id);
327
+ //move the uploaded file to its final destination
328
+ $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
329
+ $file_copied = $wfu_upload_file_ret["uploaded"];
330
+ //process warning messages from move_uploaded_file
331
+ $echo_message = ob_get_contents();
332
+ //finish redirecting of echo to internal buffer
333
+ ob_end_clean();
334
+ if ( $echo_message != "" && !$file_copied ) {
335
+ $file_output['message_type'] = "error";
336
+ if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
337
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
338
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
339
+ }
340
+ else {
341
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
342
+ $file_output['admin_messages'] = wfu_join_strings("<br />n", $file_output['admin_messages'], strip_tags($echo_message));
343
+ }
344
+ $message_processed = true;
345
+ }
346
+ if ( $wfu_upload_file_ret["admin_message"] != "" ) {
347
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
348
  }
 
349
  }
350
+ else {
351
+ $file_output['message_type'] = "error";
352
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_WARNING_FILE_EXISTS);
353
+ $message_processed = true;
354
+ $file_copied = false;
355
  }
356
  }
 
 
 
 
 
 
357
  }
358
 
359
  if ( $file_copied ) {
360
  /* prepare email notification parameters if email notification is enabled */
361
+ if ( $params["notify"] == "true" && !$only_check ) {
362
  $notify_only_filename_list .= ( $notify_only_filename_list == "" ? "" : ", " ).$only_filename;
363
  $notify_target_path_list .= ( $notify_target_path_list == "" ? "" : ", " ).$target_path;
364
  if ( $params["attachfile"] == "true" )
readme.txt CHANGED
@@ -110,6 +110,11 @@ Administrators can view and manage the uploaded files from the File Browser that
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
113
  = 2.5.2 =
114
  * fixed important bug in free version not correctly showing message after failed upload
115
 
@@ -340,6 +345,9 @@ Initial version.
340
 
341
  == Upgrade Notice ==
342
 
 
 
 
343
  = 2.5.2 =
344
  Important upgrade to address some bugs.
345
 
@@ -490,7 +498,7 @@ A detailed list of attributes, together with instructions is shown below:
490
 
491
  *Filters*
492
 
493
- * **uploadrole:** This is the roles that are allowed to upload files. Default role is "administrator". If you use other roles, like "editor", then only users of this role and also of role "administrator" will be able to upload files. You can set multiple roles, separated by comma, e.g. "editor, author". If you set uploadrole to "all" then all users, even guests, will be able to upload files.
494
  * **uploadpatterns:** This is the filter of the uploaded files. Default value is "*.*", meaning that all files can be uploaded. Use this attribute to restrict the types of files that can be uploaded. For instance, in order to upload only pdf files put "\*.pdf". You can use more that one filters, separated by comma, for instance "\*.pdf,\*.doc".
495
  * **maxsize:** This is the maximum size in MBytes of the uploaded files. Use this attribute to restrict the upload of files larger that this value. Default value is "10", meaning that you cannot upload files larger than 10MBytes.
496
 
110
 
111
  == Changelog ==
112
 
113
+ = 2.5.3 =
114
+ * fixed bug not allowing redirection to work
115
+ * fixed bug that was including failed files in email notifications on certain occasions
116
+ * default value for uploadrole changed to "all"
117
+
118
  = 2.5.2 =
119
  * fixed important bug in free version not correctly showing message after failed upload
120
 
345
 
346
  == Upgrade Notice ==
347
 
348
+ = 2.5.3 =
349
+ Important upgrade to address some bugs.
350
+
351
  = 2.5.2 =
352
  Important upgrade to address some bugs.
353
 
498
 
499
  *Filters*
500
 
501
+ * **uploadrole:** This is the roles that are allowed to upload files. Default role is "all". If you use other roles, like "editor", then only users of this role and also of role "administrator" will be able to upload files. You can set multiple roles, separated by comma, e.g. "editor, author". If you set uploadrole to "all" then all users, even guests, will be able to upload files.
502
  * **uploadpatterns:** This is the filter of the uploaded files. Default value is "*.*", meaning that all files can be uploaded. Use this attribute to restrict the types of files that can be uploaded. For instance, in order to upload only pdf files put "\*.pdf". You can use more that one filters, separated by comma, for instance "\*.pdf,\*.doc".
503
  * **maxsize:** This is the maximum size in MBytes of the uploaded files. Use this attribute to restrict the upload of files larger that this value. Default value is "10", meaning that you cannot upload files larger than 10MBytes.
504
 
wordpress_file_upload.php CHANGED
@@ -4,7 +4,7 @@ session_start();
4
  /*
5
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
  Description: Simple interface to upload files from a page.
7
- Version: 2.5.2
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
4
  /*
5
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
  Description: Simple interface to upload files from a page.
7
+ Version: 2.5.3
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */