WordPress File Upload - Version 2.1.3

Version Description

  • variables %pagetitle% and %pageid% added in uploadpath.
  • bug fixes when working with IE8.
  • Shortcode Composer saves selected options
  • Easier handling of userdata variables in Shortcode Composer
  • correction of bug that allowed debugdata to be shown in non-admin users
  • reset.css removed from plugin as it was causing breaks in theme's css
  • correction of bug with WPFilebase Manager plugin
Download this release

Release Info

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

Code changes from version 2.1.2 to 2.1.3

css/wordpress_file_upload_adminstyle.css CHANGED
@@ -71,11 +71,36 @@ table.wfu_main_table tr.wfu_subcategory { background-color: #ddd; }
71
 
72
  table.wfu_main_table tr.wfu_subcategory > th { padding-top: 0; padding-bottom: 0; }
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  span.wfu_variable
75
  {
 
 
76
  font-size: smaller;
77
  background-color: #ddd;
78
  border: 1px solid #ccc;
 
79
  -webkit-border-radius: 5px;
80
  -moz-border-radius: 5px;
81
  -khtml-border-radius: 5px;
@@ -482,3 +507,26 @@ div.wfu_color_container
482
  }
483
  input[type="text"].wp-color-picker { width: 75px; }
484
  input[type="button"].wp-picker-clear { width: 62px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  table.wfu_main_table tr.wfu_subcategory > th { padding-top: 0; padding-bottom: 0; }
73
 
74
+ select.wfu_variable
75
+ {
76
+ padding: 0px;
77
+ margin: 0px;
78
+ height: auto;
79
+ font-size: smaller;
80
+ background-color: #ddd;
81
+ border: 1px solid #ccc;
82
+ color: rgb(51, 51, 51);
83
+ -webkit-border-radius: 5px;
84
+ -moz-border-radius: 5px;
85
+ -khtml-border-radius: 5px;
86
+ border-radius: 5px;
87
+ -webkit-touch-callout: none;
88
+ -webkit-user-select: none;
89
+ -khtml-user-select: none;
90
+ -moz-user-select: none;
91
+ -ms-user-select: none;
92
+ user-select: none;
93
+ cursor: default;
94
+ }
95
+
96
  span.wfu_variable
97
  {
98
+ padding: 1px;
99
+ margin: 0px;
100
  font-size: smaller;
101
  background-color: #ddd;
102
  border: 1px solid #ccc;
103
+ color: rgb(51, 51, 51);
104
  -webkit-border-radius: 5px;
105
  -moz-border-radius: 5px;
106
  -khtml-border-radius: 5px;
507
  }
508
  input[type="text"].wp-color-picker { width: 75px; }
509
  input[type="button"].wp-picker-clear { width: 62px; }
510
+
511
+ /* Shortcode Styles */
512
+ span.wfu_save_label
513
+ {
514
+ background-color: aliceblue;
515
+ color: limegreen;
516
+ border-radius: 6px;
517
+ padding: 1px 2px;
518
+ box-shadow: 1px 1px 1px;
519
+ font-size: smaller;
520
+ opacity: 0;
521
+ }
522
+
523
+ span.wfu_save_label_fail
524
+ {
525
+ background-color: beige;
526
+ color: lightcoral;
527
+ border-radius: 6px;
528
+ padding: 1px 2px;
529
+ box-shadow: 1px 1px 1px;
530
+ font-size: smaller;
531
+ opacity: 0;
532
+ }
css/wordpress_file_upload_reset.css CHANGED
@@ -19,7 +19,7 @@ time, mark, audio, video {
19
  padding: 0;
20
  border: 0;
21
  font-size: 100%;
22
- font: inherit;
23
  vertical-align: baseline;
24
  }
25
  /* HTML5 display-role reset for older browsers */
19
  padding: 0;
20
  border: 0;
21
  font-size: 100%;
22
+ /* font: inherit;*/
23
  vertical-align: baseline;
24
  }
25
  /* HTML5 display-role reset for older browsers */
js/wordpress_file_upload_adminfunctions.js CHANGED
@@ -1,4 +1,7 @@
1
  var DraggedItem = null;
 
 
 
2
 
3
  jQuery(document).ready(function($){
4
  $('.wfu_color_field').wpColorPicker({
@@ -47,6 +50,7 @@ function wfu_admin_onoff_clicked(key) {
47
  for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "none";
48
  }
49
  wfu_generate_shortcode();
 
50
  }
51
 
52
  function wfu_admin_radio_clicked(key) {
@@ -377,7 +381,8 @@ function wfu_generate_shortcode() {
377
  var item;
378
  var attribute = "";
379
  var value = "";
380
- var shortcode = "[wordpress_file_upload";
 
381
  for (var i = 0; i < defaults.childNodes.length; i++) {
382
  item = defaults.childNodes[i];
383
  if (item.nodeType === 1) {
@@ -387,9 +392,12 @@ function wfu_generate_shortcode() {
387
  shortcode += " " + attribute + "=\"" + value + "\"";
388
  }
389
  }
390
- shortcode += "]";
391
 
392
- document.getElementById("wfu_shortcode").value = shortcode;
 
 
 
393
  }
394
 
395
  function wfu_update_text_value(e) {
@@ -503,6 +511,30 @@ function wfu_update_userfield_value(e) {
503
  item.oldVal = val;
504
  document.getElementById("wfu_attribute_value_userdatalabel").value = val;
505
  wfu_generate_shortcode();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  }
507
  }
508
 
@@ -513,6 +545,8 @@ function wfu_attach_element_handlers(item, handler) {
513
  }
514
 
515
  function wfu_Attach_Admin_Events() {
 
 
516
  wfu_Attach_Admin_DragDrop_Events();
517
  var text_elements = document.getElementsByName("wfu_text_elements");
518
  for (var i = 0; i < text_elements.length; i++) wfu_attach_element_handlers(text_elements[i], wfu_update_text_value);
@@ -534,3 +568,127 @@ function wfu_insert_variable(obj) {
534
  inp.value = prevval.substr(0, pos) + obj.innerHTML + prevval.substr(pos);
535
  wfu_update_text_value({target:inp});
536
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  var DraggedItem = null;
2
+ var ShortcodeNextSave = 0;
3
+ var ShortcodeTimeOut = null;
4
+ var ShortcodeString = "";
5
 
6
  jQuery(document).ready(function($){
7
  $('.wfu_color_field').wpColorPicker({
50
  for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "none";
51
  }
52
  wfu_generate_shortcode();
53
+ if (key == "userdata") wfu_update_userfield_variables();
54
  }
55
 
56
  function wfu_admin_radio_clicked(key) {
381
  var item;
382
  var attribute = "";
383
  var value = "";
384
+ var shortcode_full = "[wordpress_file_upload";
385
+ var shortcode = "";
386
  for (var i = 0; i < defaults.childNodes.length; i++) {
387
  item = defaults.childNodes[i];
388
  if (item.nodeType === 1) {
392
  shortcode += " " + attribute + "=\"" + value + "\"";
393
  }
394
  }
395
+ shortcode_full += shortcode + "]";
396
 
397
+ document.getElementById("wfu_shortcode").value = shortcode_full;
398
+ ShortcodeString = shortcode.substr(1);
399
+
400
+ wfu_schedule_save_shortcode();
401
  }
402
 
403
  function wfu_update_text_value(e) {
511
  item.oldVal = val;
512
  document.getElementById("wfu_attribute_value_userdatalabel").value = val;
513
  wfu_generate_shortcode();
514
+ wfu_update_userfield_variables();
515
+ }
516
+ }
517
+
518
+ function wfu_update_userfield_variables() {
519
+ var userdata = document.getElementById("wfu_attribute_value_userdatalabel").value;
520
+ var container = document.getElementById("wfu_wrapper");
521
+ var shadows = document.getElementsByClassName("wfu_shadow_userdata", "div", container);
522
+ var selects = document.getElementsByName("wfu_userfield_select");
523
+ for (var i = 0; i < selects.length; i++) selects[i].style.display = "none";
524
+ if (shadows.length == 0) return;
525
+ if (shadows[0].style.display == "block") return;
526
+
527
+ var options_str = '<option style="display:none;">%userdataXXX%</option>';
528
+ var userfields = userdata.split("/");
529
+ var field = "";
530
+ for (var i = 1; i <= userfields.length; i++) {
531
+ field = userfields[i - 1];
532
+ if (field[0] == "*") field = field.substr(1);
533
+ options_str += '<option value="%userdata' + i + '%">' + i + ': ' + field + '</option>';
534
+ }
535
+ for (var i = 0; i < selects.length; i++) {
536
+ selects[i].innerHTML = options_str;
537
+ selects[i].style.display = "inline-block";
538
  }
539
  }
540
 
545
  }
546
 
547
  function wfu_Attach_Admin_Events() {
548
+ wfu_generate_shortcode();
549
+ wfu_update_userfield_variables();
550
  wfu_Attach_Admin_DragDrop_Events();
551
  var text_elements = document.getElementsByName("wfu_text_elements");
552
  for (var i = 0; i < text_elements.length; i++) wfu_attach_element_handlers(text_elements[i], wfu_update_text_value);
568
  inp.value = prevval.substr(0, pos) + obj.innerHTML + prevval.substr(pos);
569
  wfu_update_text_value({target:inp});
570
  }
571
+
572
+ function wfu_insert_userfield_variable(obj) {
573
+ var attr = obj.className.replace("wfu_variable wfu_variable_", "");
574
+ var inp = document.getElementById("wfu_attribute_" + attr);
575
+ var pos = inp.selectionStart;
576
+ var prevval = inp.value;
577
+ inp.value = prevval.substr(0, pos) + obj.value + prevval.substr(pos);
578
+ obj.value = "%userdataXXX%";
579
+ wfu_update_text_value({target:inp});
580
+ }
581
+
582
+ //wfu_GetHttpRequestObject: function that returns XMLHttpRequest object for various browsers
583
+ function wfu_GetHttpRequestObject() {
584
+ var xhr = null;
585
+ try {
586
+ xhr = new XMLHttpRequest();
587
+ }
588
+ catch(e) {
589
+ try {
590
+ xhr = new ActiveXObject("Msxml2.XMLHTTP");
591
+ }
592
+ catch (e2) {
593
+ try {
594
+ xhr = new ActiveXObject("Microsoft.XMLHTTP");
595
+ }
596
+ catch (e) {}
597
+ }
598
+ }
599
+ if (xhr == null && window.createRequest) {
600
+ try {
601
+ xmlhttp = window.createRequest();
602
+ }
603
+ catch (e) {}
604
+ }
605
+ return xhr;
606
+ }
607
+
608
+ //wfu_plugin_encode_string: function that encodes a decoded string
609
+ function wfu_plugin_encode_string(str) {
610
+ var i = 0;
611
+ var newstr = "";
612
+ var hex = "";
613
+ for (i = 0; i < str.length; i++) {
614
+ hex = str.charCodeAt(i).toString(16);
615
+ if (hex.length == 1) hex = "0" + hex;
616
+ newstr += hex;
617
+ }
618
+ return newstr;
619
+ }
620
+
621
+ function wfu_schedule_save_shortcode() {
622
+ var d = new Date();
623
+ var dt = ShortcodeNextSave - d.getTime();
624
+ if (ShortcodeTimeOut != null) {
625
+ clearTimeout(ShortcodeTimeOut);
626
+ ShortcodeTimeOut = null;
627
+ }
628
+ if (dt <= 0) wfu_save_shortcode();
629
+ else ShortcodeTimeOut = setTimeout(function() {wfu_save_shortcode();}, dt);
630
+ }
631
+
632
+ function wfu_save_shortcode() {
633
+ var xhr = wfu_GetHttpRequestObject();
634
+ if (xhr == null) return;
635
+
636
+ //send request using AJAX
637
+ var url = AdminParams.wfu_ajax_url;
638
+ params = new Array(2);
639
+ params[0] = new Array(2);
640
+ params[0][0] = 'action';
641
+ params[0][1] = 'wfu_ajax_action_save_shortcode';
642
+ params[1] = new Array(2);
643
+ params[1][0] = 'shortcode';
644
+ params[1][1] = wfu_plugin_encode_string(ShortcodeString);
645
+
646
+ var parameters = '';
647
+ for (var i = 0; i < params.length; i++) {
648
+ parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
649
+ }
650
+
651
+ var d = new Date();
652
+ ShortcodeNextSave = d.getTime() + 5000;
653
+
654
+ xhr.open("POST", url, true);
655
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
656
+ xhr.setRequestHeader("Content-length", parameters.length);
657
+ xhr.setRequestHeader("Connection", "close");
658
+ xhr.onreadystatechange = function() {
659
+ if ( xhr.readyState == 4 ) {
660
+ if ( xhr.status == 200 ) {
661
+ if (xhr.responseText == "save_shortcode_success") {
662
+ document.getElementById("wfu_save_label").innerHTML = "saved";
663
+ document.getElementById("wfu_save_label").className = "wfu_save_label";
664
+ document.getElementById("wfu_save_label").style.opacity = 1;
665
+ wfu_fadeout_element(300);
666
+ ShortcodeNextSave = d.getTime() + 1000;
667
+ if (ShortcodeTimeOut != null) wfu_schedule_save_shortcode();
668
+ }
669
+ else {
670
+ document.getElementById("wfu_save_label").innerHTML = "not saved";
671
+ document.getElementById("wfu_save_label").className = "wfu_save_label_fail";
672
+ document.getElementById("wfu_save_label").style.opacity = 1;
673
+ wfu_fadeout_element(300);
674
+ }
675
+ }
676
+ }
677
+ };
678
+ xhr.send(parameters);
679
+ }
680
+
681
+ function wfu_adjust_opacity(opacity) {
682
+ document.getElementById("wfu_save_label").style.opacity = opacity;
683
+ }
684
+
685
+ function wfu_fadeout_element(interval) {
686
+ var reps = 20.0;
687
+ var op = 0.0;
688
+ for (var i = 0; i < reps; i++) {
689
+ op = 1.0 - i / reps;
690
+ setTimeout('wfu_adjust_opacity("' + op.toString() + '")', i * interval / reps);
691
+ }
692
+
693
+ setTimeout('wfu_adjust_opacity("0.0")', i * interval / reps);
694
+ }
js/wordpress_file_upload_functions.js CHANGED
@@ -342,7 +342,7 @@ function wfu_notify_WPFilebase(url) {
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
@@ -390,6 +390,7 @@ function wfu_send_email_notification(sid, unique_id, params_index, session_token
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;
@@ -467,25 +468,25 @@ function wfu_uploadComplete(evt) {
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);
@@ -633,7 +634,7 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
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
@@ -672,11 +673,11 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
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) {
@@ -867,7 +868,7 @@ function wfu_redirect_to_classic(sid, session_token, flag, adminerrorcode) {
867
  // check if there are empty user data fields that are required
868
  if (!wfu_check_required_userdata(sid)) return;
869
 
870
- wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, []);
871
  }
872
 
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
@@ -879,7 +880,7 @@ function wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode,
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,12 +995,11 @@ function wfu_HTML5UploadFile(sid, JSONtext, session_token) {
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
 
1002
- wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, []);
1003
  }
1004
 
1005
  function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
@@ -1037,6 +1037,7 @@ function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
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");
@@ -1107,7 +1108,7 @@ function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
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++) {
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, is_admin) {
346
  var xhr = wfu_GetHttpRequestObject();
347
  if (xhr == null) {
348
  // error sending email
390
  xhr.file_id = 0;
391
  xhr.unique_id = unique_id;
392
  xhr.debugmode = debugmode;
393
+ xhr.is_admin = is_admin;
394
  xhr.params_index = params_index;
395
  xhr.session_token = session_token;
396
  xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
468
  Params[0]['message_type'] = "error";
469
  Params[0]['header'] = this.error_message_header;
470
  Params[0]['message'] = GlobalData.consts.message_timelimit;
471
+ Params[0]['admin_messages'] = this.is_admin == "true" ? GlobalData.consts.message_admin_timelimit : "";
472
  }
473
+ else Params.general.admin_messages.other = this.is_admin == "true" ? GlobalData.consts.message_admin_timelimit : "";
474
  //check if we have a failed upload probably due to exceeded upload time limit
475
  if (Params.general.upload_finish_time > 0) {
476
  var d = new Date();
477
  if (d.getTime() < Params.general.upload_finish_time) {
478
  if (Params.general.files_count > 0) {
479
  Params[0]['message'] = Params.general.fail_message;
480
+ Params[0]['admin_messages'] = this.is_admin == "true" ? Params.general.fail_admin_message : "";
481
  }
482
+ else Params.general.admin_messages.other = this.is_admin == "true" ? Params.general.fail_admin_message : "";
483
  }
484
  }
485
  // note that upload_params is passed as object, so no need to pass a safe_output string
486
+ last = wfu_ProcessUploadComplete(sid, this.file_id, Params, this.unique_id, this.params_index, this.session_token, "", [this.debugmode, debug_data, this.is_admin]);
487
  }
488
  else {
489
+ last = wfu_ProcessUploadComplete(sid, this.file_id, upload_params, this.unique_id, this.params_index, this.session_token, safe_params, [this.debugmode, debug_data, this.is_admin]);
490
  }
491
  if (last) {
492
  wfu_unlock_upload(evt.target.shortcode_id);
634
  }
635
  if (G.notify_only_filename_list != "") {
636
  G.admin_messages.notify = "";
637
+ 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], debug_data[2]);
638
  // in email notification we declare that this is not the last call, because we wait for a last answer from email sending result
639
  G.last = false;
640
  G.notify_only_filename_list = ""; //reset this variable so that repetitive email messages are not sent
673
  else if (G.upload_state == 5 && !admin_message == "" && nonadmin_message == "") G.upload_state --;
674
  }
675
 
676
+ // if (typeof console != "undefined") {
677
+ // console.log(Params);
678
+ // var GG = G;
679
+ // console.log(GG);
680
+ // }
681
 
682
  // section to update message box, executed only if message box is activated
683
  if (message_table) {
868
  // check if there are empty user data fields that are required
869
  if (!wfu_check_required_userdata(sid)) return;
870
 
871
+ wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, [""]);
872
  }
873
 
874
  //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
880
  Params.general.shortcode_id = sid;
881
  Params.general.unique_id = "";
882
  Params.general.files_count = wfu_filesselected(sid);
883
+ wfu_ProcessUploadComplete(sid, 0, Params, "no-ajax", "", session_token, "", ["false", "", "false"]);
884
 
885
  if (flag == 1) {
886
  var suffice = "";
995
  var numfiles = wfu_filesselected(sid);
996
  if (numfiles == 0) return;
997
 
 
998
 
999
  // check if there are empty user data fields that are required
1000
  if (!wfu_check_required_userdata(sid)) return;
1001
 
1002
+ wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, [""]);
1003
  }
1004
 
1005
  function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
1037
  xhr.params_index = JSONobj.params_index;
1038
  xhr.session_token = session_token;
1039
  xhr.debugmode = JSONobj.debugmode;
1040
+ xhr.is_admin = JSONobj.is_admin;
1041
  xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
1042
  xhr.fail_colors = JSONobj.fail_colors;
1043
  xhr.error_message_header = GlobalData.consts.message_header.replace(/%username%/g, "no data");
1108
  var Params = wfu_Initialize_Params();
1109
  Params.general.shortcode_id = sid;
1110
  Params.general.unique_id = rand_str;
1111
+ wfu_ProcessUploadComplete(sid, 0, Params, rand_str, JSONobj.params_index, session_token, "", ["false", "", "false"]);
1112
 
1113
  var inc = 0;
1114
  for (var i = 0; i < farr.length; i++) {
languages/wordpress-file-upload.pot CHANGED
@@ -2,8 +2,8 @@ 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"
@@ -304,7 +304,7 @@ msgid "Insert variable %blogid% inside text. It will be replaced by the blog id
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
2
  msgstr ""
3
  "Project-Id-Version: Wordpress File Upload\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-01-10 00:16+0200\n"
6
+ "PO-Revision-Date: 2014-01-10 00:16+0200\n"
7
  "Last-Translator: nickboss <info@iptanus.com>\n"
8
  "Language-Team: Iptanus Team <info@iptanus.com>\n"
9
  "Language: \n"
304
  msgstr ""
305
 
306
  #: lib/wfu_constants.php:123
307
+ msgid "Insert variable %userdataXXX% inside text. Select the user field from the drop-down list. It will be replaced by the value that the user entered in this field."
308
  msgstr ""
309
 
310
  #: lib/wfu_constants.php:124
lib/wfu_admin.php CHANGED
@@ -65,13 +65,20 @@ function wfu_shortcode_composer() {
65
  global $wpdb;
66
  global $wp_roles;
67
 
68
- // $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
69
  $components = wfu_component_definitions();
70
 
71
  $cats = wfu_category_definitions();
72
  $defs = wfu_attribute_definitions();
73
- foreach ( $defs as $key => $def ) $defs[$key]['default'] = $def['value'];
74
-
 
 
 
 
 
 
 
 
75
  // index $components
76
  $components_indexed = array();
77
  foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
@@ -84,6 +91,7 @@ function wfu_shortcode_composer() {
84
  $echo_str .= "\n\t".'<div style="margin-top:10px;">';
85
  $echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
86
  $echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
 
87
  $echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">[wordpress_file_upload]</textarea>';
88
  $echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
89
  foreach ( $defs as $def )
@@ -193,8 +201,7 @@ function wfu_shortcode_composer() {
193
  }
194
  elseif ( $def['type'] == "text" ) {
195
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
196
- if ( $def['variables'] != null ) foreach ( $def['variables'] as $variable )
197
- $echo_str .= $dlp."\t\t".'<span class="wfu_variable wfu_variable_'.$attr.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
198
  }
199
  elseif ( $def['type'] == "placements" ) {
200
  $components_used = array();
@@ -235,8 +242,7 @@ function wfu_shortcode_composer() {
235
  }
236
  elseif ( $def['type'] == "ltext" ) {
237
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$def['value'].'" />';
238
- if ( $def['variables'] != null ) foreach ( $def['variables'] as $variable )
239
- $echo_str .= $dlp."\t\t".'<span class="wfu_variable wfu_variable_'.$attr.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
240
  }
241
  elseif ( $def['type'] == "integer" ) {
242
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" min="1" value="'.$def['value'].'" />';
@@ -258,18 +264,15 @@ function wfu_shortcode_composer() {
258
  else $plural = $parts[1];
259
  $echo_str .= $dlp."\t\t".'<span class="wfu_ptext_span">Singular</span><input id="wfu_attribute_s_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$singular.'" />';
260
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
261
- if ( $def['variables'] != null ) foreach ( $def['variables'] as $variable )
262
- $echo_str .= $dlp."\t\t".'<span class="wfu_variable wfu_variable_s_'.$attr.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
263
  $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">Plural</span><input id="wfu_attribute_p_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$plural.'" />';
264
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
265
- if ( $def['variables'] != null ) foreach ( $def['variables'] as $variable )
266
- $echo_str .= $dlp."\t\t".'<span class="wfu_variable wfu_variable_p_'.$attr.'" title'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
267
  }
268
  elseif ( $def['type'] == "mtext" ) {
269
  $val = str_replace("%n%", "\n", $def['value']);
270
  $echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
271
- if ( $def['variables'] != null ) foreach ( $def['variables'] as $variable )
272
- if ( $variable != "%n%" ) $echo_str .= $dlp."\t\t".'<span class="wfu_variable wfu_variable_'.$attr.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
273
  }
274
  elseif ( $def['type'] == "rolelist" ) {
275
  $roles = $wp_roles->get_names();
@@ -335,8 +338,7 @@ function wfu_shortcode_composer() {
335
  }
336
  else {
337
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
338
- if ( $def['variables'] != null ) foreach ( $def['variables'] as $variable )
339
- $echo_str .= $dlp."\t\t".'<span class="wfu_variable wfu_variable_'.$attr.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
340
  }
341
  $echo_str .= $dlp."\t".'</div></td>';
342
  if ( $def['parent'] == "" ) {
@@ -367,6 +369,14 @@ function wfu_shortcode_composer() {
367
  echo $echo_str;
368
  }
369
 
 
 
 
 
 
 
 
 
370
  function wfu_update_settings() {
371
  }
372
 
65
  global $wpdb;
66
  global $wp_roles;
67
 
 
68
  $components = wfu_component_definitions();
69
 
70
  $cats = wfu_category_definitions();
71
  $defs = wfu_attribute_definitions();
72
+
73
+ $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
74
+ $shortcode_attrs = wfu_shortcode_string_to_array($plugin_options['shortcode']);
75
+ foreach ( $defs as $key => $def ) {
76
+ $defs[$key]['default'] = $def['value'];
77
+ if ( array_key_exists($def['attribute'], $shortcode_attrs) ) {
78
+ $defs[$key]['value'] = $shortcode_attrs[$def['attribute']];
79
+ }
80
+ }
81
+
82
  // index $components
83
  $components_indexed = array();
84
  foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
91
  $echo_str .= "\n\t".'<div style="margin-top:10px;">';
92
  $echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
93
  $echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
94
+ $echo_str .= "\n\t\t\t".'<span id="wfu_save_label" class="wfu_save_label">saved</span>';
95
  $echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">[wordpress_file_upload]</textarea>';
96
  $echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
97
  foreach ( $defs as $def )
201
  }
202
  elseif ( $def['type'] == "text" ) {
203
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
204
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
 
205
  }
206
  elseif ( $def['type'] == "placements" ) {
207
  $components_used = array();
242
  }
243
  elseif ( $def['type'] == "ltext" ) {
244
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$def['value'].'" />';
245
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
 
246
  }
247
  elseif ( $def['type'] == "integer" ) {
248
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" min="1" value="'.$def['value'].'" />';
264
  else $plural = $parts[1];
265
  $echo_str .= $dlp."\t\t".'<span class="wfu_ptext_span">Singular</span><input id="wfu_attribute_s_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$singular.'" />';
266
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
267
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
 
268
  $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">Plural</span><input id="wfu_attribute_p_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$plural.'" />';
269
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
270
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr);
 
271
  }
272
  elseif ( $def['type'] == "mtext" ) {
273
  $val = str_replace("%n%", "\n", $def['value']);
274
  $echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
275
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
 
276
  }
277
  elseif ( $def['type'] == "rolelist" ) {
278
  $roles = $wp_roles->get_names();
338
  }
339
  else {
340
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
341
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
 
342
  }
343
  $echo_str .= $dlp."\t".'</div></td>';
344
  if ( $def['parent'] == "" ) {
369
  echo $echo_str;
370
  }
371
 
372
+ function wfu_insert_variables($variables, $class) {
373
+ $ret = "";
374
+ foreach ( $variables as $variable )
375
+ if ( $variable == "%userdataXXX%" ) $ret .= $dlp."\t\t".'<select class="'.$class.'" name="wfu_userfield_select" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" onchange="wfu_insert_userfield_variable(this);"><option style="display:none;">%userdataXXX%</option></select>';
376
+ elseif ( $variable != "%n%" ) $ret .= $dlp."\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
377
+ return $ret;
378
+ }
379
+
380
  function wfu_update_settings() {
381
  }
382
 
lib/wfu_ajaxactions.php CHANGED
@@ -65,8 +65,23 @@ function wfu_ajax_action_callback() {
65
  $user = wp_get_current_user();
66
  $arr = wfu_get_params_fields_from_index($_POST['params_index']);
67
  //check referer using server sessions to avoid CSRF attacks
68
- if ( $_SESSION["wfu_token_".$arr['shortcode_id']] != $_POST['session_token'] ) die();
69
- if ( $user->user_login != $arr['user_login'] ) die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  $params_str = get_option('wfu_params_'.$arr['unique_id']);
72
  $params = wfu_decode_array_from_string($params_str);
@@ -81,4 +96,15 @@ function wfu_ajax_action_callback() {
81
  die("wfu_fileupload_success:".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array));
82
  }
83
 
 
 
 
 
 
 
 
 
 
 
 
84
  ?>
65
  $user = wp_get_current_user();
66
  $arr = wfu_get_params_fields_from_index($_POST['params_index']);
67
  //check referer using server sessions to avoid CSRF attacks
68
+ if ( $_SESSION["wfu_token_".$arr['shortcode_id']] != $_POST['session_token'] ) {
69
+ echo "Session failed!<br/><br/>Session Data:<br/>";
70
+ print_r($_SESSION);
71
+ echo "<br/><br/>Post Data:<br/>";
72
+ print_r($_POST);
73
+ die();
74
+ }
75
+
76
+ if ( $user->user_login != $arr['user_login'] ) {
77
+ echo "User failed!<br/><br/>User Data:<br/>";
78
+ print_r($user);
79
+ echo "<br/><br/>Post Data:<br/>";
80
+ print_r($_POST);
81
+ echo "<br/><br/>Params Data:<br/>";
82
+ print_r($arr);
83
+ die();
84
+ }
85
 
86
  $params_str = get_option('wfu_params_'.$arr['unique_id']);
87
  $params = wfu_decode_array_from_string($params_str);
96
  die("wfu_fileupload_success:".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array));
97
  }
98
 
99
+ function wfu_ajax_action_save_shortcode() {
100
+ if ( !isset($_POST['shortcode']) ) die();
101
+
102
+ $plugin_options['version'] = '1.0';
103
+ $plugin_options['shortcode'] = wfu_plugin_decode_string($_POST['shortcode']);
104
+ $encoded_options = wfu_encode_plugin_options($plugin_options);
105
+ update_option( "wordpress_file_upload_options", $encoded_options );
106
+
107
+ die("save_shortcode_success");
108
+ }
109
+
110
  ?>
lib/wfu_constants.php CHANGED
@@ -120,7 +120,7 @@ DEFINE("WFU_VARIABLE_TITLE_USEREMAIL", __("Insert variable %useremail% inside te
120
  DEFINE("WFU_VARIABLE_TITLE_FILENAME", __("Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file.", "wordpress-file-upload"));
121
  DEFINE("WFU_VARIABLE_TITLE_FILEPATH", __("Insert variable %filepath% inside text. It will be replaced by the full filepath of the uploaded file.", "wordpress-file-upload"));
122
  DEFINE("WFU_VARIABLE_TITLE_BLOGID", __("Insert variable %blogid% inside text. It will be replaced by the blog id of the website.", "wordpress-file-upload"));
123
- DEFINE("WFU_VARIABLE_TITLE_USERDATAXXX", __("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.", "wordpress-file-upload"));
124
  DEFINE("WFU_VARIABLE_TITLE_N", __("Insert variable %n% inside text to denote a line change.", "wordpress-file-upload"));
125
 
126
  //define plugin other constants
120
  DEFINE("WFU_VARIABLE_TITLE_FILENAME", __("Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file.", "wordpress-file-upload"));
121
  DEFINE("WFU_VARIABLE_TITLE_FILEPATH", __("Insert variable %filepath% inside text. It will be replaced by the full filepath of the uploaded file.", "wordpress-file-upload"));
122
  DEFINE("WFU_VARIABLE_TITLE_BLOGID", __("Insert variable %blogid% inside text. It will be replaced by the blog id of the website.", "wordpress-file-upload"));
123
+ DEFINE("WFU_VARIABLE_TITLE_USERDATAXXX", __("Insert variable %userdataXXX% inside text. Select the user field from the drop-down list. It will be replaced by the value that the user entered in this field.", "wordpress-file-upload"));
124
  DEFINE("WFU_VARIABLE_TITLE_N", __("Insert variable %n% inside text to denote a line change.", "wordpress-file-upload"));
125
 
126
  //define plugin other constants
lib/wfu_functions.php CHANGED
@@ -97,6 +97,47 @@ function wfu_array_remove_nulls(&$arr) {
97
  array_splice($arr, $key, 1);
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  //********************* Directory Functions ************************************************************************************************
101
 
102
  function wfu_upload_plugin_full_path( $params ) {
97
  array_splice($arr, $key, 1);
98
  }
99
 
100
+ function wfu_shortcode_string_to_array($shortcode) {
101
+ $arr = explode(" ", $shortcode);
102
+ $attrs = array();
103
+ foreach ( $arr as $attr ) {
104
+ if ( trim($attr) != "" ) {
105
+ $attr_arr = explode("=", $attr, 2);
106
+ $key = "";
107
+ if ( count($attr_arr) > 0 ) $key = $attr_arr[0];
108
+ $val = "";
109
+ if ( count($attr_arr) > 1 ) $val = $attr_arr[1];
110
+ if ( trim($key) != "" ) $attrs[trim($key)] = str_replace('"', '', $val);
111
+ }
112
+ }
113
+ $i=0;
114
+ $m=array();
115
+ $mm = preg_replace_callback('/"([^"]*)"/', function ($matches) use(&$i, &$m) {array_push($m, $matches[1]); return "attr".$i++;}, $shortcode);
116
+ return $attrs;
117
+ }
118
+
119
+ //********************* Plugin Options Functions ************************************************************************************************
120
+
121
+ function wfu_encode_plugin_options($plugin_options) {
122
+ $encoded_options = 'version='.$plugin_options['version'].';';
123
+ $encoded_options .= 'shortcode='.wfu_plugin_encode_string($plugin_options['shortcode']);
124
+ return $encoded_options;
125
+ }
126
+
127
+ function wfu_decode_plugin_options($encoded_options) {
128
+ $decoded_array = explode(';', $encoded_options);
129
+ $plugin_options = array();
130
+ foreach ($decoded_array as $decoded_item) {
131
+ list($item_key, $item_value) = explode("=", $decoded_item, 2);
132
+ if ( $item_key == 'shortcode' )
133
+ $plugin_options[$item_key] = wfu_plugin_decode_string($item_value);
134
+ else
135
+ $plugin_options[$item_key] = $item_value;
136
+
137
+ }
138
+ return $plugin_options;
139
+ }
140
+
141
  //********************* Directory Functions ************************************************************************************************
142
 
143
  function wfu_upload_plugin_full_path( $params ) {
lib/wfu_processfiles.php CHANGED
@@ -367,7 +367,7 @@ function wfu_process_files($params, $method) {
367
  Execution will happen only if accumulated $params_output_array["general"]['update_wpfilebase'] is not empty */
368
  if ( $params["filebaselink"] == "true" ) {
369
  if ( $somefiles_Ok ) {
370
- $filebaseurl = WP_SITEURL;
371
  if ( substr($filebaseurl, -1, 1) == "/" ) $filebaseurl = substr($filebaseurl, 0, strlen($filebaseurl) - 1);
372
  /* if the following variable is not empty, then WPFileBase Plugin update must be executed
373
  and any admin messages must be suppressed */
367
  Execution will happen only if accumulated $params_output_array["general"]['update_wpfilebase'] is not empty */
368
  if ( $params["filebaselink"] == "true" ) {
369
  if ( $somefiles_Ok ) {
370
+ $filebaseurl = site_url();
371
  if ( substr($filebaseurl, -1, 1) == "/" ) $filebaseurl = substr($filebaseurl, 0, strlen($filebaseurl) - 1);
372
  /* if the following variable is not empty, then WPFileBase Plugin update must be executed
373
  and any admin messages must be suppressed */
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: nickboss
3
  Donate link: http://www.iptanus.com/support/wordpress-file-upload
4
  Tags: upload, upload file, upload files, multiple, multiple upload, multiple uploads, captcha, progress bar, form, ajax, directory, HTML5, filelist
5
  Requires at least: 2.9.2
6
- Tested up to: 3.7.1
7
  Stable tag: "trunk"
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -96,6 +96,15 @@ The plugin is designed not to expose website information by using sessions. Para
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.
@@ -236,6 +245,9 @@ Initial version.
236
 
237
  == Upgrade Notice ==
238
 
 
 
 
239
  = 2.1.2 =
240
  Important upgrade to address some bugs.
241
 
@@ -481,6 +493,8 @@ For the time being, the following variables are supported:
481
  * **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*.
482
  * **%userdataXXX%:** Is replaced by the additional message that the user has sent together with the file upload. XXX is the number of the field (starting from 0). The shortcode attribute userdata must have been set to "true". Can be used inside attributes *notifysubject*, *notifymessage*.
483
  * **%n%:** Denotes change of line (equivalent of \n). Can be used inside attributes *notifymessage* and *notifyheaders*. It exists because of problems of using \n inside the classic page editor of Wordpress.
 
 
484
 
485
  == Requirements ==
486
 
3
  Donate link: http://www.iptanus.com/support/wordpress-file-upload
4
  Tags: upload, upload file, upload files, multiple, multiple upload, multiple uploads, captcha, progress bar, form, ajax, directory, HTML5, filelist
5
  Requires at least: 2.9.2
6
+ Tested up to: 3.8
7
  Stable tag: "trunk"
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
96
 
97
  == Changelog ==
98
 
99
+ = 2.1.3 =
100
+ * variables %pagetitle% and %pageid% added in uploadpath.
101
+ * bug fixes when working with IE8.
102
+ * Shortcode Composer saves selected options
103
+ * Easier handling of userdata variables in Shortcode Composer
104
+ * correction of bug that allowed debugdata to be shown in non-admin users
105
+ * reset.css removed from plugin as it was causing breaks in theme's css
106
+ * correction of bug with WPFilebase Manager plugin
107
+
108
  = 2.1.2 =
109
  * Several bug fixes and code reconstruction.
110
  * Code modifications so that the plugin can operate even when DEBUG mode is ON.
245
 
246
  == Upgrade Notice ==
247
 
248
+ = 2.1.3 =
249
+ Important upgrade to address some serious bugs.
250
+
251
  = 2.1.2 =
252
  Important upgrade to address some bugs.
253
 
493
  * **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*.
494
  * **%userdataXXX%:** Is replaced by the additional message that the user has sent together with the file upload. XXX is the number of the field (starting from 0). The shortcode attribute userdata must have been set to "true". Can be used inside attributes *notifysubject*, *notifymessage*.
495
  * **%n%:** Denotes change of line (equivalent of \n). Can be used inside attributes *notifymessage* and *notifyheaders*. It exists because of problems of using \n inside the classic page editor of Wordpress.
496
+ * **%pagetitle%:** Is replaced by the title of the current page. Can be used inside attribute *uploadpath*.
497
+ * **%pageid%:** Is replaced by the id of the current page. Can be used inside attribute *uploadpath*.
498
 
499
  == Requirements ==
500
 
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.1.2
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
@@ -41,11 +41,12 @@ if ( is_admin() ) {
41
  wp_enqueue_style('wordpress-file-upload-admin-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_adminstyle.css',false,'1.0','all');
42
  wp_enqueue_style( 'wp-color-picker' );
43
  wp_enqueue_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_adminfunctions.js', array( 'wp-color-picker' ), false, true);
44
- wp_enqueue_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/getElementsByClassName-1.0.1.js');
 
45
  }
46
  }
47
  else {
48
- wp_enqueue_style('wordpress-file-upload-reset', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_reset.css',false,'1.0','all');
49
  wp_enqueue_style('wordpress-file-upload-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style.css',false,'1.0','all');
50
  wp_enqueue_style('wordpress-file-upload-style-safe', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style_safe.css',false,'1.0','all');
51
  wp_enqueue_script('json_class', WPFILEUPLOAD_DIR.'js/json2.js');
@@ -56,6 +57,7 @@ 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
  wfu_include_lib();
60
  //foreach ( glob( plugin_dir_path( __FILE__ )."lib/*.php" ) as $file )
61
  // include_once $file;
@@ -110,14 +112,18 @@ function wordpress_file_upload_function($incomingfromhandler) {
110
  $plugin_upload_user_role = wfu_get_user_role($user, $uploadroles);
111
  if ( !in_array($plugin_upload_user_role, $uploadroles) && $plugin_upload_user_role != 'administrator' && $params["uploadrole"] != 'all' ) return;
112
 
 
 
 
113
  $params["adminmessages"] = ( $params["adminmessages"] == "true" && $plugin_upload_user_role == 'administrator' );
114
  // define variable to hold any additional admin errors coming before processing of files (e.g. due to redirection)
115
  $params["adminerrors"] = "";
116
 
117
  /* Define dynamic upload path from variables */
118
- $search = array ('/%username%/', '/%blogid%/');
119
- if ( is_user_logged_in() ) $replace = array ($user->user_login, $blog_id);
120
- else $replace = array ("guests", $blog_id);
 
121
  $params["uploadpath"] = preg_replace($search, $replace, $params["uploadpath"]);
122
 
123
  /* Determine if userdata fields have been defined */
@@ -171,6 +177,7 @@ function wordpress_file_upload_function($incomingfromhandler) {
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);
@@ -270,7 +277,7 @@ function wordpress_file_upload_function($incomingfromhandler) {
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
 
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.3
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
41
  wp_enqueue_style('wordpress-file-upload-admin-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_adminstyle.css',false,'1.0','all');
42
  wp_enqueue_style( 'wp-color-picker' );
43
  wp_enqueue_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_adminfunctions.js', array( 'wp-color-picker' ), false, true);
44
+ wp_enqueue_script('wordpress_file_upload_classname_script', WPFILEUPLOAD_DIR.'js/getElementsByClassName-1.0.1.js');
45
+ wp_localize_script( 'wordpress_file_upload_admin_script', 'AdminParams', array("wfu_ajax_url" => site_url()."/wp-admin/admin-ajax.php") );
46
  }
47
  }
48
  else {
49
+ // wp_enqueue_style('wordpress-file-upload-reset', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_reset.css',false,'1.0','all');
50
  wp_enqueue_style('wordpress-file-upload-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style.css',false,'1.0','all');
51
  wp_enqueue_style('wordpress-file-upload-style-safe', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style_safe.css',false,'1.0','all');
52
  wp_enqueue_script('json_class', WPFILEUPLOAD_DIR.'js/json2.js');
57
  add_action('wp_ajax_nopriv_wfu_ajax_action', 'wfu_ajax_action_callback');
58
  add_action('wp_ajax_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
59
  add_action('wp_ajax_nopriv_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
60
+ add_action('wp_ajax_wfu_ajax_action_save_shortcode', 'wfu_ajax_action_save_shortcode');
61
  wfu_include_lib();
62
  //foreach ( glob( plugin_dir_path( __FILE__ )."lib/*.php" ) as $file )
63
  // include_once $file;
112
  $plugin_upload_user_role = wfu_get_user_role($user, $uploadroles);
113
  if ( !in_array($plugin_upload_user_role, $uploadroles) && $plugin_upload_user_role != 'administrator' && $params["uploadrole"] != 'all' ) return;
114
 
115
+ //activate debug mode only for admins
116
+ if ( $plugin_upload_user_role != 'administrator' ) $params["debugmode"] = "false";
117
+
118
  $params["adminmessages"] = ( $params["adminmessages"] == "true" && $plugin_upload_user_role == 'administrator' );
119
  // define variable to hold any additional admin errors coming before processing of files (e.g. due to redirection)
120
  $params["adminerrors"] = "";
121
 
122
  /* Define dynamic upload path from variables */
123
+ $search = array ('/%username%/', '/%blogid%/', '/%pageid%/', '/%pagetitle%/');
124
+ if ( is_user_logged_in() ) $username = $user->user_login;
125
+ else $username = "guests";
126
+ $replace = array ($username, $blog_id, $post->ID, get_the_title($post->ID));
127
  $params["uploadpath"] = preg_replace($search, $replace, $params["uploadpath"]);
128
 
129
  /* Determine if userdata fields have been defined */
177
  $ajax_params['shortcode_id'] = $sid;
178
  $ajax_params['params_index'] = $params_index;
179
  $ajax_params['debugmode'] = $params["debugmode"];
180
+ $ajax_params['is_admin'] = ( $plugin_upload_user_role == 'administrator' ? "true" : "false" );
181
  $ajax_params["fail_colors"] = $params["failmessagecolors"];
182
 
183
  $ajax_params_str = wfu_encode_array_to_string($ajax_params);
277
  unset($wfu_process_file_array["general"]['safe_output']);
278
 
279
  $wfu_process_file_array_str = wfu_encode_array_to_string($wfu_process_file_array);
280
+ $ProcessUploadComplete_functiondef = 'function(){wfu_ProcessUploadComplete('.$sid.', 1, "'.$wfu_process_file_array_str.'", "no-ajax", "", "", "'.$safe_output.'", ["false", "", "false"]);}';
281
  $wordpress_file_upload_output .= '<script type="text/javascript">window.onload='.$ProcessUploadComplete_functiondef.'</script>';
282
 
283