WordPress File Upload - Version 4.10.2

Version Description

  • added wordpress_file_upload_preload_check() function in main plugin file to avoid conflicts of variable names with Wordpress
  • updated webcam code to address createObjectURL Javascript error that prevents webcam feature to work in latest versions of browsers
Download this release

Release Info

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

Code changes from version 4.10.1 to 4.10.2

js/wordpress_file_upload_functions.js CHANGED
@@ -139,7 +139,7 @@ maxrecordtime:maxrecordtime};GlobalData.WFU[sid].webcamProps=WebcamProps;wfu_rei
139
  wfu_reinitialize_webcam=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_props.active=true;webcam_props.width=0;webcam_props.width=0;webcam_props.timeStart=0;webcam_props.duration=0;webcam_props.counting=false;webcam_props.stream=null;webcam_props.media=null;webcam_props.blobs=null;webcam_props.playing=false;var WebcamProps=webcam_props;webcam_obj.updateStatus("idle");var constraints={audio:WebcamProps.audio,video:WebcamProps.video};if(typeof Promise==
140
  "undefined"){Promise=function(mainCallback){this.mainCallback=mainCallback;this.then=function(successCallback){this.successCallback=successCallback;return this};this["catch"]=function(errorCallback){mainCallback(this.successCallback,errorCallback)}};PromiseRejected=function(error){this.then=function(successCallback){return this};this["catch"]=function(errorCallback){errorCallback(error)}};Promise.reject=function(error){return new PromiseRejected(error)}}var promisifiedOldGUM=function(constraints,
141
  successCallback,errorCallback){var getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;if(!getUserMedia||typeof MediaRecorder=="undefined")return Promise.reject(new Error("getUserMedia is not implemented in this browser"));return new Promise(function(successCallback,errorCallback){getUserMedia.call(navigator,constraints,successCallback,errorCallback)})};if(navigator.mediaDevices===undefined)navigator.mediaDevices={};if(navigator.mediaDevices.getUserMedia===
142
- undefined)navigator.mediaDevices.getUserMedia=promisifiedOldGUM;navigator.mediaDevices.getUserMedia(constraints).then(function(stream){webcam_props.stream=stream;webcam_obj.setVideoProperties({autoplay:true,ontimeupdate:null,onerror:null,onloadeddata:function(e){wfu_webcam_init_callback(sid)},src:window.URL.createObjectURL(stream)});webcam_obj.initButtons(WebcamProps.mode)})["catch"](function(e){console.log("Video not supported!",e);webcam_obj.updateStatus("video_notsupported")})};
143
  wfu_webcam_init_callback=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;var video_size=webcam_obj.videoSize();webcam_props.width=video_size.width;webcam_props.height=video_size.height;webcam_obj.initCallback()};
144
  wfu_webcam_counter_status=function(sid,action){var webcam_props=GlobalData.WFU[sid].webcamProps;if(action=="start"){var d=new Date;webcam_props.duration=0;webcam_props.timeStart=d.getTime()/1E3;webcam_props.counting=true;wfu_webcam_update_counter(sid)}else{var d=new Date;webcam_props.duration=d.getTime()/1E3-webcam_props.timeStart;webcam_props.counting=false}};
145
  wfu_webcam_update_counter=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.counting){var d=new Date;var dif=d.getTime()/1E3-webcam_props.timeStart;webcam_obj.updateTimer(dif);setTimeout(function(){wfu_webcam_update_counter(sid)},100)}};
@@ -149,7 +149,7 @@ wfu_webcam_start_rec=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var
149
  -1||webcam_props.maxrecordtime>0&&dif<=webcam_props.maxrecordtime){if(e.data&&e.data.size>0)webcam_props.blobs.push(e.data)}else wfu_webcam_stop_rec(sid)};webcam_obj.updateButtonStatus("recording");wfu_webcam_counter_status(sid,"start");webcam_props.media.onstop=function(e){wfu_webcam_counter_status(sid,"stop");webcam_obj.updateButtonStatus("after_recording");wfu_webcam_onstop(e,sid)};webcam_props.media.start(10)};
