WordPress File Upload - Version 2.1.2

Version Description

  • Several bug fixes and code reconstruction.
  • Code modifications so that the plugin can operate even when DEBUG mode is ON.
  • New attribute debugmode added to allow better debugging of the plugin when there are errors.
Download this release

Release Info

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

Code changes from version 2.0.2 to 2.1.2

css/wordpress_file_upload_style.css CHANGED
@@ -561,6 +561,25 @@ div.file_messageblock_subheader_adminmessage
561
  margin: 0;
562
  padding: 2px;
563
  background-color: #F7F7F7;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
  }
565
 
566
  label.file_messageblock_subheader_adminmessagelabel
561
  margin: 0;
562
  padding: 2px;
563
  background-color: #F7F7F7;
564
+ overflow: scroll;
565
+ }
566
+
567
+ label.file_messageblock_subheader_debugmessage_label
568
+ {
569
+ margin: 0;
570
+ padding: 0;
571
+ background: none;
572
+ border: none;
573
+ font-weight: bold;
574
+ }
575
+
576
+ div.file_messageblock_subheader_debugmessage_container
577
+ {
578
+ margin: 0 0 0 20px;
579
+ padding: 0px;
580
+ background: none;
581
+ border: none;
582
+ font-size: 10px;
583
  }
584
 
585
  label.file_messageblock_subheader_adminmessagelabel
images/add_12.png CHANGED
Binary file
images/add_16.png CHANGED
Binary file
images/draw-delete.png CHANGED
Binary file
images/help_16.png CHANGED
Binary file
images/progbar.gif CHANGED
Binary file
images/refresh_16.gif CHANGED
Binary file
images/remove_12.png CHANGED
Binary file
images/remove_16.png CHANGED
Binary file
images/white-grad-active.png CHANGED
Binary file
js/wordpress_file_upload_functions.js CHANGED
@@ -15,9 +15,8 @@ function wfu_Initialize_Consts(consts) {
15
  var consts_arr = consts.split(";");
16
  var const_arr;
17
  for (var i = 0; i < consts_arr.length; i++) {
18
- const_txt = wfu_plugin_decode_string(consts_arr[i]);
19
- const_arr = const_txt.split(":");
20
- GlobalData.consts[const_arr[0]] = const_arr[1];
21
  }
22
  }
23
 
