Version Description
- Bug - Fixed Contact Form 7 error notice
- PHP Deprecated: id property of a WPCF7_ContactForm object is no longer accessible.
- Reported here - https://wordpress.org/support/topic/bug-notice-id-not-accessible
Download this release
Release Info
Developer | glenwpcoder |
Plugin | Drag and Drop Multiple File Upload – Contact Form 7 |
Version | 1.3.5.5.1 |
Comparing to | |
See all releases |
Code changes from version 1.3.5.4 to 1.3.5.5.1
- assets/js/codedropz-uploader-min.js +3 -3
- drag-n-drop-upload-cf7.php +2 -2
- inc/dnd-upload-cf7.php +53 -3
- readme.txt +14 -2
assets/js/codedropz-uploader-min.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
/**
|
2 |
-
* CodeDropz Uploader v1.3.5.
|
3 |
* Copyright 2018 Glen Mongaya
|
4 |
* CodeDrop Drag&Drop Uploader
|
5 |
-
* @version 1.3.5.
|
6 |
* @author CodeDropz, Glen Don L. Mongaya
|
7 |
* @license The MIT License (MIT)
|
8 |
*/
|
9 |
|
10 |
// CodeDropz Drag and Drop Plugin
|
11 |
-
!function(e){e.fn.CodeDropz_Uploader=function(a){this.each(function(){var d=e(this),r=e.extend({handler:d,color:"#000",background:"",server_max_error:"Uploaded file exceeds the maximum upload size of your server.",max_file:d.data("max")?d.data("max"):10,max_upload_size:d.data("limit")?d.data("limit"):"10485760",supported_type:d.data("type")?d.data("type"):"jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls",text:"Drag & Drop Files Here",separator:"or",button_text:"Browse Files",on_success:""},a),o=d.data("name")+"_count_files";localStorage.setItem(o,1);var s='<div class="codedropz-upload-handler"><div class="codedropz-upload-container"><div class="codedropz-upload-inner"><h3>'+r.text+"</h3><span>"+r.separator+'</span><div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+r.button_text+'</a></div></div></div><span class="dnd-upload-counter"><span>0</span> '+dnd_cf7_uploader.dnd_text_counter+" "+parseInt(r.max_file)+"</span></div>";r.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>'),r.supported_type=r.supported_type.replace(/[^a-zA-Z0-9| ]/g,"");var t=r.handler.parents("form"),n=r.handler.parents(".codedropz-upload-wrapper"),p=e('input[type="submit"]',t);r.handler.after(s),e(".codedropz-upload-handler",n).on("drag dragstart dragend dragover dragenter dragleave drop",function(e){e.preventDefault(),e.stopPropagation()}),e(".codedropz-upload-handler",n).on("dragover dragenter",function(a){e(this).addClass("codedropz-dragover")}),e(".codedropz-upload-handler",n).on("dragleave dragend drop",function(a){e(this).removeClass("codedropz-dragover")}),e("a.cd-upload-btn",n).on("click",function(e){e.preventDefault(),r.handler.val(null),r.handler.click()}),e(".codedropz-upload-handler",n).on("drop",function(e){l(e.originalEvent.dataTransfer.files,"drop")}),r.handler.on("change",function(e){l(this.files,"click")});var l=function(a,s){if(!(!a.length>1)){var p=new FormData;p.append("
|
1 |
/**
|
2 |
+
* CodeDropz Uploader v1.3.5.5
|
3 |
* Copyright 2018 Glen Mongaya
|
4 |
* CodeDrop Drag&Drop Uploader
|
5 |
+
* @version 1.3.5.5
|
6 |
* @author CodeDropz, Glen Don L. Mongaya
|
7 |
* @license The MIT License (MIT)
|
8 |
*/
|
9 |
|
10 |
// CodeDropz Drag and Drop Plugin
|
11 |
+
!function(e){e.fn.CodeDropz_Uploader=function(a){this.each(function(){var d=e(this),r=e.extend({handler:d,color:"#000",background:"",server_max_error:"Uploaded file exceeds the maximum upload size of your server.",max_file:d.data("max")?d.data("max"):10,max_upload_size:d.data("limit")?d.data("limit"):"10485760",supported_type:d.data("type")?d.data("type"):"jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls",text:"Drag & Drop Files Here",separator:"or",button_text:"Browse Files",on_success:""},a),o=d.data("name")+"_count_files";localStorage.setItem(o,1);var s='<div class="codedropz-upload-handler"><div class="codedropz-upload-container"><div class="codedropz-upload-inner"><h3>'+r.text+"</h3><span>"+r.separator+'</span><div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+r.button_text+'</a></div></div></div><span class="dnd-upload-counter"><span>0</span> '+dnd_cf7_uploader.dnd_text_counter+" "+parseInt(r.max_file)+"</span></div>";r.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>'),r.supported_type=r.supported_type.replace(/[^a-zA-Z0-9| ]/g,"");var t=r.handler.parents("form"),n=r.handler.parents(".codedropz-upload-wrapper"),p=e('input[type="submit"]',t);r.handler.after(s),e(".codedropz-upload-handler",n).on("drag dragstart dragend dragover dragenter dragleave drop",function(e){e.preventDefault(),e.stopPropagation()}),e(".codedropz-upload-handler",n).on("dragover dragenter",function(a){e(this).addClass("codedropz-dragover")}),e(".codedropz-upload-handler",n).on("dragleave dragend drop",function(a){e(this).removeClass("codedropz-dragover")}),e("a.cd-upload-btn",n).on("click",function(e){e.preventDefault(),r.handler.val(null),r.handler.click()}),e(".codedropz-upload-handler",n).on("drop",function(e){l(e.originalEvent.dataTransfer.files,"drop")}),r.handler.on("change",function(e){l(this.files,"click")});var l=function(a,s){if(!(!a.length>1)){var p=new FormData;p.append("size_limit",r.max_upload_size),p.append("action","dnd_codedropz_upload"),p.append("type",s),p.append("security",dnd_cf7_uploader.ajax_nonce),p.append("form_id",d.data("id")),p.append("upload_name",d.data("name")),e("span.has-error",r.handler).remove(),e.each(a,function(a,s){if(void 0!==p.delete&&p.delete("upload-file"),localStorage.getItem(o)>r.max_file)return!e("span.has-error-msg",n).length>0&&(err_msg=dnd_cf7_uploader.drag_n_drop_upload.max_file_limit,n.append('<span class="has-error-msg">'+err_msg.replace("%count%",r.max_file)+"</span>")),!1;var l=i.createProgressBar(s),c=!1;if(s.size>r.max_upload_size&&(e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+dnd_cf7_uploader.drag_n_drop_upload.large_file+"</span>"),c=!0),regex_type=new RegExp("(.*?).("+r.supported_type+")$"),!1!==c||regex_type.test(s.name.toLowerCase())||(e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+dnd_cf7_uploader.drag_n_drop_upload.inavalid_type+"</span>"),c=!0),localStorage.setItem(o,Number(localStorage.getItem(o))+1),!1===c){p.append("upload-file",s);e.ajax({url:r.ajax_url,type:t.attr("method"),data:p,dataType:"json",cache:!1,contentType:!1,processData:!1,xhr:function(){var e=new window.XMLHttpRequest;return e.upload.addEventListener("progress",function(e){if(e.lengthComputable){var a=e.loaded/e.total,d=parseInt(100*a);i.setProgressBar(l,d)}},!1),e},complete:function(){i.setProgressBar(l,100)},success:function(a){a.success?e.isFunction(r.on_success)&&r.on_success.call(this,d,l,a):(e(".dnd-progress-bar",e("#"+l)).remove(),e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+a.data+"</span>"),e('input[type="submit"]',t).removeClass("disabled").prop("disabled",!1))},error:function(a,d,o){e(".dnd-progress-bar",e("#"+l)).remove(),e(".dnd-upload-details",e("#"+l)).append('<span class="has-error">'+r.server_max_error+"</span>"),e('input[type="submit"]',t).removeClass("disabled").prop("disabled",!1)}})}})}},i={createProgressBar:function(a){var d=e(".codedropz-upload-handler",n),r="dnd-file-"+Math.random().toString(36).substr(2,9),s='<div class="dnd-upload-image"><span class="dnd-icon-blank-file"></span></div><div class="dnd-upload-details"><span class="name"><span>'+a.name+"</span><em>("+i.bytesToSize(a.size)+')</em></span><a href="javascript:void(0)" title="'+dnd_cf7_uploader.drag_n_drop_upload.delete.title+'" class="remove-file" data-storage="'+o+'"><span class="dnd-icon-remove"></span></a><span class="dnd-progress-bar"><span></span></span></div>';return d.after('<div id="'+r+'" class="dnd-upload-status">'+s+"</div>"),r},setProgressBar:function(a,d){var r=e(".dnd-progress-bar",e("#"+a));return r.length>0&&(i.disableBtn(p),progress_width=d*r.width()/100,e("span",r).addClass("in-progress").animate({width:progress_width},10).text(d+"% "),100==d&&e("span",r).addClass("complete").removeClass("in-progress")),!1},bytesToSize:function(e){return 0===e?"0":(kBytes=e/1024,fileSize=kBytes>=1024?(kBytes/1024).toFixed(2)+"MB":kBytes.toFixed(2)+"KB",fileSize)},disableBtn:function(e){e.length>0&&e.addClass("disable").prop("disabled",!0)}}}),e(document).on("click",".dnd-icon-remove",function(d){var r=e(this),o=r.parents(".dnd-upload-status"),s=r.parents(".codedropz-upload-wrapper"),t=r.parent("a").attr("data-storage"),n=Number(localStorage.getItem(t));if(e("span.in-progress",o).length>0)return!1;if(e(".has-error",o).length>0)return o.remove(),localStorage.setItem(t,n-1),!1;r.addClass("deleting").text(dnd_cf7_uploader.drag_n_drop_upload.delete.text+"...");var p={path:o.find('input[type="hidden"]').val(),action:"dnd_codedropz_upload_delete",security:dnd_cf7_uploader.ajax_nonce};e.post(a.ajax_url,p,function(a){a.success&&(o.remove(),localStorage.setItem(t,n-1),e(".dnd-upload-status",s).length<=1&&e("span.has-error-msg",s).remove(),e(".dnd-upload-counter span",s).text(Number(localStorage.getItem(t))-1))}),e("span.has-error-msg").remove()})}}(jQuery);
|
drag-n-drop-upload-cf7.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Description: This simple plugin create Drag & Drop or choose Multiple File upload in your Confact Form 7 Forms.
|
7 |
* Text Domain: dnd-upload-cf7
|
8 |
* Domain Path: /languages
|
9 |
-
* Version: 1.3.5.
|
10 |
* Author: Glen Don L. Mongaya
|
11 |
* Author URI: http://codedropz.com
|
12 |
* License: GPL2
|
@@ -21,7 +21,7 @@
|
|
21 |
define( 'dnd_upload_cf7', true );
|
22 |
|
23 |
/** Define plugin Version */
|
24 |
-
define( 'dnd_upload_cf7_version', '1.3.5.
|
25 |
|
26 |
/** Define constant Plugin Directories */
|
27 |
define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
|
6 |
* Description: This simple plugin create Drag & Drop or choose Multiple File upload in your Confact Form 7 Forms.
|
7 |
* Text Domain: dnd-upload-cf7
|
8 |
* Domain Path: /languages
|
9 |
+
* Version: 1.3.5.5.1
|
10 |
* Author: Glen Don L. Mongaya
|
11 |
* Author URI: http://codedropz.com
|
12 |
* License: GPL2
|
21 |
define( 'dnd_upload_cf7', true );
|
22 |
|
23 |
/** Define plugin Version */
|
24 |
+
define( 'dnd_upload_cf7_version', '1.3.5.5.1' );
|
25 |
|
26 |
/** Define constant Plugin Directories */
|
27 |
define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
|
inc/dnd-upload-cf7.php
CHANGED
@@ -455,6 +455,9 @@
|
|
455 |
$class .= ' wpcf7-not-valid';
|
456 |
}
|
457 |
|
|
|
|
|
|
|
458 |
// Setup element attributes
|
459 |
$atts = array();
|
460 |
|
@@ -478,6 +481,7 @@
|
|
478 |
$atts['data-type'] = $tag->get_option( 'filetypes','', true);
|
479 |
$atts['data-limit'] = $tag->get_option( 'limit','', true);
|
480 |
$atts['data-max'] = $tag->get_option( 'max-file','', true);
|
|
|
481 |
|
482 |
// Combine and format attrbiutes
|
483 |
$atts = wpcf7_format_atts( $atts );
|
@@ -618,9 +622,48 @@
|
|
618 |
<?php
|
619 |
}
|
620 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
// Begin process upload
|
622 |
function dnd_upload_cf7_upload() {
|
623 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
624 |
// check and verify ajax request
|
625 |
if( is_user_logged_in() ) {
|
626 |
check_ajax_referer( 'dnd-cf7-security-nonce', 'security' );
|
@@ -641,8 +684,10 @@
|
|
641 |
wp_send_json_error( '('. $file['error'] .') ' . ( $failed_error ? $failed_error : dnd_cf7_error_msg('failed_upload') ) );
|
642 |
}
|
643 |
|
644 |
-
/*
|
645 |
-
$supported_type =
|
|
|
|
|
646 |
$file_type_pattern = dnd_upload_cf7_filetypes( $supported_type );
|
647 |
|
648 |
// Get file extension
|
@@ -787,7 +832,7 @@
|
|
787 |
$extension = preg_replace( '/[^A-Za-z0-9,|]/', '', $extension );
|
788 |
|
789 |
// not allowed file types
|
790 |
-
$not_allowed = array( 'php', 'php3','php4','phtml','exe','script', 'app', 'asp', 'bas', 'bat', 'cer', 'cgi', 'chm', 'cmd', 'com', 'cpl', 'crt', 'csh', 'csr', 'dll', 'drv', 'fxp', 'flv', 'hlp', 'hta', 'htaccess', 'htm', 'htpasswd', 'inf', 'ins', 'isp', 'jar', 'js', 'jse', 'jsp', 'ksh', 'lnk', 'mdb', 'mde', 'mdt', 'mdw', 'msc', 'msi', 'msp', 'mst', 'ops', 'pcd', '
|
791 |
|
792 |
// Search in $not_allowed extension and match
|
793 |
foreach( $not_allowed as $single_ext ) {
|
@@ -920,6 +965,11 @@
|
|
920 |
<?php
|
921 |
}
|
922 |
|
|
|
|
|
|
|
|
|
|
|
923 |
// Add custom links
|
924 |
function dnd_custom_plugin_row_meta( $links, $file ) {
|
925 |
if ( strpos( $file, 'drag-n-drop-upload-cf7.php' ) !== false ) {
|
455 |
$class .= ' wpcf7-not-valid';
|
456 |
}
|
457 |
|
458 |
+
// Get current form Object
|
459 |
+
$form = WPCF7_ContactForm::get_current();
|
460 |
+
|
461 |
// Setup element attributes
|
462 |
$atts = array();
|
463 |
|
481 |
$atts['data-type'] = $tag->get_option( 'filetypes','', true);
|
482 |
$atts['data-limit'] = $tag->get_option( 'limit','', true);
|
483 |
$atts['data-max'] = $tag->get_option( 'max-file','', true);
|
484 |
+
$atts['data-id'] = ( $form->id() ? $form->id() : 0 );
|
485 |
|
486 |
// Combine and format attrbiutes
|
487 |
$atts = wpcf7_format_atts( $atts );
|
622 |
<?php
|
623 |
}
|
624 |
|
625 |
+
// Get allowed types
|
626 |
+
function dnd_cf7_get_allowed_types( $form_id ) {
|
627 |
+
|
628 |
+
// Initialize contact form instance
|
629 |
+
$form = WPCF7_ContactForm::get_instance( $form_id );
|
630 |
+
|
631 |
+
// Check if not valid object and null
|
632 |
+
if( ! $form && ! is_object( $form ) ) {
|
633 |
+
return false;
|
634 |
+
}
|
635 |
+
|
636 |
+
// Get specific tag (mfile is for dnd file upload)
|
637 |
+
$tags = $form->scan_form_tags( array( 'type' => array('mfile', 'mfile*') ) );
|
638 |
+
$supported_types = array();
|
639 |
+
|
640 |
+
// Loop all upload tags
|
641 |
+
if( $tags && is_array( $tags ) ) {
|
642 |
+
foreach( $tags as $tag ) {
|
643 |
+
|
644 |
+
// Get file types option & remove not allowed character..
|
645 |
+
$types = preg_replace( '/[^a-zA-Z0-9|\']/', '', $tag->get_option('filetypes','', true ) );
|
646 |
+
|
647 |
+
// Assign if filetypes is present otherwise use the default ext list.
|
648 |
+
$supported_types[ $tag->name ] = ( $types ? $types : dnd_upload_default_ext() );
|
649 |
+
}
|
650 |
+
}
|
651 |
+
|
652 |
+
return $supported_types;
|
653 |
+
}
|
654 |
+
|
655 |
// Begin process upload
|
656 |
function dnd_upload_cf7_upload() {
|
657 |
|
658 |
+
// cf7 form id & upload name
|
659 |
+
$cf7_id = sanitize_text_field( (int)$_POST['form_id']);
|
660 |
+
|
661 |
+
// Get the name of upload field.
|
662 |
+
$cf7_upload_name = sanitize_text_field( $_POST['upload_name'] );
|
663 |
+
|
664 |
+
// Get allowed ext list @expected : png|jpeg|jpg
|
665 |
+
$allowed_types = dnd_cf7_get_allowed_types( $cf7_id );
|
666 |
+
|
667 |
// check and verify ajax request
|
668 |
if( is_user_logged_in() ) {
|
669 |
check_ajax_referer( 'dnd-cf7-security-nonce', 'security' );
|
684 |
wp_send_json_error( '('. $file['error'] .') ' . ( $failed_error ? $failed_error : dnd_cf7_error_msg('failed_upload') ) );
|
685 |
}
|
686 |
|
687 |
+
/* Get allowed extension */
|
688 |
+
$supported_type = ( isset( $allowed_types["$cf7_upload_name"] ) ? $allowed_types["$cf7_upload_name"] : dnd_upload_default_ext() );
|
689 |
+
|
690 |
+
// Create type pattern for anti script
|
691 |
$file_type_pattern = dnd_upload_cf7_filetypes( $supported_type );
|
692 |
|
693 |
// Get file extension
|
832 |
$extension = preg_replace( '/[^A-Za-z0-9,|]/', '', $extension );
|
833 |
|
834 |
// not allowed file types
|
835 |
+
$not_allowed = array( 'php', 'php3','php4','phtml','exe','script', 'app', 'asp', 'bas', 'bat', 'cer', 'cgi', 'chm', 'cmd', 'com', 'cpl', 'crt', 'csh', 'csr', 'dll', 'drv', 'fxp', 'flv', 'hlp', 'hta', 'htaccess', 'htm', 'htpasswd', 'inf', 'ins', 'isp', 'jar', 'js', 'jse', 'jsp', 'ksh', 'lnk', 'mdb', 'mde', 'mdt', 'mdw', 'msc', 'msi', 'msp', 'mst', 'ops', 'pcd', 'pif', 'pl', 'prg', 'ps1', 'ps2', 'py', 'rb', 'reg', 'scr', 'sct', 'sh', 'shb', 'shs', 'sys', 'swf', 'tmp', 'torrent', 'url', 'vb', 'vbe', 'vbs', 'vbscript', 'wsc', 'wsf', 'wsf', 'wsh' );
|
836 |
|
837 |
// Search in $not_allowed extension and match
|
838 |
foreach( $not_allowed as $single_ext ) {
|
965 |
<?php
|
966 |
}
|
967 |
|
968 |
+
// Define custom (safe) file extension.
|
969 |
+
function dnd_upload_default_ext() {
|
970 |
+
return apply_filters('dnd_cf7_default_ext', 'jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|svg|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls' );
|
971 |
+
}
|
972 |
+
|
973 |
// Add custom links
|
974 |
function dnd_custom_plugin_row_meta( $links, $file ) {
|
975 |
if ( strpos( $file, 'drag-n-drop-upload-cf7.php' ) !== false ) {
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Donate link : http://codedropz.com/donation
|
3 |
Tags: drag and drop, contact form 7, ajax uploader, multiple file, upload, contact form 7 uploader
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 1.3.5.
|
7 |
Requires PHP: 5.2.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -133,6 +133,18 @@ To install this plugin see below:
|
|
133 |
|
134 |
== Changelog ==
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
= 1.3.5.4 =
|
137 |
* Added - Russian translation (Thanks to "Dan Uchvatoff ")
|
138 |
* Fixed - File counter "of" not translatable.
|
2 |
Donate link : http://codedropz.com/donation
|
3 |
Tags: drag and drop, contact form 7, ajax uploader, multiple file, upload, contact form 7 uploader
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 5.5
|
6 |
+
Stable tag: 1.3.5.5.1
|
7 |
Requires PHP: 5.2.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
133 |
|
134 |
== Changelog ==
|
135 |
|
136 |
+
= 1.3.5.5.1 =
|
137 |
+
* Bug - Fixed Contact Form 7 error notice
|
138 |
+
- PHP Deprecated: id property of a WPCF7_ContactForm object is no longer accessible.
|
139 |
+
- Reported here - https://wordpress.org/support/topic/bug-notice-id-not-accessible
|
140 |
+
|
141 |
+
= 1.3.5.5 =
|
142 |
+
* Fixed - Vulnerability (Thanks to @Sysdream Labs team )
|
143 |
+
- Removed "supported type" in POST request so other users cannot override through remote access.
|
144 |
+
- The issue was, user able to bypass and upload ".phar & .phpt" file extension by modifying "suported type"
|
145 |
+
- Those extensions are enabled by default on a fresh PHP/Apache2 installation.
|
146 |
+
* Improved - Security (file types condition are based on specified in the admin)
|
147 |
+
|
148 |
= 1.3.5.4 =
|
149 |
* Added - Russian translation (Thanks to "Dan Uchvatoff ")
|
150 |
* Fixed - File counter "of" not translatable.
|