150
  wfu_webcam_stop_rec=function(sid){var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_props.media.stop()};
151
  wfu_webcam_onstop=function(e,sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.blobs.length==0){alert(GlobalData.consts.webcam_video_nothingrecorded);wfu_webcam_golive(sid)}else{if(webcam_props.stream)webcam_obj.screenshot();var superBuffer=new Blob(webcam_props.blobs,{type:"video/mp4"});webcam_obj.setVideoProperties({autoplay:false,ontimeupdate:function(e){wfu_webcam_update_pos(sid)},onended:function(e){wfu_webcam_ended(sid)},onloadeddata:function(e){if(webcam_obj.readyState()>=
152
- 2)webcam_obj.updateButtonStatus("ready_playback")},onerror:function(e){webcam_obj.setVideoProperties({onloadeddata:null,src:window.URL.createObjectURL(webcam_props.stream)})},src:window.URL.createObjectURL(superBuffer)});superBuffer.name="video.mp4";wfu_add_files(sid,[{file:superBuffer,props:{}}],false);wfu_update_uploadbutton_status(sid)}};
153
  wfu_webcam_play=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.playing)return;webcam_obj.updateButtonStatus("playing");webcam_props.playing=true;webcam_obj.play()};wfu_webcam_ended=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_obj.ended();webcam_obj.updateButtonStatus("ready_playback");webcam_props.playing=false};
154
  wfu_webcam_pause=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_obj.pause();webcam_obj.updateButtonStatus("ready_playback");webcam_props.playing=false};wfu_webcam_back=function(sid){GlobalData.WFU[sid].webcam.back()};wfu_webcam_fwd=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_obj.fwd(webcam_props.duration)};
155
  wfu_webcam_take_picture=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.stream){webcam_obj.screenshot(function(image_file){image_file.name="image.png";wfu_add_files(sid,[{file:image_file,props:{}}],false);wfu_update_uploadbutton_status(sid)},"image/png");webcam_obj.updateButtonStatus("after_screenshot")}};
139
  wfu_reinitialize_webcam=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_props.active=true;webcam_props.width=0;webcam_props.width=0;webcam_props.timeStart=0;webcam_props.duration=0;webcam_props.counting=false;webcam_props.stream=null;webcam_props.media=null;webcam_props.blobs=null;webcam_props.playing=false;var WebcamProps=webcam_props;webcam_obj.updateStatus("idle");var constraints={audio:WebcamProps.audio,video:WebcamProps.video};if(typeof Promise==
140
  "undefined"){Promise=function(mainCallback){this.mainCallback=mainCallback;this.then=function(successCallback){this.successCallback=successCallback;return this};this["catch"]=function(errorCallback){mainCallback(this.successCallback,errorCallback)}};PromiseRejected=function(error){this.then=function(successCallback){return this};this["catch"]=function(errorCallback){errorCallback(error)}};Promise.reject=function(error){return new PromiseRejected(error)}}var promisifiedOldGUM=function(constraints,
141
  successCallback,errorCallback){var getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;if(!getUserMedia||typeof MediaRecorder=="undefined")return Promise.reject(new Error("getUserMedia is not implemented in this browser"));return new Promise(function(successCallback,errorCallback){getUserMedia.call(navigator,constraints,successCallback,errorCallback)})};if(navigator.mediaDevices===undefined)navigator.mediaDevices={};if(navigator.mediaDevices.getUserMedia===
142
+ undefined)navigator.mediaDevices.getUserMedia=promisifiedOldGUM;navigator.mediaDevices.getUserMedia(constraints).then(function(stream){webcam_props.stream=stream;webcam_obj.setVideoProperties({autoplay:true,ontimeupdate:null,onerror:null,onloadeddata:function(e){wfu_webcam_init_callback(sid)},srcObject:stream});webcam_obj.initButtons(WebcamProps.mode)})["catch"](function(e){console.log("Video not supported!",e);webcam_obj.updateStatus("video_notsupported")})};
143
  wfu_webcam_init_callback=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;var video_size=webcam_obj.videoSize();webcam_props.width=video_size.width;webcam_props.height=video_size.height;webcam_obj.initCallback()};