@@ -317,7 +316,7 @@ function wfu_uploadProgress(evt) {
317
  var percentComplete = 0;
318
  var simplebar = document.getElementById('progressbar_' + sid + '_animation');
319
  if (evt.lengthComputable) {
320
- if (this.xhr.size == 0) this.xhr.size = evt.total;
321
  if (simplebar) {
322
  var total = 0;
323
  var totalloaded = 0;
@@ -343,14 +342,14 @@ function wfu_notify_WPFilebase(url) {
343
  }
344
 
345
  /* wfu_send_email_notification: function to send notification message as ajax request */
346
- function wfu_send_email_notification(sid, unique_id, params_index, session_token, notify_only_filename_list, notify_target_path_list, notify_attachment_list) {
347
  var xhr = wfu_GetHttpRequestObject();
348
  if (xhr == null) {
349
  // error sending email
350
  return;
351
  }
352
 
353
- var url = '/wp-admin/admin-ajax.php';
354
  var userdata_count = wfu_get_userdata_count(sid);
355
  params = new Array(7 + userdata_count);
356
  params[0] = new Array(2);
@@ -385,11 +384,21 @@ function wfu_send_email_notification(sid, unique_id, params_index, session_token
385
  parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
386
  }
387
 
 
388
  xhr.shortcode_id = sid;
 
389
  xhr.file_id = 0;
390
  xhr.unique_id = unique_id;
 
391
  xhr.params_index = params_index;
392
  xhr.session_token = session_token;
 
 
 
 
 
 
 
393
  xhr.open("POST", url, true);
394
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
395
  xhr.setRequestHeader("Content-length", parameters.length);
@@ -401,6 +410,17 @@ function wfu_send_email_notification(sid, unique_id, params_index, session_token
401
  xhr.send(parameters);
402
  }
403
 
 
 
 
 
 
 
 
 
 
 
 
404
  //wfu_uploadComplete: function that is called after successfull file upload
405
  function wfu_uploadComplete(evt) {
406
  var sid = this.shortcode_id;
@@ -408,15 +428,24 @@ function wfu_uploadComplete(evt) {
408
  var last = false;
409
  var upload_params = "";
410
  var safe_params = "";
 
 
411
  if (evt.target.responseText != -1) {
412
  var txt = evt.target.responseText;
413
- var pos = txt.indexOf(":");
414
- var txt_header = txt.substr(0, pos);
415
- var txt_value = txt.substr(pos + 1, txt.length - pos - 1);
416
- if (txt_header == "success") {
417
- pos = txt_value.indexOf(":");
418
- safe_params = txt_value.substr(0, pos);
419
- upload_params = txt_value.substr(pos + 1, txt_value.length - pos - 1);
 
 
 
 
 
 
 
420
  }
421
  }
422
 
@@ -426,31 +455,37 @@ function wfu_uploadComplete(evt) {
426
  Params.general.shortcode_id = sid;
427
  Params.general.unique_id = this.unique_id;
428
  Params.general.state = 7;
429
- Params.general.files_count = 1;
430
  Params.general.upload_finish_time = this.finish_time;
431
- Params.general.fail_message = this.error_message_unknown;
432
- Params.general.fail_admin_message = this.error_adminmessage_unknown;
433
- Params[0] = {};
434
- Params[0]['color'] = error_colors[0];
435
- Params[0]['bgcolor'] = error_colors[1];
436
- Params[0]['borcolor'] = error_colors[2];
437
- Params[0]['message_type'] = "error";
438
- Params[0]['header'] = this.error_message_header;
439
- Params[0]['message'] = this.error_message_timelimit;
440
- Params[0]['admin_messages'] = this.error_message_admin_timelimit;
441
- // if upload_finish_time is non-zero, then we have a failed upload, probably due to exceeded upload time limit
 
 
 
442
  if (Params.general.upload_finish_time > 0) {
443
  var d = new Date();
444
  if (d.getTime() < Params.general.upload_finish_time) {
445
- Params[0]['message'] = Params.general.fail_message;
446
- Params[0]['admin_messages'] = Params.general.fail_admin_message;
 
 
 
447
  }
448
  }
449
  // note that upload_params is passed as object, so no need to pass a safe_output string
450
- last = wfu_ProcessUploadComplete(sid, this.file_id, Params, this.unique_id, this.params_index, this.session_token, "");
451
  }
452
  else {
453
- last = wfu_ProcessUploadComplete(sid, this.file_id, upload_params, this.unique_id, this.params_index, this.session_token, safe_params);
454
  }
455
  if (last) {
456
  wfu_unlock_upload(evt.target.shortcode_id);
@@ -460,7 +495,7 @@ function wfu_uploadComplete(evt) {
460
  }
461
 
462
  //wfu_ProcessUploadComplete: function to perform actions after successfull upload
463
- function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, params_index, session_token, safe_output) {
464
  //initial checks to process or not the data
465
  if (!sid || sid < 0) return;
466
  if (upload_params == null || upload_params == "") return;
@@ -549,6 +584,7 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
549
  G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
550
  G.admin_messages.notify = Params.general.admin_messages.notify;
551
  G.admin_messages.redirect = Params.general.admin_messages.redirect;
 
552
  G.admin_messages.other = Params.general.admin_messages.other;
553
  G.errors = {};
554
  G.errors.wpfilebase = Params.general.errors.wpfilebase;
@@ -577,6 +613,7 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
577
  G.notify_only_filename_list = wfu_join_strings(", ", G.notify_only_filename_list, Params.general.notify_only_filename_list);
578
  G.notify_target_path_list = wfu_join_strings(", ", G.notify_target_path_list, Params.general.notify_target_path_list);
579
  G.notify_attachment_list = wfu_join_strings(",", G.notify_attachment_list, Params.general.notify_attachment_list);
 
580
  G.admin_messages.other = wfu_join_strings("<br />", G.admin_messages.other, Params.general.admin_messages.other);
581
  if (G.admin_messages.wpfilebase == "") G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
582
  if (G.admin_messages.notify == "") G.admin_messages.notify = Params.general.admin_messages.notify;
@@ -596,7 +633,7 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
596
  }
597
  if (G.notify_only_filename_list != "") {
598
  G.admin_messages.notify = "";
599
- wfu_send_email_notification(sid, unique_id, params_index, session_token, G.notify_only_filename_list, G.notify_target_path_list, G.notify_attachment_list);
600
  // in email notification we declare that this is not the last call, because we wait for a last answer from email sending result
601
  G.last = false;
602
  G.notify_only_filename_list = ""; //reset this variable so that repetitive email messages are not sent
@@ -610,13 +647,14 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
610
  }
611
  }
612
 
613
- // last adjustment of header messages due to json parse error of UploadState
614
  var nonadmin_message = G.message;
615
  var admin_message = wfu_join_strings("<br />",
616
- Params.general.admin_messages.other,
617
- Params.general.admin_messages.wpfilebase,
618
- Params.general.admin_messages.notify,
619
- Params.general.admin_messages.redirect);
 
620
  if (!UploadStates_Ok) {
621
  var error_jsonparse_headermessage = GlobalData.consts.jsonparse_headermessage;
622
  var error_jsonparse_headeradminmessage = GlobalData.consts.jsonparse_headeradminmessage;
@@ -634,11 +672,11 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
634
  else if (G.upload_state == 5 && !admin_message == "" && nonadmin_message == "") G.upload_state --;
635
  }
636
 
637
- // if (typeof console != "undefined") {
638
- // console.log(Params);
639
- // var GG = G;
640
- // console.log(GG);
641
- // }
642
 
643
  // section to update message box, executed only if message box is activated
644
  if (message_table) {
@@ -835,16 +873,13 @@ function wfu_redirect_to_classic(sid, session_token, flag, adminerrorcode) {
835
  //wfu_redirect_to_classic_cont: function thatinforms the page to process the file after reloading, informs the page if this is a redirection from HTML5 to classic functionality and submits the file
836
  function wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, other_params) {
837
  var process_function = function(responseText) {
838
- var pos = responseText.indexOf(":");
839
- var txt_header = responseText.substr(0, pos);
840
- var txt_value = responseText.substr(pos + 1, responseText.length - pos - 1);
841
- if (txt_header == "success") {
842
  // show message in wait for upload state
843
  var Params = wfu_Initialize_Params();
844
  Params.general.shortcode_id = sid;
845
  Params.general.unique_id = "";
846
  Params.general.files_count = wfu_filesselected(sid);
847
- wfu_ProcessUploadComplete(sid, 0, Params, "no-ajax", "", session_token, "");
848
 
849
  if (flag == 1) {
850
  var suffice = "";
@@ -959,6 +994,8 @@ function wfu_HTML5UploadFile(sid, JSONtext, session_token) {
959
  var numfiles = wfu_filesselected(sid);
960
  if (numfiles == 0) return;
961
 
 
 
962
  // check if there are empty user data fields that are required
963
  if (!wfu_check_required_userdata(sid)) return;
964
 
@@ -966,6 +1003,66 @@ function wfu_HTML5UploadFile(sid, JSONtext, session_token) {
966
  }
967
 
968
  function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
969
  // get index of subdirectory if subdirectory dropdown list is activated
970
  var subdir_sel_index = -1;
971
  if (document.getElementById('selectsubdir_' + sid) != null)
@@ -996,6 +1093,7 @@ function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
996
  GlobalData[sid].admin_messages.wpfilebase = "";
997
  GlobalData[sid].admin_messages.notify = "";
998
  GlobalData[sid].admin_messages.redirect = "";
 
999
  GlobalData[sid].admin_messages.other = "";
1000
  GlobalData[sid].errors = {};
1001
  GlobalData[sid].errors.wpfilebase = "";
@@ -1009,71 +1107,11 @@ function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
1009
  var Params = wfu_Initialize_Params();
1010
  Params.general.shortcode_id = sid;
1011
  Params.general.unique_id = rand_str;
1012
- wfu_ProcessUploadComplete(sid, 0, Params, rand_str, JSONobj.params_index, session_token, "");
1013
 
 
1014
  for (var i = 0; i < farr.length; i++) {
1015
- // initialise AJAX and FormData objects
1016
- var xhr = wfu_GetHttpRequestObject();
1017
- if (xhr == null) return;
1018
- var fd = null;
1019
- try {
1020
- var fd = new FormData();
1021
- }
1022
- catch(e) {}
1023
- if (fd == null) return;
1024
-
1025
- // define POST parameters
1026
- fd.append("uploadedfile_" + sid + suffice, farr[i]);
1027
- fd.append("action", "wfu_ajax_action");
1028
- fd.append("params_index", JSONobj.params_index);
1029
- fd.append("subdir_sel_index", subdir_sel_index);
1030
- fd.append("session_token", session_token);
1031
- fd.append("unique_id", rand_str);
1032
- var userdata_count = wfu_get_userdata_count(sid);
1033
- for (var ii = 0; ii < userdata_count; ii++)
1034
- fd.append("hiddeninput_" + sid + "_userdata_" + ii, document.getElementById('hiddeninput_' + sid + '_userdata_' + ii).value);
1035
-
1036
- // define variables
1037
- GlobalData[sid].xhrs.push(xhr);
1038
- var d = new Date();
1039
- xhr.shortcode_id = sid;
1040
- xhr.file_id = i + 1;
1041
- xhr.size = 0;
1042
- xhr.sizeloaded = 0;
1043
- xhr.unique_id = rand_str;
1044
- xhr.params_index = JSONobj.params_index;
1045
- xhr.session_token = session_token;
1046
- xhr.finish_time = d.getTime() + JSONobj.max_time_limit * 1000;
1047
- xhr.fail_colors = JSONobj.fail_colors;
1048
- xhr.default_colors = JSONobj.default_colors;
1049
- xhr.error_message_header = JSONobj.error_message_header.replace(/%username%/g, "no data");
1050
- xhr.error_message_header = xhr.error_message_header.replace(/%useremail%/g, "no data");
1051
- xhr.error_message_header = xhr.error_message_header.replace(/%filename%/g, farr[i].name);
1052
- xhr.error_message_header = xhr.error_message_header.replace(/%filepath%/g, farr[i].name);
1053
- xhr.error_message_failed = JSONobj.error_message_failed;
1054
- xhr.error_message_cancelled = JSONobj.error_message_cancelled;
1055
- xhr.error_message_unknown = JSONobj.error_message_unknown;
1056
- xhr.error_adminmessage_unknown = JSONobj.error_adminmessage_unknown.replace(/%username%/g, "no data");
1057
- xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%useremail%/g, "no data");
1058
- xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filename%/g, farr[i].name);
1059
- xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filepath%/g, farr[i].name);
1060
- xhr.error_jsonparse_headermessage = JSONobj.error_jsonparse_headermessage;
1061
- xhr.error_jsonparse_headeradminmessage = JSONobj.error_jsonparse_headeradminmessage;
1062
-
1063
- xhr.error_message_timelimit = JSONobj.error_message_timelimit;
1064
- xhr.error_message_admin_timelimit = JSONobj.error_message_admin_timelimit;
1065
- xhr.upload.xhr = xhr;
1066
-
1067
- // event listeners
1068
- xhr.upload.addEventListener("loadstart", wfu_loadStart, false);
1069
- xhr.upload.addEventListener("progress", wfu_uploadProgress, false);
1070
- xhr.addEventListener("load", wfu_uploadComplete, false);
1071
- xhr.addEventListener("error", wfu_uploadFailed, false);
1072
- xhr.addEventListener("abort", wfu_uploadCanceled, false);
1073
-
1074
- // xhr.open("POST", "/wp-admin/admin-ajax.php");
1075
- xhr.open("POST", JSONobj.open_url);
1076
- xhr.send(fd);
1077
  }
1078
  }
1079
 
15
  var consts_arr = consts.split(";");
16
  var const_arr;
17
  for (var i = 0; i < consts_arr.length; i++) {
18
+ const_txt = consts_arr[i].split(":");
19
+ GlobalData.consts[wfu_plugin_decode_string(const_txt[0])] = wfu_plugin_decode_string(const_txt[1]);
 
20
  }
21
  }
22
 
316
  var percentComplete = 0;
317
  var simplebar = document.getElementById('progressbar_' + sid + '_animation');
318
  if (evt.lengthComputable) {
319
+ if (this.xhr.size != evt.total && evt.total > 0) this.xhr.size = evt.total;
320
  if (simplebar) {
321
  var total = 0;
322
  var totalloaded = 0;
342
  }
343
 
344
  /* wfu_send_email_notification: function to send notification message as ajax request */
345
+ function wfu_send_email_notification(sid, unique_id, params_index, session_token, notify_only_filename_list, notify_target_path_list, notify_attachment_list, debugmode) {
346
  var xhr = wfu_GetHttpRequestObject();
347
  if (xhr == null) {
348
  // error sending email
349
  return;
350
  }
351
 
352
+ var url = GlobalData.consts.ajax_url;
353
  var userdata_count = wfu_get_userdata_count(sid);
354
  params = new Array(7 + userdata_count);
355
  params[0] = new Array(2);
384
  parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
385
  }
386
 
387
+ var d = new Date();
388
  xhr.shortcode_id = sid;
389
+ xhr.requesttype = "email";
390
  xhr.file_id = 0;
391
  xhr.unique_id = unique_id;
392
+ xhr.debugmode = debugmode;
393
  xhr.params_index = params_index;
394
  xhr.session_token = session_token;
395
+ xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
396
+ xhr.fail_colors = GlobalData.consts.fail_colors;
397
+ xhr.error_message_header = "";
398
+ xhr.error_message_failed = GlobalData.consts.message_failed;
399
+ xhr.error_message_cancelled = GlobalData.consts.message_cancelled;
400
+ xhr.error_adminmessage_unknown = "";
401
+
402
  xhr.open("POST", url, true);
403
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
404
  xhr.setRequestHeader("Content-length", parameters.length);
410
  xhr.send(parameters);
411
  }
412
 
413
+ //wfu_format_debug_data: function to format and prepare debug data for output
414
+ function wfu_format_debug_data(data, title) {
415
+ output = '<label class="file_messageblock_subheader_debugmessage_label">';
416
+ output += 'Debug Data' + title;
417
+ output += '</label>';
418
+ output += '<div class="file_messageblock_subheader_debugmessage_container">';
419
+ output += data;
420
+ output += '</div>';
421
+ return output;
422
+ }
423
+
424
  //wfu_uploadComplete: function that is called after successfull file upload
425
  function wfu_uploadComplete(evt) {
426
  var sid = this.shortcode_id;
428
  var last = false;
429
  var upload_params = "";
430
  var safe_params = "";
431
+ var debug_data = "";
432
+ var result_data = evt.target.responseText;
433
  if (evt.target.responseText != -1) {
434
  var txt = evt.target.responseText;
435
+ var success_txt = "wfu_fileupload_success:";
436
+ var pos = txt.indexOf(success_txt);
437
+ if ( pos > -1 ) {
438
+ if (this.debugmode == "true") debug_data = txt.substr(0, pos);
439
+ result_data = txt.substr(pos + success_txt.length);
440
+ pos = result_data.indexOf(":");
441
+ safe_params = result_data.substr(0, pos);
442
+ upload_params = result_data.substr(pos + 1);
443
+ }
444
+ if (debug_data != "") {
445
+ var title = "";
446
+ if (this.requesttype == "fileupload") title = ' - File: ' + this.file_id;
447
+ else if (this.requesttype == "email") title = ' - Email Notification';
448
+ debug_data = wfu_format_debug_data(debug_data, title);
449
  }
450
  }
451
 
455
  Params.general.shortcode_id = sid;
456
  Params.general.unique_id = this.unique_id;
457
  Params.general.state = 7;
458
+ Params.general.files_count = (this.requesttype == "fileupload") ? 1 : 0;
459
  Params.general.upload_finish_time = this.finish_time;
460
+ Params.general.fail_message = GlobalData.consts.message_unknown;
461
+ Params.general.fail_admin_message = wfu_join_strings("<br />", this.error_adminmessage_unknown, this.requesttype + ":" + result_data);
462
+ if (Params.general.files_count > 0) {
463
+ Params[0] = {};
464
+ Params[0]['color'] = error_colors[0];
465
+ Params[0]['bgcolor'] = error_colors[1];
466
+ Params[0]['borcolor'] = error_colors[2];
467
+ Params[0]['message_type'] = "error";
468
+ Params[0]['header'] = this.error_message_header;
469
+ Params[0]['message'] = GlobalData.consts.message_timelimit;
470
+ Params[0]['admin_messages'] = GlobalData.consts.message_admin_timelimit;
471
+ }
472
+ else Params.general.admin_messages.other = GlobalData.consts.message_admin_timelimit;
473
+ //check if we have a failed upload probably due to exceeded upload time limit
474
  if (Params.general.upload_finish_time > 0) {
475
  var d = new Date();
476
  if (d.getTime() < Params.general.upload_finish_time) {
477
+ if (Params.general.files_count > 0) {
478
+ Params[0]['message'] = Params.general.fail_message;
479
+ Params[0]['admin_messages'] = Params.general.fail_admin_message;
480
+ }
481
+ else Params.general.admin_messages.other = Params.general.fail_admin_message;
482
  }
483
  }
484
  // note that upload_params is passed as object, so no need to pass a safe_output string
485
+ last = wfu_ProcessUploadComplete(sid, this.file_id, Params, this.unique_id, this.params_index, this.session_token, "", [this.debugmode, debug_data]);
486
  }
487
  else {
488
+ last = wfu_ProcessUploadComplete(sid, this.file_id, upload_params, this.unique_id, this.params_index, this.session_token, safe_params, [this.debugmode, debug_data]);
489
  }
490
  if (last) {
491
  wfu_unlock_upload(evt.target.shortcode_id);
495
  }
496
 
497
  //wfu_ProcessUploadComplete: function to perform actions after successfull upload
498
+ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, params_index, session_token, safe_output, debug_data) {
499
  //initial checks to process or not the data
500
  if (!sid || sid < 0) return;
501
  if (upload_params == null || upload_params == "") return;
584
  G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
585
  G.admin_messages.notify = Params.general.admin_messages.notify;
586
  G.admin_messages.redirect = Params.general.admin_messages.redirect;
587
+ G.admin_messages.debug = debug_data[1];
588
  G.admin_messages.other = Params.general.admin_messages.other;
589
  G.errors = {};
590
  G.errors.wpfilebase = Params.general.errors.wpfilebase;
613
  G.notify_only_filename_list = wfu_join_strings(", ", G.notify_only_filename_list, Params.general.notify_only_filename_list);
614
  G.notify_target_path_list = wfu_join_strings(", ", G.notify_target_path_list, Params.general.notify_target_path_list);
615
  G.notify_attachment_list = wfu_join_strings(",", G.notify_attachment_list, Params.general.notify_attachment_list);
616
+ G.admin_messages.debug = wfu_join_strings("<br />", G.admin_messages.debug, debug_data[1]);
617
  G.admin_messages.other = wfu_join_strings("<br />", G.admin_messages.other, Params.general.admin_messages.other);
618
  if (G.admin_messages.wpfilebase == "") G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
619
  if (G.admin_messages.notify == "") G.admin_messages.notify = Params.general.admin_messages.notify;
633
  }
634
  if (G.notify_only_filename_list != "") {
635
  G.admin_messages.notify = "";
636
+ wfu_send_email_notification(sid, unique_id, params_index, session_token, G.notify_only_filename_list, G.notify_target_path_list, G.notify_attachment_list, debug_data[0]);
637
  // in email notification we declare that this is not the last call, because we wait for a last answer from email sending result
638
  G.last = false;
639
  G.notify_only_filename_list = ""; //reset this variable so that repetitive email messages are not sent
647
  }
648
  }
649
 
650
+ // last adjustment of header messages due to json parse error of UploadState or debug messages
651
  var nonadmin_message = G.message;
652
  var admin_message = wfu_join_strings("<br />",
653
+ G.admin_messages.other,
654
+ G.admin_messages.wpfilebase,
655
+ G.admin_messages.notify,
656
+ G.admin_messages.redirect,
657
+ G.admin_messages.debug);
658
  if (!UploadStates_Ok) {
659
  var error_jsonparse_headermessage = GlobalData.consts.jsonparse_headermessage;
660
  var error_jsonparse_headeradminmessage = GlobalData.consts.jsonparse_headeradminmessage;
672
  else if (G.upload_state == 5 && !admin_message == "" && nonadmin_message == "") G.upload_state --;
673
  }
674
 
675
+ if (typeof console != "undefined") {
676
+ console.log(Params);
677
+ var GG = G;
678
+ console.log(GG);
679
+ }
680
 
681
  // section to update message box, executed only if message box is activated
682
  if (message_table) {
873
  //wfu_redirect_to_classic_cont: function thatinforms the page to process the file after reloading, informs the page if this is a redirection from HTML5 to classic functionality and submits the file
874
  function wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, other_params) {
875
  var process_function = function(responseText) {
876
+ if (responseText.indexOf("wfu_response_success:") > -1) {
 
 
 
877
  // show message in wait for upload state
878
  var Params = wfu_Initialize_Params();
879
  Params.general.shortcode_id = sid;
880
  Params.general.unique_id = "";
881
  Params.general.files_count = wfu_filesselected(sid);
882
+ wfu_ProcessUploadComplete(sid, 0, Params, "no-ajax", "", session_token, "", ["false", ""]);
883
 
884
  if (flag == 1) {
885
  var suffice = "";
994
  var numfiles = wfu_filesselected(sid);
995
  if (numfiles == 0) return;
996
 
997
+ console.log(numfiles);
998
+
999
  // check if there are empty user data fields that are required
1000
  if (!wfu_check_required_userdata(sid)) return;
1001
 
1003
  }
1004
 
1005
  function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
1006
+ function sendfile(ind, file) {
1007
+ // initialise AJAX and FormData objects
1008
+ var xhr = wfu_GetHttpRequestObject();
1009
+ if (xhr == null) return;
1010
+ var fd = null;
1011
+ try {
1012
+ var fd = new FormData();
1013
+ }
1014
+ catch(e) {}
1015
+ if (fd == null) return;
1016
+
1017
+ // define POST parameters
1018
+ fd.append("uploadedfile_" + sid + suffice, file);
1019
+ fd.append("action", "wfu_ajax_action");
1020
+ fd.append("params_index", JSONobj.params_index);
1021
+ fd.append("subdir_sel_index", subdir_sel_index);
1022
+ fd.append("session_token", session_token);
1023
+ fd.append("unique_id", rand_str);
1024
+ var userdata_count = wfu_get_userdata_count(sid);
1025
+ for (var ii = 0; ii < userdata_count; ii++)
1026
+ fd.append("hiddeninput_" + sid + "_userdata_" + ii, document.getElementById('hiddeninput_' + sid + '_userdata_' + ii).value);
1027
+
1028
+ // define variables
1029
+ GlobalData[sid].xhrs.push(xhr);
1030
+ var d = new Date();
1031
+ xhr.shortcode_id = sid;
1032
+ xhr.requesttype = "fileupload";
1033
+ xhr.file_id = ind + 1;
1034
+ xhr.size = file.size;
1035
+ xhr.sizeloaded = 0;
1036
+ xhr.unique_id = rand_str;
1037
+ xhr.params_index = JSONobj.params_index;
1038
+ xhr.session_token = session_token;
1039
+ xhr.debugmode = JSONobj.debugmode;
1040
+ xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
1041
+ xhr.fail_colors = JSONobj.fail_colors;
1042
+ xhr.error_message_header = GlobalData.consts.message_header.replace(/%username%/g, "no data");
1043
+ xhr.error_message_header = xhr.error_message_header.replace(/%useremail%/g, "no data");
1044
+ xhr.error_message_header = xhr.error_message_header.replace(/%filename%/g, file.name);
1045
+ xhr.error_message_header = xhr.error_message_header.replace(/%filepath%/g, file.name);
1046
+ xhr.error_message_failed = GlobalData.consts.message_failed;
1047
+ xhr.error_message_cancelled = GlobalData.consts.message_cancelled;
1048
+ xhr.error_adminmessage_unknown = GlobalData.consts.adminmessage_unknown.replace(/%username%/g, "no data");
1049
+ xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%useremail%/g, "no data");
1050
+ xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filename%/g, file.name);
1051
+ xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filepath%/g, file.name);
1052
+
1053
+ xhr.upload.xhr = xhr;
1054
+
1055
+ // event listeners
1056
+ xhr.upload.addEventListener("loadstart", wfu_loadStart, false);
1057
+ xhr.upload.addEventListener("progress", wfu_uploadProgress, false);
1058
+ xhr.addEventListener("load", wfu_uploadComplete, false);
1059
+ xhr.addEventListener("error", wfu_uploadFailed, false);
1060
+ xhr.addEventListener("abort", wfu_uploadCanceled, false);
1061
+
1062
+ xhr.open("POST", GlobalData.consts.ajax_url);
1063
+ xhr.send(fd);
1064
+ inc ++;
1065
+ }
1066
  // get index of subdirectory if subdirectory dropdown list is activated
1067
  var subdir_sel_index = -1;
1068
  if (document.getElementById('selectsubdir_' + sid) != null)
1093
  GlobalData[sid].admin_messages.wpfilebase = "";
1094
  GlobalData[sid].admin_messages.notify = "";
1095
  GlobalData[sid].admin_messages.redirect = "";
1096
+ GlobalData[sid].admin_messages.debug = "";
1097
  GlobalData[sid].admin_messages.other = "";
1098
  GlobalData[sid].errors = {};
1099
  GlobalData[sid].errors.wpfilebase = "";
1107
  var Params = wfu_Initialize_Params();
1108
  Params.general.shortcode_id = sid;
1109
  Params.general.unique_id = rand_str;
1110
+ wfu_ProcessUploadComplete(sid, 0, Params, rand_str, JSONobj.params_index, session_token, "", ["false", ""]);
1111
 
1112
+ var inc = 0;
1113
  for (var i = 0; i < farr.length; i++) {
1114
+ sendfile(i, farr[i]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1115
  }
1116
  }
1117
 
languages/wordpress-file-upload-upload.pot DELETED
File without changes
languages/wordpress-file-upload.pot ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Wordpress File Upload\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-12-20 00:43+0200\n"
6
+ "PO-Revision-Date: 2013-12-20 00:44+0200\n"
7
+ "Last-Translator: nickboss <info@iptanus.com>\n"
8
+ "Language-Team: Iptanus Team <info@iptanus.com>\n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;gettext;gettext_noop\n"
14
+ "X-Poedit-Basepath: ../\n"
15
+ "X-Poedit-SearchPath-0: .\n"
16
+
17
+ #: lib/wfu_constants.php:7
18
+ msgid "Upload files"
19
+ msgstr ""
20
+
21
+ #: lib/wfu_constants.php:8
22
+ msgid "Select File"
23
+ msgstr ""
24
+
25
+ #: lib/wfu_constants.php:9
26
+ msgid "Upload File"
27
+ msgstr ""
28
+
29
+ #: lib/wfu_constants.php:24
30
+ msgid "File Upload Notification"
31
+ msgstr ""
32
+
33
+ #: lib/wfu_constants.php:25
34
+ msgid "Dear Recipient,%n%%n% This is an automatic delivery message to notify you that a new file has been uploaded.%n%%n%Best Regards"
35
+ msgstr ""
36
+
37
+ #: lib/wfu_constants.php:31
38
+ #, php-format
39
+ msgid "File %filename% uploaded successfully"
40
+ msgstr ""
41
+
42
+ #: lib/wfu_constants.php:32
43
+ #, php-format
44
+ msgid "File %filename% uploaded successfully but with warnings"
45
+ msgstr ""
46
+
47
+ #: lib/wfu_constants.php:33
48
+ msgid "File %filename% not uploaded"
49
+ msgstr ""
50
+
51
+ #: lib/wfu_constants.php:34
52
+ msgid "File %filename% is being uploaded"
53
+ msgstr ""
54
+
55
+ #: lib/wfu_constants.php:51
56
+ msgid "Your message"
57
+ msgstr ""
58
+
59
+ #: lib/wfu_constants.php:54
60
+ msgid "Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' attribute."
61
+ msgstr ""
62
+
63
+ #: lib/wfu_constants.php:55
64
+ msgid "Error. Invalid ftp information. Check 'ftpinfo' attribute."
65
+ msgstr ""
66
+
67
+ #: lib/wfu_constants.php:56
68
+ msgid "Error. Could not extract ftp information from 'ftpinfo' attribute. Check its syntax."
69
+ msgstr ""
70
+
71
+ #: lib/wfu_constants.php:57
72
+ msgid "Error. Could not resolve ftp target filename. Check the domain in 'ftpinfo' attribute."
73
+ msgstr ""
74
+
75
+ #: lib/wfu_constants.php:58
76
+ msgid ""
77
+ "Error. The upload size limit of PHP directive upload_max_filesize is preventing the upload of big files.\n"
78
+ "PHP directive upload_max_filesize limit is: "
79
+ msgstr ""
80
+
81
+ #: lib/wfu_constants.php:59
82
+ msgid ""
83
+ "The upload time limit of PHP directive max_input_time is preventing the upload of big files.\n"
84
+ "PHP directive max_input_time limit is: "
85
+ msgstr ""
86
+
87
+ #: lib/wfu_constants.php:60
88
+ msgid ""
89
+ "Error. Permission denied to write to target folder.\n"
90
+ "Check and correct read/write permissions of target folder."
91
+ msgstr ""
92
+
93
+ #: lib/wfu_constants.php:61
94
+ msgid "Targer folder doesn't exist."
95
+ msgstr ""
96
+
97
+ #: lib/wfu_constants.php:62
98
+ msgid "Upload failed! Missing a temporary folder."
99
+ msgstr ""
100
+
101
+ #: lib/wfu_constants.php:63
102
+ msgid "Upload failed! Permission denied to write to target folder."
103
+ msgstr ""
104
+
105
+ #: lib/wfu_constants.php:64
106
+ msgid "File not allowed."
107
+ msgstr ""
108
+
109
+ #: lib/wfu_constants.php:65
110
+ msgid "The uploaded file exceeds the file size limit."
111
+ msgstr ""
112
+
113
+ #: lib/wfu_constants.php:66
114
+ msgid "Upload failed! The uploaded file exceeds the file size limit of the server. Please contact the administrator."
115
+ msgstr ""
116
+
117
+ #: lib/wfu_constants.php:67
118
+ msgid "Upload failed! The duration of the upload exceeded the time limit of the server. Please contact the administrator."
119
+ msgstr ""
120
+
121
+ #: lib/wfu_constants.php:68
122
+ msgid "Upload failed! The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."
123
+ msgstr ""
124
+
125
+ #: lib/wfu_constants.php:69
126
+ msgid "Upload failed! The uploaded file was only partially uploaded."
127
+ msgstr ""
128
+
129
+ #: lib/wfu_constants.php:70
130
+ msgid "Upload failed! No file was uploaded."
131
+ msgstr ""
132
+
133
+ #: lib/wfu_constants.php:71
134
+ msgid "Upload failed! Failed to write file to disk."
135
+ msgstr ""
136
+
137
+ #: lib/wfu_constants.php:72
138
+ msgid "Upload failed! Error occured while moving temporary file. Please contact administrator."
139
+ msgstr ""
140
+
141
+ #: lib/wfu_constants.php:73
142
+ msgid "Upload failed! A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help."
143
+ msgstr ""
144
+
145
+ #: lib/wfu_constants.php:74
146
+ msgid "Upload failed! Error occured while attemting to upload the file."
147
+ msgstr ""
148
+
149
+ #: lib/wfu_constants.php:75
150
+ msgid "Upload failed!"
151
+ msgstr ""
152
+
153
+ #: lib/wfu_constants.php:76
154
+ msgid "No file!"
155
+ msgstr ""
156
+
157
+ #: lib/wfu_constants.php:77
158
+ msgid "Upload failed! The upload has been canceled by the user or the browser dropped the connection."
159
+ msgstr ""
160
+
161
+ #: lib/wfu_constants.php:78
162
+ msgid "Upload failed! Unknown error."
163
+ msgstr ""
164
+
165
+ #: lib/wfu_constants.php:79
166
+ msgid "Please contact the administrator."
167
+ msgstr ""
168
+
169
+ #: lib/wfu_constants.php:80
170
+ msgid "No result from remote server!"
171
+ msgstr ""
172
+
173
+ #: lib/wfu_constants.php:81
174
+ msgid " but with warnings"
175
+ msgstr ""
176
+
177
+ #: lib/wfu_constants.php:82
178
+ #: lib/wfu_constants.php:84
179
+ msgid "Warning: JSON parse error."
180
+ msgstr ""
181
+
182
+ #: lib/wfu_constants.php:83
183
+ msgid "Upload parameters of this file, passed as JSON string to the handler, could not be parsed."
184
+ msgstr ""
185
+
186
+ #: lib/wfu_constants.php:85
187
+ msgid "UploadStates, passed as JSON string to the handler, could not be parsed."
188
+ msgstr ""
189
+
190
+ #: lib/wfu_constants.php:86
191
+ msgid "Redirection to classic form functionality occurred due to unknown error."
192
+ msgstr ""
193
+
194
+ #: lib/wfu_constants.php:87
195
+ msgid "Redirection to classic form functionality occurred because AJAX is not supported."
196
+ msgstr ""
197
+
198
+ #: lib/wfu_constants.php:88
199
+ msgid "Redirection to classic form functionality occurred because HTML5 is not supported."
200
+ msgstr ""
201
+
202
+ #: lib/wfu_constants.php:89
203
+ msgid "Redirection to classic form functionality occurred due to JSON parse error."
204
+ msgstr ""
205
+
206
+ #: lib/wfu_constants.php:90
207
+ msgid "cannot be empty!"
208
+ msgstr ""
209
+
210
+ #: lib/wfu_constants.php:93
211
+ msgid "Upload skipped! File already exists."
212
+ msgstr ""
213
+
214
+ #: lib/wfu_constants.php:94
215
+ msgid "No files have been selected!"
216
+ msgstr ""
217
+
218
+ #: lib/wfu_constants.php:95
219
+ msgid "WPFilebase Plugin not updated because there were no files uploaded."
220
+ msgstr ""
221
+
222
+ #: lib/wfu_constants.php:96
223
+ msgid "Notification email was not sent because there were no files uploaded."
224
+ msgstr ""
225
+
226
+ #: lib/wfu_constants.php:97
227
+ msgid "Notification email was not sent because no recipients were defined. Please check notifyrecipients attribute in the shortcode."
228
+ msgstr ""
229
+
230
+ #: lib/wfu_constants.php:98
231
+ msgid "Notification email was not sent due to an error. Please check notifyrecipients, notifysubject and notifymessage attributes for errors."
232
+ msgstr ""
233
+
234
+ #: lib/wfu_constants.php:99
235
+ msgid "Redirection not executed because redirection link is empty. Please check redirectlink attribute."
236
+ msgstr ""
237
+
238
+ #: lib/wfu_constants.php:100
239
+ msgid "Redirection not executed because not all files were successfully uploaded."
240
+ msgstr ""
241
+
242
+ #: lib/wfu_constants.php:103
243
+ msgid "Test Mode"
244
+ msgstr ""
245
+
246
+ #: lib/wfu_constants.php:104
247
+ msgid "Upload path: %filepath%"
248
+ msgstr ""
249
+
250
+ #: lib/wfu_constants.php:105
251
+ msgid "Failed upload path: %filepath%"
252
+ msgstr ""
253
+
254
+ #: lib/wfu_constants.php:108
255
+ msgid "This is a test message"
256
+ msgstr ""
257
+
258
+ #: lib/wfu_constants.php:109
259
+ msgid "This is a test administrator message"
260
+ msgstr ""
261
+
262
+ #: lib/wfu_constants.php:110
263
+ msgid "File testfile 1 under test"
264
+ msgstr ""
265
+
266
+ #: lib/wfu_constants.php:111
267
+ msgid "File testfile 1 message"
268
+ msgstr ""
269
+
270
+ #: lib/wfu_constants.php:112
271
+ msgid "File testfile 1 administrator message"
272
+ msgstr ""
273
+
274
+ #: lib/wfu_constants.php:113
275
+ msgid "File testfile 2 under test"
276
+ msgstr ""
277
+
278
+ #: lib/wfu_constants.php:114
279
+ msgid "File testfile 2 message"
280
+ msgstr ""
281
+
282
+ #: lib/wfu_constants.php:115
283
+ msgid "File testfile 2 administrator message"
284
+ msgstr ""
285
+
286
+ #: lib/wfu_constants.php:118
287
+ msgid "Insert variable %username% inside text. It will be replaced by the username of the current user."
288
+ msgstr ""
289
+
290
+ #: lib/wfu_constants.php:119
291
+ msgid "Insert variable %useremail% inside text. It will be replaced by the email of the current user."
292
+ msgstr ""
293
+
294
+ #: lib/wfu_constants.php:120
295
+ msgid "Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file."
296
+ msgstr ""
297
+
298
+ #: lib/wfu_constants.php:121
299
+ msgid "Insert variable %filepath% inside text. It will be replaced by the full filepath of the uploaded file."
300
+ msgstr ""
301
+
302
+ #: lib/wfu_constants.php:122
303
+ msgid "Insert variable %blogid% inside text. It will be replaced by the blog id of the website."
304
+ msgstr ""
305
+
306
+ #: lib/wfu_constants.php:123
307
+ msgid "Insert variable %userdataXXX% inside text. Replace XXX with the number of the user field (1, 2, etc...). It will be replaced by the value that the user entered in this field."
308
+ msgstr ""
309
+
310
+ #: lib/wfu_constants.php:124
311
+ msgid "Insert variable %n% inside text to denote a line change."
312
+ msgstr ""
313
+
314
+ #: lib/wfu_constants.php:127
315
+ msgid "Upload in progress"
316
+ msgstr ""
317
+
318
+ #: lib/wfu_constants.php:128
319
+ msgid "Upload in progress with warnings!"
320
+ msgstr ""
321
+
322
+ #: lib/wfu_constants.php:129
323
+ msgid "Upload in progress but some files already failed!"
324
+ msgstr ""
325
+
326
+ #: lib/wfu_constants.php:130
327
+ msgid "Upload in progress but no files uploaded so far!"
328
+ msgstr ""
329
+
330
+ #: lib/wfu_constants.php:131
331
+ msgid "All files uploaded successfully"
332
+ msgstr ""
333
+
334
+ #: lib/wfu_constants.php:132
335
+ msgid "All files uploaded successfully but there are warnings!"
336
+ msgstr ""
337
+
338
+ #: lib/wfu_constants.php:133
339
+ msgid "File uploaded successfully but there are warnings!"
340
+ msgstr ""
341
+
342
+ #: lib/wfu_constants.php:134
343
+ msgid "Some files failed to upload!"
344
+ msgstr ""
345
+
346
+ #: lib/wfu_constants.php:135
347
+ msgid "All files failed to upload"
348
+ msgstr ""
349
+
350
+ #: lib/wfu_constants.php:136
351
+ msgid "File failed to upload"
352
+ msgstr ""
353
+
354
+ #: lib/wfu_constants.php:137
355
+ msgid "There are no files to upload!"
356
+ msgstr ""
357
+
358
+ #: lib/wfu_constants.php:138
359
+ msgid "Test upload message"
360
+ msgstr ""
361
+
362
+ #: lib/wfu_constants.php:139
363
+ msgid "JSON parse warning!"
364
+ msgstr ""
365
+
366
+ #: lib/wfu_constants.php:140
367
+ msgid "please wait while redirecting..."
368
+ msgstr ""
369
+
lib/wfu_ajaxactions.php CHANGED
@@ -58,7 +58,7 @@ function wfu_ajax_action_send_email_notification() {
58
  /* construct safe output */
59
  $sout = "0;".WFU_DEFAULTMESSAGECOLORS.";0";
60
 
61
- die("success:".$sout.":".wfu_encode_array_to_string($params_output_array));
62
  }
63
 
64
  function wfu_ajax_action_callback() {
@@ -78,7 +78,7 @@ function wfu_ajax_action_callback() {
78
  // extract safe_output from wfu_process_file_array and pass it as separate part of the response text
79
  $safe_output = $wfu_process_file_array["general"]['safe_output'];
80
  unset($wfu_process_file_array["general"]['safe_output']);
81
- die("success:".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array));
82
  }
83
 
84
  ?>
58
  /* construct safe output */
59
  $sout = "0;".WFU_DEFAULTMESSAGECOLORS.";0";
60
 
61
+ die("wfu_fileupload_success:".$sout.":".wfu_encode_array_to_string($params_output_array));
62
  }
63
 
64
  function wfu_ajax_action_callback() {
78
  // extract safe_output from wfu_process_file_array and pass it as separate part of the response text
79
  $safe_output = $wfu_process_file_array["general"]['safe_output'];
80
  unset($wfu_process_file_array["general"]['safe_output']);
81
+ die("wfu_fileupload_success:".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array));
82
  }
83
 
84
  ?>
lib/wfu_attributes.php CHANGED
@@ -364,6 +364,20 @@ function wfu_attribute_definitions() {
364
  "variables" => null,
365
  "help" => "If enabled then the plugin will be shown in test mode, meaning that all selected features will be shown but no upload will be possible. Use it to review how the plugin looks like and style it according to your needs."
366
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  array(
368
  "name" => "Plugin Component Positions",
369
  "attribute" => "placements",
364
  "variables" => null,
365
  "help" => "If enabled then the plugin will be shown in test mode, meaning that all selected features will be shown but no upload will be possible. Use it to review how the plugin looks like and style it according to your needs."
366
  ),
367
+ array(
368
+ "name" => "Debug Mode",
369
+ "attribute" => "debugmode",
370
+ "type" => "onoff",
371
+ "listitems" => null,
372
+ "value" => WFU_DEBUGMODE,
373
+ "mode" => "free",
374
+ "category" => "general",
375
+ "subcategory" => "Other Administrator Options",
376
+ "parent" => "",
377
+ "dependencies" => null,
378
+ "variables" => null,
379
+ "help" => "If enabled then the plugin will show to administrators any internal PHP warnings and errors generated during the upload process inside the message box."
380
+ ),
381
  array(
382
  "name" => "Plugin Component Positions",
383
  "attribute" => "placements",
lib/wfu_blocks.php CHANGED
@@ -14,6 +14,7 @@ function wfu_prepare_subfolders_block($params, $widths, $heights) {
14
  if ( $widths["subfolders_select"] != "" ) $styles2 .= 'width: '.$widths["subfolders_select"].'; ';
15
  if ( $heights["subfolders_select"] != "" ) $styles2 .= 'height: '.$heights["subfolders_select"].'; ';
16
  $styles2 = ' style="'.$styles2.'"';
 
17
  if ( $params["testmode"] == "true" ) {
18
  $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
19
  $subfolders_item["hidden"] = false;
@@ -34,7 +35,6 @@ function wfu_prepare_subfolders_block($params, $widths, $heights) {
34
  $subfolders_item["line2"] = '<select class="file_item_clean"'.$styles2.' id="'.$selectsubdir.'" onchange="javascript: document.getElementById(\''.$hiddeninput.'\').value = document.getElementById(\''.$selectsubdir.'\').selectedIndex;">';
35
  $subfolders_lastline = 3;
36
  $dir_levels = array ( wfu_upload_plugin_directory($params["uploadpath"]) );
37
- $subfolder_paths = array ( );
38
  $prev_level = 0;
39
  foreach ($subfolders as $subfolder) {
40
  $subfolder = trim($subfolder);
@@ -188,10 +188,10 @@ function wfu_prepare_progressbar_block($params, $widths, $heights) {
188
  if ( $styles != "" ) $styles = ' style="'.$styles.'"';
189
  $progressbar_item["line1"] = '<div id="'.$progress_bar.'" class="file_progress_bar"'.$styles.'>';
190
  $progressbar_item["line2"] = "\t".'<div id="'.$progress_bar.'_inner" class="file_progress_inner">';
191
- $progressbar_item["line4"] = "\t\t".'<span id="'.$progress_bar.'_animation" class="file_progress_noanimation">&nbsp;</span>';
192
- $progressbar_item["line5"] = "\t\t".'<img id="'.$progress_bar.'_imagesafe" class="file_progress_imagesafe" src="'.WFU_IMAGE_SIMPLE_PROGBAR.'" style="display:none;" />';
193
- $progressbar_item["line6"] = "\t".'</div>';
194
- $progressbar_item["line7"] = '</div>';
195
 
196
  return $progressbar_item;
197
  }
14
  if ( $widths["subfolders_select"] != "" ) $styles2 .= 'width: '.$widths["subfolders_select"].'; ';
15
  if ( $heights["subfolders_select"] != "" ) $styles2 .= 'height: '.$heights["subfolders_select"].'; ';
16
  $styles2 = ' style="'.$styles2.'"';
17
+ $subfolder_paths = array ( );
18
  if ( $params["testmode"] == "true" ) {
19
  $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
20
  $subfolders_item["hidden"] = false;
35
  $subfolders_item["line2"] = '<select class="file_item_clean"'.$styles2.' id="'.$selectsubdir.'" onchange="javascript: document.getElementById(\''.$hiddeninput.'\').value = document.getElementById(\''.$selectsubdir.'\').selectedIndex;">';
36
  $subfolders_lastline = 3;
37
  $dir_levels = array ( wfu_upload_plugin_directory($params["uploadpath"]) );
 
38
  $prev_level = 0;
39
  foreach ($subfolders as $subfolder) {
40
  $subfolder = trim($subfolder);
188
  if ( $styles != "" ) $styles = ' style="'.$styles.'"';
189
  $progressbar_item["line1"] = '<div id="'.$progress_bar.'" class="file_progress_bar"'.$styles.'>';
190
  $progressbar_item["line2"] = "\t".'<div id="'.$progress_bar.'_inner" class="file_progress_inner">';
191
+ $progressbar_item["line3"] = "\t\t".'<span id="'.$progress_bar.'_animation" class="file_progress_noanimation">&nbsp;</span>';
192
+ $progressbar_item["line4"] = "\t\t".'<img id="'.$progress_bar.'_imagesafe" class="file_progress_imagesafe" src="'.WFU_IMAGE_SIMPLE_PROGBAR.'" style="display:none;" />';
193
+ $progressbar_item["line5"] = "\t".'</div>';
194
+ $progressbar_item["line6"] = '</div>';
195
 
196
  return $progressbar_item;
197
  }
lib/wfu_constants.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  //define plugin defaults
4
  DEFINE("WFU_UPLOADID", "1");
5
  DEFINE("WFU_UPLOADTITLE", __('Upload files', 'wordpress-file-upload'));
@@ -41,6 +43,7 @@ DEFINE("WFU_ASKFORSUBFOLDERS", "false");
41
  DEFINE("WFU_SUBFOLDERTREE", "");
42
  DEFINE("WFU_FORCECLASSIC", "false");
43
  DEFINE("WFU_TESTMODE", "false");
 
44
  DEFINE("WFU_WIDTHS", "");
45
  DEFINE("WFU_HEIGHTS", "");
46
  DEFINE("WFU_PLACEMENTS", "title/filename+selectbutton+uploadbutton/subfolders"."/userdata"."/message");
@@ -135,7 +138,9 @@ DEFINE("WFU_UPLOAD_STATE8", __("There are no files to upload!", "wordpress-file-
135
  DEFINE("WFU_UPLOAD_STATE9", __("Test upload message", "wordpress-file-upload"));
136
  DEFINE("WFU_UPLOAD_STATE10", __("JSON parse warning!", "wordpress-file-upload"));
137
  DEFINE("WFU_UPLOAD_STATE11", __("please wait while redirecting...", "wordpress-file-upload"));
138
- DEFINE("WFU_RESPONSE_URL", WPFILEUPLOAD_DIR."wfu_response.php");
 
 
139
 
140
  //define colors
141
  DEFINE("WFU_TESTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
@@ -154,26 +159,37 @@ DEFINE("WFU_HEADERMESSAGECOLORS_STATE10", "#F88017,#FEF2E7,#633309");
154
  DEFINE("WFU_HEADERMESSAGECOLORS_STATE11", "#666666,#EEEEEE,#333333");
155
 
156
  //define images
157
- DEFINE("WFU_IMAGE_ADMIN_HELP", WPFILEUPLOAD_DIR.'images/help_16.png');
158
- DEFINE("WFU_IMAGE_ADMIN_USERDATA_ADD", WPFILEUPLOAD_DIR.'images/add_12.png');
159
- DEFINE("WFU_IMAGE_ADMIN_USERDATA_REMOVE", WPFILEUPLOAD_DIR.'images/remove_12.png');
160
- DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", WPFILEUPLOAD_DIR.'images/progbar.gif');
161
 
162
  function wfu_set_javascript_constants() {
163
  $consts = array(
164
  "nofilemessage" => WFU_ERROR_UPLOAD_NOFILESELECTED,
165
  "userdata_empty" => WFU_ERROR_USERDATA_EMPTY,
166
  "remoteserver_noresult" => WFU_ERROR_REMOTESERVER_NORESULT,
 
 
 
 
 
 
 
167
  "jsonparse_filemessage" => WFU_ERROR_JSONPARSE_FILEMESSAGE,
168
  "jsonparse_message" => WFU_ERROR_JSONPARSE_MESSAGE,
169
  "jsonparse_adminmessage" => WFU_ERROR_JSONPARSE_ADMINMESSAGE,
170
  "jsonparse_headermessage" => WFU_ERROR_JSONPARSE_HEADERMESSAGE,
171
  "jsonparse_headeradminmessage" => WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE,
172
- "response_url" => WFU_RESPONSE_URL
 
 
 
 
173
  );
174
  $consts_txt = "";
175
  foreach ( $consts as $key => $val )
176
- $consts_txt .= ( $consts_txt == "" ? "" : ";" ).wfu_plugin_encode_string($key.":".$val);
177
 
178
  return $consts_txt;
179
  }
1
  <?php
2
 
3
+ $siteurl = site_url();
4
+
5
  //define plugin defaults
6
  DEFINE("WFU_UPLOADID", "1");
7
  DEFINE("WFU_UPLOADTITLE", __('Upload files', 'wordpress-file-upload'));
43
  DEFINE("WFU_SUBFOLDERTREE", "");
44
  DEFINE("WFU_FORCECLASSIC", "false");
45
  DEFINE("WFU_TESTMODE", "false");
46
+ DEFINE("WFU_DEBUGMODE", "false");
47
  DEFINE("WFU_WIDTHS", "");
48
  DEFINE("WFU_HEIGHTS", "");
49
  DEFINE("WFU_PLACEMENTS", "title/filename+selectbutton+uploadbutton/subfolders"."/userdata"."/message");
138
  DEFINE("WFU_UPLOAD_STATE9", __("Test upload message", "wordpress-file-upload"));
139
  DEFINE("WFU_UPLOAD_STATE10", __("JSON parse warning!", "wordpress-file-upload"));
140
  DEFINE("WFU_UPLOAD_STATE11", __("please wait while redirecting...", "wordpress-file-upload"));
141
+ DEFINE("WFU_MAX_TIME_LIMIT", ini_get("max_input_time"));
142
+ DEFINE("WFU_RESPONSE_URL", $siteurl.WPFILEUPLOAD_DIR."wfu_response.php");
143
+ DEFINE("WFU_AJAX_URL", $siteurl."/wp-admin/admin-ajax.php");
144
 
145
  //define colors
146
  DEFINE("WFU_TESTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
159
  DEFINE("WFU_HEADERMESSAGECOLORS_STATE11", "#666666,#EEEEEE,#333333");
160
 
161
  //define images
162
+ DEFINE("WFU_IMAGE_ADMIN_HELP", $siteurl.WPFILEUPLOAD_DIR.'images/help_16.png');
163
+ DEFINE("WFU_IMAGE_ADMIN_USERDATA_ADD", $siteurl.WPFILEUPLOAD_DIR.'images/add_12.png');
164
+ DEFINE("WFU_IMAGE_ADMIN_USERDATA_REMOVE", $siteurl.WPFILEUPLOAD_DIR.'images/remove_12.png');
165
+ DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", $siteurl.WPFILEUPLOAD_DIR.'images/progbar.gif');
166
 
167
  function wfu_set_javascript_constants() {
168
  $consts = array(
169
  "nofilemessage" => WFU_ERROR_UPLOAD_NOFILESELECTED,
170
  "userdata_empty" => WFU_ERROR_USERDATA_EMPTY,
171
  "remoteserver_noresult" => WFU_ERROR_REMOTESERVER_NORESULT,
172
+ "message_header" => WFU_ERRORMESSAGE,
173
+ "message_failed" => WFU_ERROR_UPLOAD_FAILED_WHILE,
174
+ "message_cancelled" => WFU_ERROR_UPLOAD_CANCELLED,
175
+ "message_unknown" => WFU_ERROR_UNKNOWN,
176
+ "adminmessage_unknown" => WFU_FAILMESSAGE_DETAILS,
177
+ "message_timelimit" => WFU_ERROR_FILE_PHP_TIME,
178
+ "message_admin_timelimit" => WFU_ERROR_ADMIN_FILE_PHP_TIME,
179
  "jsonparse_filemessage" => WFU_ERROR_JSONPARSE_FILEMESSAGE,
180
  "jsonparse_message" => WFU_ERROR_JSONPARSE_MESSAGE,
181
  "jsonparse_adminmessage" => WFU_ERROR_JSONPARSE_ADMINMESSAGE,
182
  "jsonparse_headermessage" => WFU_ERROR_JSONPARSE_HEADERMESSAGE,
183
  "jsonparse_headeradminmessage" => WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE,
184
+ "default_colors" => WFU_DEFAULTMESSAGECOLORS,
185
+ "fail_colors" => WFU_FAILMESSAGECOLORS,
186
+ "max_time_limit" => WFU_MAX_TIME_LIMIT,
187
+ "response_url" => WFU_RESPONSE_URL,
188
+ "ajax_url" => WFU_AJAX_URL
189
  );
190
  $consts_txt = "";
191
  foreach ( $consts as $key => $val )
192
+ $consts_txt .= ( $consts_txt == "" ? "" : ";" ).wfu_plugin_encode_string($key).":".wfu_plugin_encode_string($val);
193
 
194
  return $consts_txt;
195
  }
lib/wfu_functions.php CHANGED
@@ -59,6 +59,16 @@ function wfu_join_strings($delimeter) {
59
  return join($delimeter, $arr);
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
62
  //********************* Array Functions *****************************************************************************************************
63
 
64
  function wfu_encode_array_to_string($arr) {
@@ -162,12 +172,15 @@ function wfu_generate_current_params_index($shortcode_id, $user_login) {
162
  $index = explode("&&", $index_str);
163
  foreach ($index as $key => $value) if ($value == "") unset($index[$key]);
164
  $index_match = preg_grep("/".$cur_index_str_search."$/", $index);
165
- if ( count($index_match) == 1 && $index_match[0] == "" ) unset($index_match[0]);
 
 
166
  if ( count($index_match) <= 0 ) {
167
  $cur_index_rand = wfu_create_random_string(16);
168
  array_push($index, $cur_index_rand.$cur_index_str);
169
  }
170
  else {
 
171
  $cur_index_rand = substr(current($index_match), 0, 16);
172
  if ( count($index_match) > 1 ) {
173
  $index_match_keys = array_keys($index_match);
@@ -189,9 +202,13 @@ function wfu_get_params_fields_from_index($params_index) {
189
  $index_str = get_option('wfu_params_index');
190
  $index = explode("&&", $index_str);
191
  $index_match = preg_grep("/^".$params_index."/", $index);
192
- if ( count($index_match) == 1 && $index_match[0] == "" ) unset($index_match[0]);
193
- if ( count($index_match) > 0 )
 
 
 
194
  list($fields['unique_id'], $fields['page_id'], $fields['shortcode_id'], $fields['user_login']) = explode("||", current($index_match));
 
195
  return $fields;
196
  }
197
 
59
  return join($delimeter, $arr);
60
  }
61
 
62
+ function wfu_create_string($size) {
63
+ $piece = str_repeat("0", 1024);
64
+ $str = "";
65
+ $reps = $size / 1024;
66
+ $rem = $size - 1024 * $reps;
67
+ for ( $i = 0; $i < $reps; $i++ ) $str .= $piece;
68
+ $str .= substr($piece, 0, $rem);
69
+ return $str;
70
+ }
71
+
72
  //********************* Array Functions *****************************************************************************************************
73
 
74
  function wfu_encode_array_to_string($arr) {
172
  $index = explode("&&", $index_str);
173
  foreach ($index as $key => $value) if ($value == "") unset($index[$key]);
174
  $index_match = preg_grep("/".$cur_index_str_search."$/", $index);
175
+ if ( count($index_match) == 1 )
176
+ foreach ( $index_match as $key => $value )
177
+ if ( $value == "" ) unset($index_match[$key]);
178
  if ( count($index_match) <= 0 ) {
179
  $cur_index_rand = wfu_create_random_string(16);
180
  array_push($index, $cur_index_rand.$cur_index_str);
181
  }
182
  else {
183
+ reset($index_match);
184
  $cur_index_rand = substr(current($index_match), 0, 16);
185
  if ( count($index_match) > 1 ) {
186
  $index_match_keys = array_keys($index_match);
202
  $index_str = get_option('wfu_params_index');
203
  $index = explode("&&", $index_str);
204
  $index_match = preg_grep("/^".$params_index."/", $index);
205
+ if ( count($index_match) == 1 )
206
+ foreach ( $index_match as $key => $value )
207
+ if ( $value == "" ) unset($index_match[$key]);
208
+ if ( count($index_match) > 0 ) {
209
+ reset($index_match);
210
  list($fields['unique_id'], $fields['page_id'], $fields['shortcode_id'], $fields['user_login']) = explode("||", current($index_match));
211
+ }
212
  return $fields;
213
  }
214
 
lib/wfu_io.php CHANGED
@@ -55,7 +55,7 @@ function wfu_upload_file($source, $target, $method, $ftpdata) {
55
  $ret_message = WFU_ERROR_ADMIN_DIR_PERMISSION;
56
  }
57
  }
58
- else if ( $method == "ftp" && $ftpdata != "" ) {
59
  $result = false;
60
  $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $ftpdata);
61
  $pos1 = strpos($ftpdata_flat, ":");
55
  $ret_message = WFU_ERROR_ADMIN_DIR_PERMISSION;
56
  }
57
  }
58
+ elseif ( $method == "ftp" && $ftpdata != "" ) {
59
  $result = false;
60
  $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $ftpdata);
61
  $pos1 = strpos($ftpdata_flat, ":");
lib/wfu_message.php CHANGED
@@ -37,7 +37,7 @@ function wfu_prepare_message_block_skeleton($sid, $styles, $test) {
37
  $messageblock_header = 'wfu_messageblock_header_'.$sid;
38
  $messageblock_arrow = 'wfu_messageblock_arrow_'.$sid;
39
  $messageblock_subheader = 'wfu_messageblock_subheader_'.$sid;
40
- $dlp .= "\n\t\t\t\t\t\t\t";
41
 
42
  /* Prepare header HTML template
43
  Variables:
37
  $messageblock_header = 'wfu_messageblock_header_'.$sid;
38
  $messageblock_arrow = 'wfu_messageblock_arrow_'.$sid;
39
  $messageblock_subheader = 'wfu_messageblock_subheader_'.$sid;
40
+ $dlp = "\n\t\t\t\t\t\t\t";
41
 
42
  /* Prepare header HTML template
43
  Variables:
lib/wfu_processfiles.php CHANGED
@@ -81,7 +81,7 @@ function wfu_process_files($params, $method) {
81
  if ( $files_count == 1 ) {
82
 
83
  foreach ( $_FILES[$uploadedfile] as $key => $prop )
84
- $fileprops[$key] = $prop;
85
 
86
  $upload_path_ok = false;
87
  $allowed_file_ok = false;
@@ -210,10 +210,10 @@ function wfu_process_files($params, $method) {
210
  $name_part = substr($name_part, 0, $dot_pos);
211
  }
212
  if ( $params["uniquepattern"] != "datetimestamp" ) {
213
- $unique_id = 1;
214
  do {
215
- $unique_id += 1;
216
- $only_filename = $name_part . "(" . $unique_id . ")" . $ext_part;
217
  $target_path = $full_path . $only_filename;
218
  }
219
  while ( file_exists($target_path) );
@@ -234,6 +234,8 @@ function wfu_process_files($params, $method) {
234
  $file_copied = $wfu_upload_file_ret["uploaded"];
235
  //process warning messages from move_uploaded_file
236
  $echo_message = ob_get_contents();
 
 
237
  if ( $echo_message != "" && !$file_copied ) {
238
  $file_output['message_type'] = "error";
239
  if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
@@ -246,15 +248,9 @@ function wfu_process_files($params, $method) {
246
  }
247
  $message_processed = true;
248
  }
249
- //finish redirecting of echo to internal buffer
250
- ob_end_clean();
251
  if ( $wfu_upload_file_ret["admin_message"] != "" ) {
252
  $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
253
  }
254
- if ( $file_copied ) {
255
- $file_output['message_type'] = "success";
256
- $message_processed = true;
257
- }
258
  }
259
  else {
260
  $file_output['message_type'] = "error";
@@ -361,7 +357,7 @@ function wfu_process_files($params, $method) {
361
  /* suppress again any admin messages if user is not administrator or adminmessages is not activated */
362
  if ( $suppress_admin_messages ) $file_output['admin_messages'] = "";
363
 
364
- $params_output_array[0] = $file_output;
365
  }
366
 
367
  $somefiles_Ok = ( ( $warning_count + $success_count ) > 0 );
81
  if ( $files_count == 1 ) {
82
 
83
  foreach ( $_FILES[$uploadedfile] as $key => $prop )
84
+ $fileprops[$key] = $prop;
85
 
86
  $upload_path_ok = false;
87
  $allowed_file_ok = false;
210
  $name_part = substr($name_part, 0, $dot_pos);
211
  }
212
  if ( $params["uniquepattern"] != "datetimestamp" ) {
213
+ $unique_ind = 1;
214
  do {
215
+ $unique_ind += 1;
216
+ $only_filename = $name_part . "(" . $unique_ind . ")" . $ext_part;
217
  $target_path = $full_path . $only_filename;
218
  }
219
  while ( file_exists($target_path) );
234
  $file_copied = $wfu_upload_file_ret["uploaded"];
235
  //process warning messages from move_uploaded_file
236
  $echo_message = ob_get_contents();
237
+ //finish redirecting of echo to internal buffer
238
+ ob_end_clean();
239
  if ( $echo_message != "" && !$file_copied ) {
240
  $file_output['message_type'] = "error";
241
  if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
248
  }
249
  $message_processed = true;
250
  }
 
 
251
  if ( $wfu_upload_file_ret["admin_message"] != "" ) {
252
  $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
253
  }
 
 
 
 
254
  }
255
  else {
256
  $file_output['message_type'] = "error";
357
  /* suppress again any admin messages if user is not administrator or adminmessages is not activated */
358
  if ( $suppress_admin_messages ) $file_output['admin_messages'] = "";
359
 
360
+ $params_output_array[0] = $file_output;
361
  }
362
 
363
  $somefiles_Ok = ( ( $warning_count + $success_count ) > 0 );
readme.txt CHANGED
@@ -33,7 +33,7 @@ The characteristics of the plugin are:
33
 
34
  Please note that old desktop browsers or mobile browsers may not support all of the above functionalities. In order to get full functionality use the latest versions browsers, supporting HTML5, AJAX and CSS3.
35
 
36
- For additional features, such as multiple file upload, drag and drop of files, captcha and detailed upload progress bars please consider [Wordpress File Upload Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page").
37
 
38
  Please visit the **Other Notes** section for customization options of this plugin.
39
 
@@ -74,6 +74,10 @@ Files by default are uploaded inside wp-content directory of your Wordpress webs
74
 
75
  Yes, you can control allowed file size and file extensions by using the appropriate attribute (see Other Notes section).
76
 
 
 
 
 
77
  = Who can upload files? =
78
 
79
  By default only administrators can upload files. However you can define which user roles are allowed to upload files, beyond administrators. Even guests can be allowed to upload files, however use this option with care.
@@ -92,6 +96,15 @@ The plugin is designed not to expose website information by using sessions. Para
92
 
93
  == Changelog ==
94
 
 
 
 
 
 
 
 
 
 
95
  = 2.0.2 =
96
  * Bug fixes in Dashboard Settings Shortcode Composer.
97
  * Correction of important bug that was breaking page in some cases.
@@ -223,6 +236,12 @@ Initial version.
223
 
224
  == Upgrade Notice ==
225
 
 
 
 
 
 
 
226
  = 2.0.2 =
227
  Important upgrade to address some serious bugs.
228
 
@@ -350,6 +369,8 @@ A detailed list of attributes, together with instructions is shown below:
350
  * **adminmessages:** This attribute offers the option to administrator users to receive additional information about upload errors. These messages will be visible only to administrators. Default value is "false".
351
  * **forceclassic:** This attribute defines if the plugin will use the old classic functionality to upload files (using forms) or ajax functionality (supported in HTML5). Default value is "false". Please note that if your browser does not support HTML ajax functionality, then the plugin will automatically switch to classic one.
352
  * **testmode:** This attribute defines if the plugin will be shown in test mode. Default value is "false". If it is set to "true", then the plugin will obtain a "dummy" functionality (it will not be able to upload files) and it will appear showing all of its objects (the selection of subfolders, progress bar, a test message), while the buttons will show a "Test Mode" message when pressed. This option can be used to configure the dimensions of the individual objects of the plugin more easily.
 
 
353
 
354
  **Placements**
355
 
33
 
34
  Please note that old desktop browsers or mobile browsers may not support all of the above functionalities. In order to get full functionality use the latest versions browsers, supporting HTML5, AJAX and CSS3.
35
 
36
+ For additional features, such as multiple file upload, very large file upload, drag and drop of files, captcha and detailed upload progress bars please consider [Wordpress File Upload Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page").
37
 
38
  Please visit the **Other Notes** section for customization options of this plugin.
39
 
74
 
75
  Yes, you can control allowed file size and file extensions by using the appropriate attribute (see Other Notes section).
76
 
77
+ = Are there any upload file size limitations? =
78
+
79
+ Yes, there are file size limitations imposed by the web server or the host. If you want to upload very large files, please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version of the plugin, which surpasses size limitations.
80
+
81
  = Who can upload files? =
82
 
83
  By default only administrators can upload files. However you can define which user roles are allowed to upload files, beyond administrators. Even guests can be allowed to upload files, however use this option with care.
96
 
97
  == Changelog ==
98
 
99
+ = 2.1.2 =
100
+ * Several bug fixes and code reconstruction.
101
+ * Code modifications so that the plugin can operate even when DEBUG mode is ON.
102
+ * New attribute debugmode added to allow better debugging of the plugin when there are errors.
103
+
104
+ = 2.1.1 =
105
+ * Bug fixes with broken images when Wordpress website is in a subdirectory.
106
+ * Replacement of glob function because is not allowed by some servers.
107
+
108
  = 2.0.2 =
109
  * Bug fixes in Dashboard Settings Shortcode Composer.
110
  * Correction of important bug that was breaking page in some cases.
236
 
237
  == Upgrade Notice ==
238
 
239
+ = 2.1.2 =
240
+ Important upgrade to address some bugs.
241
+
242
+ = 2.1.1 =
243
+ Important upgrade to address some serious bugs.
244
+
245
  = 2.0.2 =
246
  Important upgrade to address some serious bugs.
247
 
369
  * **adminmessages:** This attribute offers the option to administrator users to receive additional information about upload errors. These messages will be visible only to administrators. Default value is "false".
370
  * **forceclassic:** This attribute defines if the plugin will use the old classic functionality to upload files (using forms) or ajax functionality (supported in HTML5). Default value is "false". Please note that if your browser does not support HTML ajax functionality, then the plugin will automatically switch to classic one.
371
  * **testmode:** This attribute defines if the plugin will be shown in test mode. Default value is "false". If it is set to "true", then the plugin will obtain a "dummy" functionality (it will not be able to upload files) and it will appear showing all of its objects (the selection of subfolders, progress bar, a test message), while the buttons will show a "Test Mode" message when pressed. This option can be used to configure the dimensions of the individual objects of the plugin more easily.
372
+ * **debugmode:** This attribute defines if the plugin will show debug information. Default value is "false". If it is set to "true", then the plugin will show in the message box any warnings and errors generated by PHP during the upload process. It can be used by administrators for deep debugging. For generation of PHP warnings and errors, global Wordpress WP_DEBUG constant must be enabled.
373
+
374
 
375
  **Placements**
376
 
screenshot-1.jpg CHANGED
Binary file
screenshot-2.jpg CHANGED
Binary file
screenshot-3.jpg CHANGED
Binary file
screenshot-4.jpg CHANGED
Binary file
screenshot-5.jpg CHANGED
Binary file
wfu_response.php CHANGED
@@ -13,7 +13,7 @@ if ( isset($_GET['shortcode_id']) && isset($_GET['session_token']) ) {
13
  $_SESSION['wfu_check_refresh_'.$_GET['shortcode_id']] = 'form button pressed';
14
  $_SESSION['wfu_start_time_'.$_GET['shortcode_id']] = $_GET['start_time'];
15
 
16
- die("success:");
17
  }
18
  }
19
  die();
13
  $_SESSION['wfu_check_refresh_'.$_GET['shortcode_id']] = 'form button pressed';
14
  $_SESSION['wfu_start_time_'.$_GET['shortcode_id']] = $_GET['start_time'];
15
 
16
+ die("wfu_response_success:");
17
  }
18
  }
19
  die();
wordpress_file_upload.php CHANGED
@@ -4,7 +4,7 @@ session_start();
4
  Plugin Name: Wordpress File Upload
5
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
  Description: Simple interface to upload files from a page.
7
- Version: 2.0.2
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
@@ -56,8 +56,19 @@ add_action('wp_ajax_wfu_ajax_action', 'wfu_ajax_action_callback');
56
  add_action('wp_ajax_nopriv_wfu_ajax_action', 'wfu_ajax_action_callback');
57
  add_action('wp_ajax_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
58
  add_action('wp_ajax_nopriv_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
59
- foreach ( glob( plugin_dir_path( __FILE__ )."lib/*.php" ) as $file )
60
- include_once $file;
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  /* exit if we are in admin pages (in case of ajax call) */
63
  if ( is_admin() ) return;
@@ -76,6 +87,7 @@ function wordpress_file_upload_handler($incomingfrompost) {
76
 
77
  function wordpress_file_upload_function($incomingfromhandler) {
78
  global $post;
 
79
  $params = wfu_plugin_parse_array($incomingfromhandler);
80
  $sid = $params["uploadid"];
81
 
@@ -158,19 +170,8 @@ function wordpress_file_upload_function($incomingfromhandler) {
158
  update_option('wfu_params_'.$params_index, $params_str);
159
  $ajax_params['shortcode_id'] = $sid;
160
  $ajax_params['params_index'] = $params_index;
161
- $ajax_params['max_time_limit'] = ini_get("max_input_time");
162
  $ajax_params["fail_colors"] = $params["failmessagecolors"];
163
- $ajax_params["default_colors"] = WFU_DEFAULTMESSAGECOLORS;
164
- $ajax_params["error_message_header"] = WFU_ERRORMESSAGE;
165
- $ajax_params["error_message_failed"] = WFU_ERROR_UPLOAD_FAILED_WHILE;
166
- $ajax_params["error_message_cancelled"] = WFU_ERROR_UPLOAD_CANCELLED;
167
- $ajax_params["error_message_unknown"] = WFU_ERROR_UNKNOWN;
168
- $ajax_params["error_adminmessage_unknown"] = WFU_FAILMESSAGE_DETAILS;
169
- $ajax_params["error_message_timelimit"] = WFU_ERROR_FILE_PHP_TIME;
170
- $ajax_params["error_message_admin_timelimit"] = WFU_ERROR_ADMIN_FILE_PHP_TIME;
171
- $ajax_params["error_jsonparse_headermessage"] = WFU_ERROR_JSONPARSE_HEADERMESSAGE;
172
- $ajax_params["error_jsonparse_headeradminmessage"] = WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE;
173
- $ajax_params["open_url"] = site_url().'/wp-admin/admin-ajax.php';
174
 
175
  $ajax_params_str = wfu_encode_array_to_string($ajax_params);
176
  $upload_clickaction = 'wfu_HTML5UploadFile('.$sid.', \''.$ajax_params_str.'\', \''.$_SESSION['wfu_token_'.$sid].'\')';
@@ -269,7 +270,7 @@ function wordpress_file_upload_function($incomingfromhandler) {
269
  unset($wfu_process_file_array["general"]['safe_output']);
270
 
271
  $wfu_process_file_array_str = wfu_encode_array_to_string($wfu_process_file_array);
272
- $ProcessUploadComplete_functiondef = 'function(){wfu_ProcessUploadComplete('.$sid.', 1, "'.$wfu_process_file_array_str.'", "no-ajax", "", "", "'.$safe_output.'");}';
273
  $wordpress_file_upload_output .= '<script type="text/javascript">window.onload='.$ProcessUploadComplete_functiondef.'</script>';
274
 
275
 
4
  Plugin Name: Wordpress File Upload
5
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
  Description: Simple interface to upload files from a page.
7
+ Version: 2.1.2
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
56
  add_action('wp_ajax_nopriv_wfu_ajax_action', 'wfu_ajax_action_callback');
57
  add_action('wp_ajax_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
58
  add_action('wp_ajax_nopriv_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
59
+ wfu_include_lib();
60
+ //foreach ( glob( plugin_dir_path( __FILE__ )."lib/*.php" ) as $file )
61
+ // include_once $file;
62
+
63
+ function wfu_include_lib() {
64
+ if ( $handle = opendir(plugin_dir_path( __FILE__ )."lib/") ) {
65
+ $blacklist = array('.', '..');
66
+ while ( false !== ($file = readdir($handle)) )
67
+ if ( !in_array($file, $blacklist) )
68
+ include_once plugin_dir_path( __FILE__ )."lib/".$file;
69
+ closedir($handle);
70
+ }
71
+ }
72
 
73
  /* exit if we are in admin pages (in case of ajax call) */
74
  if ( is_admin() ) return;
87
 
88
  function wordpress_file_upload_function($incomingfromhandler) {
89
  global $post;
90
+ global $blog_id;
91
  $params = wfu_plugin_parse_array($incomingfromhandler);
92
  $sid = $params["uploadid"];
93
 
170
  update_option('wfu_params_'.$params_index, $params_str);
171
  $ajax_params['shortcode_id'] = $sid;
172
  $ajax_params['params_index'] = $params_index;
173
+ $ajax_params['debugmode'] = $params["debugmode"];
174
  $ajax_params["fail_colors"] = $params["failmessagecolors"];
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  $ajax_params_str = wfu_encode_array_to_string($ajax_params);
177
  $upload_clickaction = 'wfu_HTML5UploadFile('.$sid.', \''.$ajax_params_str.'\', \''.$_SESSION['wfu_token_'.$sid].'\')';
270
  unset($wfu_process_file_array["general"]['safe_output']);
271
 
272
  $wfu_process_file_array_str = wfu_encode_array_to_string($wfu_process_file_array);
273
+ $ProcessUploadComplete_functiondef = 'function(){wfu_ProcessUploadComplete('.$sid.', 1, "'.$wfu_process_file_array_str.'", "no-ajax", "", "", "'.$safe_output.'", ["false", ""]);}';
274
  $wordpress_file_upload_output .= '<script type="text/javascript">window.onload='.$ProcessUploadComplete_functiondef.'</script>';
275
 
276