144
  wfu_webcam_counter_status=function(sid,action){var webcam_props=GlobalData.WFU[sid].webcamProps;if(action=="start"){var d=new Date;webcam_props.duration=0;webcam_props.timeStart=d.getTime()/1E3;webcam_props.counting=true;wfu_webcam_update_counter(sid)}else{var d=new Date;webcam_props.duration=d.getTime()/1E3-webcam_props.timeStart;webcam_props.counting=false}};
145
  wfu_webcam_update_counter=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.counting){var d=new Date;var dif=d.getTime()/1E3-webcam_props.timeStart;webcam_obj.updateTimer(dif);setTimeout(function(){wfu_webcam_update_counter(sid)},100)}};
149
  -1||webcam_props.maxrecordtime>0&&dif<=webcam_props.maxrecordtime){if(e.data&&e.data.size>0)webcam_props.blobs.push(e.data)}else wfu_webcam_stop_rec(sid)};webcam_obj.updateButtonStatus("recording");wfu_webcam_counter_status(sid,"start");webcam_props.media.onstop=function(e){wfu_webcam_counter_status(sid,"stop");webcam_obj.updateButtonStatus("after_recording");wfu_webcam_onstop(e,sid)};webcam_props.media.start(10)};
150
  wfu_webcam_stop_rec=function(sid){var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_props.media.stop()};
151
  wfu_webcam_onstop=function(e,sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.blobs.length==0){alert(GlobalData.consts.webcam_video_nothingrecorded);wfu_webcam_golive(sid)}else{if(webcam_props.stream)webcam_obj.screenshot();var superBuffer=new Blob(webcam_props.blobs,{type:"video/mp4"});webcam_obj.setVideoProperties({autoplay:false,ontimeupdate:function(e){wfu_webcam_update_pos(sid)},onended:function(e){wfu_webcam_ended(sid)},onloadeddata:function(e){if(webcam_obj.readyState()>=
152
+ 2)webcam_obj.updateButtonStatus("ready_playback")},onerror:function(e){webcam_obj.setVideoProperties({onloadeddata:null,srcObject:webcam_props.stream})},srcObject:superBuffer});superBuffer.name="video.mp4";wfu_add_files(sid,[{file:superBuffer,props:{}}],false);wfu_update_uploadbutton_status(sid)}};
153
  wfu_webcam_play=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.playing)return;webcam_obj.updateButtonStatus("playing");webcam_props.playing=true;webcam_obj.play()};wfu_webcam_ended=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_obj.ended();webcam_obj.updateButtonStatus("ready_playback");webcam_props.playing=false};
154
  wfu_webcam_pause=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_obj.pause();webcam_obj.updateButtonStatus("ready_playback");webcam_props.playing=false};wfu_webcam_back=function(sid){GlobalData.WFU[sid].webcam.back()};wfu_webcam_fwd=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;webcam_obj.fwd(webcam_props.duration)};
155
  wfu_webcam_take_picture=function(sid){var webcam_obj=GlobalData.WFU[sid].webcam;var webcam_props=GlobalData.WFU[sid].webcamProps;if(webcam_props.stream){webcam_obj.screenshot(function(image_file){image_file.name="image.png";wfu_add_files(sid,[{file:image_file,props:{}}],false);wfu_update_uploadbutton_status(sid)},"image/png");webcam_obj.updateButtonStatus("after_screenshot")}};
lib/wfu_template.php CHANGED
@@ -2345,7 +2345,16 @@ this.setVideoProperties = function(props) {
2345
  var video = document.getElementById("webcam_$ID_box");
2346
  for (var prop in props) {
2347
  if (props.hasOwnProperty(prop)) {
2348
- video[prop] = props[prop];
 
 
 
 
 
 
 
 
 
2349
  }
2350
  }
2351
  }
2345
  var video = document.getElementById("webcam_$ID_box");
2346
  for (var prop in props) {
2347
  if (props.hasOwnProperty(prop)) {
2348
+ if (prop == "srcObject") {
2349
+ try {
2350
+ video.srcObject = props["srcObject"];
2351
+ }
2352
+ catch (error) {
2353
+ //fallback to the src property if srcObject not supported
2354
+ video.src = window.URL.createObjectURL(props["srcObject"]);
2355
+ }
2356
+ }
2357
+ else video[prop] = props[prop];
2358
  }
2359
  }
2360
  }
readme.txt CHANGED
@@ -149,6 +149,10 @@ There is an option in plugin's settings in Dashboard to relax the CSS rules, so
149
 
150
  == Changelog ==
151
 
 
 
 
 
152
  = 4.10.1 =
153
  * code modified so that vendor libraries are loaded only when necessary
154
  * improved process of deleting all plugin options
@@ -816,6 +820,9 @@ Initial version.
816
 
817
  == Upgrade Notice ==
818
 
 
 
 
819
  = 4.10.1 =
820
  Regular update to introduce some new features and improvements.
821
 
149
 
150
  == Changelog ==
151
 
152
+ = 4.10.2 =
153
+ * added wordpress_file_upload_preload_check() function in main plugin file to avoid conflicts of variable names with Wordpress
154
+ * updated webcam code to address createObjectURL Javascript error that prevents webcam feature to work in latest versions of browsers
155
+
156
  = 4.10.1 =
157
  * code modified so that vendor libraries are loaded only when necessary
158
  * improved process of deleting all plugin options
820
 
821
  == Upgrade Notice ==
822
 
823
+ = 4.10.2 =
824
+ Minor update to introduce some improvements and fix some bugs.
825
+
826
  = 4.10.1 =
827
  Regular update to introduce some new features and improvements.
828
 
release_notes.txt CHANGED
@@ -1,9 +1,7 @@
1
- <!-- --><span><strong>Version 4.10.1</strong> is a <strong>regular</strong> update that introduces the following improvements and additions:</span>
2
  <ul style="list-style: disc; padding-left: 30px;">
3
- <li>Added <strong>honeypot</strong> field to <strong>userdata fields</strong>. This is a security feature, in replacement of captchas, invisible to users that prevents bots from uploading files.</li>
4
- <li>Added attribute <strong>Consent Denial Rejects Upload</strong> in uploader shortcode <strong>Personal Data</strong> tab to stop the upload if the consent answer is no, as well as <strong>Reject Message</strong> attribute to customize the upload rejection message shown to the user</li>
5
- <li>Added attribute <strong>Do Not Remember Consent Answer</strong> in uploader shortcode <strong>Personal Data</strong> tab to show the consent question every time (and not only the first time).</li>
6
- <li>Attribute <strong>Preselected Answer</strong> in uploader shortcode <strong>Personal Data</strong> tab modified to be compatible with either checkbox or radio Consent Format.</li>
7
  </ul>
8
  For more details about this version's changes please visit the Release Notes of the plugin's </span><a href="http://www.iptanus.com/wordpress-plugins/wordpress-file-upload/">support page</a><span>.</span><!-- -->
9
  <!-- -->
1
+ <!-- --><span><strong>Version 4.10.2</strong> is a <strong>minor</strong> update that introduces the following improvements and bug fixes:</span>
2
  <ul style="list-style: disc; padding-left: 30px;">
3
+ <li>Plugin code improved to avoid conflicts of variable names with Wordpress.</li>
4
+ <li>Updated webcam code to align with latest modifications of web browsers that prevented <strong>webcam</strong> feature to work properly.</li>
 
 
5
  </ul>
6
  For more details about this version's changes please visit the Release Notes of the plugin's </span><a href="http://www.iptanus.com/wordpress-plugins/wordpress-file-upload/">support page</a><span>.</span><!-- -->
7
  <!-- -->
wordpress_file_upload.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
5
  Description: Simple interface to upload files from a page.
6
- Version: 4.10.1
7
  Author: Nickolas Bossinas
8
  Author URI: http://www.iptanus.com
9
  Text Domain: wp-file-upload
@@ -27,30 +27,35 @@ You should have received a copy of the GNU General Public License
27
  along with this program. If not, see <http://www.gnu.org/licenses/>.
28
  */
29
 
30
- //do not load plugin if this is the login page
31
- $uri = $_SERVER['REQUEST_URI'];
32
- if ( strpos($uri, 'wp-login.php') !== false ) return;
 
33
 
34
- //before loading the plugin we need to check if restricted loading is enabled
35
- if ( !is_admin() ) {
36
- $page = get_page_by_path($uri);
37
- if ( $page ) {
38
- $envars = get_option("wfu_environment_variables", array());
39
- $ids = ( isset($envars["WFU_RESTRICT_FRONTEND_LOADING"]) ? $envars["WFU_RESTRICT_FRONTEND_LOADING"] : "false" );
40
- //if restricted loading is enabled, then the plugin will load only if
41
- //the current page ID is included in $ids list
42
- if ( $ids !== "false" ) {
43
- $ids = explode(",", $ids);
44
- $pass = false;
45
- foreach ( $ids as $id )
46
- if ( trim($id) != "" && (int)trim($id) > 0 && (int)trim($id) == $page->ID ) {
47
- $pass = true;
48
- break;
49
- }
50
- if ( !$pass ) return;
51
  }
52
  }
 
53
  }
 
 
 
54
  //proceed loading the plugin
55
  DEFINE("WPFILEUPLOAD_PLUGINFILE", __FILE__);
56
  require_once( plugin_dir_path( WPFILEUPLOAD_PLUGINFILE ) . 'wfu_loader.php' );
3
  /*
4
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
5
  Description: Simple interface to upload files from a page.
6
+ Version: 4.10.2
7
  Author: Nickolas Bossinas
8
  Author URI: http://www.iptanus.com
9
  Text Domain: wp-file-upload
27
  along with this program. If not, see <http://www.gnu.org/licenses/>.
28
  */
29
 
30
+ function wordpress_file_upload_preload_check() {
31
+ //do not load plugin if this is the login page
32
+ $uri = $_SERVER['REQUEST_URI'];
33
+ if ( strpos($uri, 'wp-login.php') !== false ) return false;
34
 
35
+ if ( !is_admin() ) {
36
+ $page = get_page_by_path($uri);
37
+ if ( $page ) {
38
+ $envars = get_option("wfu_environment_variables", array());
39
+ $ids = ( isset($envars["WFU_RESTRICT_FRONTEND_LOADING"]) ? $envars["WFU_RESTRICT_FRONTEND_LOADING"] : "false" );
40
+ //if restricted loading is enabled, then the plugin will load only if
41
+ //the current page ID is included in $ids list
42
+ if ( $ids !== "false" ) {
43
+ $ids = explode(",", $ids);
44
+ $pass = false;
45
+ foreach ( $ids as $id )
46
+ if ( trim($id) != "" && (int)trim($id) > 0 && (int)trim($id) == $page->ID ) {
47
+ $pass = true;
48
+ break;
49
+ }
50
+ if ( !$pass ) return false;
51
+ }
52
  }
53
  }
54
+ return true;
55
  }
56
+
57
+ //before loading the plugin we need to check if restricted loading is enabled
58
+ if ( !wordpress_file_upload_preload_check() ) return;
59
  //proceed loading the plugin
60
  DEFINE("WPFILEUPLOAD_PLUGINFILE", __FILE__);
61
  require_once( plugin_dir_path( WPFILEUPLOAD_PLUGINFILE ) . 'wfu_loader.php' );