Version Description
Download this release
Release Info
Developer | cssimmon |
Plugin | Backup and Restore WordPress – WPBackItUp Backup Plugin |
Version | 1.24.0 |
Comparing to | |
See all releases |
Code changes from version 1.23.0 to 1.24.0
- js/wp-backitup-admin.min.js +1 -1
- lib/includes/class-admin-notices.php +3 -3
- lib/includes/class-job-scheduler.php +175 -0
- lib/includes/class-license.php +182 -79
- lib/includes/class-usage.php +9 -1
- lib/includes/class-wpbackitup-admin.php +114 -94
- lib/includes/update_plugin.php +20 -0
- readme.txt +7 -0
- views/backup.php +3 -3
- wp-backitup.php +5 -4
js/wp-backitup-admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var WPBNewBackupData={},ajaxNamespace="wpbackitup-safe",ENUM={GDRIVE:"GDRIVE",AMAZONS3:"AMAZONS3",DROPBOX:"DROPBOX"},CLOUDSTATUS={READY:"ready",UPLOADING:"uploading",UPLOADED:"uploaded",ERROR:"error"},debugFlag=!1,wpbackitup_get_action_name=function(e){return ajaxNamespace+"_"+e},AjaxGetSafe=function(e){return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:wpbackitup_get_action_name(e),security:WPBackItUpSafeLocals[e]},dataType:"json"})},AjaxGetCore=function(e){var a=wpbackitup_local[e];return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:"wp-backitup_"+e,security:a},dataType:"json"})},AjaxPostSafe=function(e,a){var a=a||{};return a.action=wpbackitup_get_action_name(e),a.security=WPBackItUpSafeLocals[e],jQuery.ajax({url:ajaxurl,type:"POST",data:a,dataType:"json"})};!function(e){"use strict";if(document.querySelector("#wpbackitup-core-backup"))var a=new Vue({el:"#wpbackitup-core-backup",data:{cloudStatus:{},isNewRowAvailable:!1,backupNewRow:{}},methods:{getAvailableBackups:function(){AjaxGetCore("get_available_backups").then(function(e){if(e.success)for(var t=0;t<e.data.length;t++){var i=e.data[t].backup_job_id,s=e.data[t].backup_job_cloud_status;a.$set(a.cloudStatus,i,s)}})},getBackupStatus:function(){var e=WPBNewBackupData;if("success"===e.backupStatus){var a=e.backupName,t=a.lastIndexOf("_"),i=a.substring(t+1);this.isNewRowAvailable=!0,this.backupNewRow={name:e.backupName,type:e.backupRuntype,date:e.backupDate,duration:e.backupDuration,status:e.backupStatus,row:99999,jobId:i,zipExist:!0},WPBNewBackupData={}}}},mounted:function(){this.getAvailableBackups(),this.getBackupStatusInterval=setInterval(function(){0!==Object.keys(WPBNewBackupData).length&&this.getBackupStatus()}.bind(this),1e3),this.getAvailableBackupsInterval=setInterval(function(){this.getAvailableBackups()}.bind(this),3e3)},beforeDestroy:function(){clearInterval(this.getAvailableBackupsInterval),clearInterval(this.getBackupStatusInterval)}})}(jQuery),function(e){function a(){e(".viewloglink").click(function(){var a=e(this).attr("href");return e("#backup_name").val(a),e("#viewlog").submit(),!1})}function t(){e(".downloadbackuplink").bind("click",function(){var a=e(this).attr("href");return e("#backup_file").val(a),e(this).append('<i class="fa fa-check"></i>'),e(this).css({color:"green"}),e("#download_backup").submit(),!1})}function i(a,i){var n=({action:f("backup_zip_filelist"),job_id:a},i.replace(/[^A-Za-z0-9\-]/g,"")),o=0,c="",l='<div id="'+n+'"> <h2>'+wpbackitup_local.bl_backup_set+" <em>"+i+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button><span id="wpbiu-note-response">'+wpbackitup_local.bl_note_saved_success+"</span></div> <p>"+wpbackitup_local.bl_backup_download+'</p> <table class="widefat" id="datatable"> <tbody>';e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_zip_filelist"),job_id:a},dataType:"json"}).done(function(i){i.data?(e.each(i.data,function(){var a=e(this)[0].name.split(/[\/]+/).pop(),t=e(this)[0].size,i=e(this)[0].file_exists;if(console.log(a,t),a.indexOf("-backupset-")>-1)c='<p><a class="downloadbackuplink" href="'+a+'"><i class="fa fa-cloud-download fa-3x"></i> <strong>'+wpbackitup_local.bl_backup_download_single+"</strong></a> <br><em>"+wpbackitup_local.bl_please_note+t+wpbackitup_local.bl_may_timeout+"</em></p>";else{o++;var s="";o%2!=0&&(s="alternate"),l+='<tr class="'+s+'" id="row'+o+'">',l+=i?'<td><a class="downloadbackuplink" href="'+a+'">'+a+"</a></td>":"<td>"+a+"</td>",l+="<td>"+t+"</td> </tr>"}}),l+=c+"</tbody></table></div>",e("#TB_ajaxContent").html(l),t(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-note-box").val(a.data)}}),e("#wpbiu-note-btn").click(function(){var t=e("#wpbiu-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-note-response").fadeIn()})}),e("#wpbiu-note-box").focus(function(){e("#wpbiu-note-response").hide()})):s(i,null,null)}).fail(function(e,a,t){s(e,a,t)})}function s(e,a,t){var i="Error-Invalid response from server: ";a&&(i+=a+"\n"),t&&(i+=t+"\n"),i+="\nResponse: \n\n"+JSON.stringify(e),alert(i)}function n(){var a={action:f("restore_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),e(a).find(".isa_error").fadeIn(1500),clearInterval(window.intervalDefine)),e(this).html()==-2&&e(a).find(".isa_warning").fadeIn(1500),99==e(this).html()&&(e(a).find(".isa_success").fadeIn(1500),clearInterval(window.intervalDefine))})})}function o(){var a={action:f("backup_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){if(x)return clearInterval(window.intervalDefine),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").fadeOut(200),e(".backup-cancelled").fadeIn(200),!1;var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),clearInterval(window.intervalDefine),c()),e(this).html()==-2&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".wpbackitup-warning").fadeIn(1500)),99==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500),clearInterval(window.intervalDefine),c())})})}function c(){var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_response_reader")},dataType:"json"});a.always(function(a,t,i){if(console.log("Backup Response:"+JSON.stringify(a)),"undefined"!=typeof a.backupStatus&&"undefined"!=typeof a.backupMessage){if(console.log("JSON Backup Status:"+a.backupStatus),console.log("JSON Backup Message:"+a.backupMessage),y)return;switch(y=!0,a.backupStatus){case"success":if(console.log("JSON success response received."),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden"),e(".isa_success").show,e(".backup-success").fadeIn(1500),_(a),"undefined"!=typeof a.backupWarnings){var s=e(".backup-warning"),n=a.backupWarnings;n.forEach(function(e){var a=e.warningMessage;s.append('<li class="isa_warning">'+wpbackitup_local.warning+": "+a+"</li>")}),s.fadeIn(1500)}break;case"error":console.log("JSON error response received.");var o=wpbackitup_local.unexpected_err;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+": "+o,l=e(".backup-error");l.html(c),l.addClass("isa_error"),l.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden");break;default:console.log("Unexpected JSON response status received.");var o=wpbackitup_local.unexpected_err2;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+"(JS998) : "+o,u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden")}}else{console.log("NON JSON response received."),console.log("Backup Response:"+i),c=wpbackitup_local.unexpected_err3+": ",c+="</br>"+wpbackitup_local.response+": "+JSON.stringify(a),c+="</br>"+wpbackitup_local.status+": "+t,c+="</br>"+wpbackitup_local.error+": "+JSON.stringify(i),e(".backup-status").hide();var u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.show(),e(".status-icon").fadeOut(200)}})}function l(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-success").hide(),e(".default-status").hide(),e(".backup-error").hide(),e(".backup-cancelled").hide(),e("ul.backup-status").children().children().hide(),e(".backup-errors").children().children().hide(),e(".backup-success").children().children().hide(),e(".backup-status").show(),y=!1,window.intervalDefine=setInterval(o,5e3)}function u(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-status").show(),y=!1,clearInterval(window.intervalDefine),window.intervalDefine=setInterval(o,5e3)}function r(){e(".restore-icon").css("visibility","visible"),e(".default-status, .upload-status").hide(),e("ul.restore-status").children().children().hide(),e(".restore-errors").children().children().hide(),e(".restore-success").children().children().hide(),e(".restore-status, .restore-errors, .restore-success").show(),e(".preparing-icon").css("visibility","visible"),e(".preparing").find(".status-icon").fadeIn(1500),window.intervalDefine=setInterval(n,5e3)}function p(a){var t=new plupload.Uploader(a);t.init(),t.bind("FilesAdded",function(a,t){plupload.each(t,function(a){e("#filelist").append('<div id="media-item-'+a.id+'" class="media-item child-of-0"><img class="pinkynail" alt="" src="'+site_url+'/wp-includes/images/media/archive.png"><div class="filename new" id="'+a.id+'">'+a.name+" (<span>"+plupload.formatSize(0)+"</span> of "+plupload.formatSize(a.size)+') <div class="progress" style="width: 0%;"></div></div></div>')}),a.refresh(),a.start()}),t.bind("UploadProgress",function(a,t){e("#"+t.id+" .progress").width(.15*t.percent+"%"),e("#"+t.id+" span").html(plupload.formatSize(parseInt(t.size*t.percent/100)))}),t.bind(" ChunkUploaded",function(e,a,t){console.log("Chunk Uploaded:"),console.log(t),d(t,e,a)&&console.log("chunk error")}),t.bind("Error",function(a,t){console.log("PlUpload Error:"),console.log(t);var i="error-item-"+t.file.id;e("#"+i).length||e("#filelist").append('<div class="error-div error" id="'+i+'" ><strong>'+t.file.name+" has failed to upload due to error: </strong> <span>"+t.message+"</span> </div>")}),t.bind("FileUploaded",function(a,t,i){console.log("File Uploaded"),console.log(i),d(i,a,t)?console.log("uploaded error"):(console.log("uploaded success"),e("#"+t.id+" .progress").css("background-color","green"),e("#import-uploads").show())})}function d(e,a,t){if("200"!=e.status)return alert("Unknown server response status: "+e.code),console.log(e),b(a,t,999,e.response),!0;try{return response_json=jQuery.parseJSON(e.response),!!response_json.error&&(b(a,t,100,response_json.error),!0)}catch(i){return console.log("Unexpected JSON Error"+i),b(a,t,998,e.response),!0}}function b(a,t,i,s){t.status=plupload.FAILED,a.trigger("Error",{code:i,message:s,file:t}),e("#media-item-"+t.id).hide()}function _(i){"undefined"!=typeof i&&(WPBNewBackupData=i,e("#nofiles")&&e("#nofiles").remove(),a(),t())}function f(e){return w+"_"+e}function k(){notification_bar=e("#wp-backitup-notification-parent"),notification_bar.fadeOut("slow")}function h(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("error",!1),notification_bar.toggleClass("updated",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}function g(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("updated",!1),notification_bar.toggleClass("error",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}var w="wp-backitup",v=0;a(),t();try{"undefined"!=typeof wpbackitup_plupload_config&&p(wpbackitup_plupload_config)}catch(m){console.log(m)}e(".logs_backup").click(function(){var a=e(this).attr("href");return e("#backup_file").val(a),e("#download_logs").val(),e("#download_backup").submit(),!1}),e("#scheduled-backups-accordian").click(function(){scheduled_backups=e("#scheduled-backups"),scheduled_backups_button=e("#scheduled-backups-accordian"),e(this).is(".fa-angle-double-down")?(scheduled_backups.fadeIn("slow"),scheduled_backups_button.toggleClass("fa-angle-double-down",!1),scheduled_backups_button.toggleClass("fa-angle-double-up",!0)):(scheduled_backups_button.toggleClass("fa-angle-double-down",!0),scheduled_backups_button.toggleClass("fa-angle-double-up",!1),scheduled_backups.fadeOut("slow"))}),e("#upload-backups-accordian").click(function(){upload_backups=e("#wpbackitup-plupload-modal"),upload_backups_button=e("#upload-backups-accordian"),e(this).is(".fa-angle-double-down")?(upload_backups.fadeIn("slow"),upload_backups_button.toggleClass("fa-angle-double-down",!1),upload_backups_button.toggleClass("fa-angle-double-up",!0)):(upload_backups_button.toggleClass("fa-angle-double-down",!0),upload_backups_button.toggleClass("fa-angle-double-up",!1),upload_backups.fadeOut("slow"))}),e("#wpbackitup-zip").bind("change",function(){var a=this.files[0].size,t=e("#maxfilesize").val();"undefined"!=a&&"undefined"!=t&&""!=a&&""!=t&&a>t&&(alert(wpbackitup_local.upload_file_size_exceed),e("#wpbackitup-zip").val(""))}),e("#import-uploads").click(function(){setTimeout(function(){window.location.reload()},100)}),e(document.body).on("click",".thickbox",function(){if(!e(this).parents(".wpbiu-restore-item").length){var a=e(this).data("jobid");console.log(a);var t=this.name;i(a,t)}}),e(document.body).on("click",".thickbox",function(){var a=e(this).data("jobid"),t=e(this).attr("name");if(e(this).parents(".wpbiu-restore-item").length){var i="<h2>"+wpbackitup_local.bl_backup_set+" <em>"+t+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-restore-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-restore-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button> <span id="wpbiu-restore-note-response">'+wpbackitup_local.bl_note_saved_success+"</span> </div>";e("#wpbiu-restore-note").html(i),e("#wpbiu-restore-note-response").hide(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-restore-note-box").val(a.data)}}),e("#wpbiu-restore-note-btn").click(function(){var t=e("#wpbiu-restore-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-restore-note-response").fadeIn()})})}e("#wpbiu-restore-note-box").focus(function(){e("#wpbiu-restore-note-response").hide()})});var y=!1;e("#wp-backitup-notification-widget-close").click(function(){notification_bar=e("#wp-backitup-notification-widget"),notification_bar.fadeOut("slow");var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("delete_transient")},dataType:"json"});a.always(function(a,t,i){a!==!1&&(notification_bar.removeClass(),notification_bar.addClass("notice"),notification_bar.addClass("notice-"+a.message_type),e("#wp-backitup-notification-widget-message p").html(a.message),notification_bar.hide().fadeIn("slow"))})}),e("#wp-backitup-notification-close").click(function(){k()}),e("#wp-backitup-save_schedule_form").submit(function(){var a=new FormData;a.append("action",f("update-schedule")),a.append("_wpnonce",e("#wp-backitup_nonce-update-schedule").val()),a.append("_wp_http_referer",e("[name='_wp_http_referer']").val());var t=[];return e.each(e("input[name='dow']:checked"),function(){t.push(e(this).val())}),a.append("days_selected",t),jQuery.ajax({url:ajaxurl,type:"POST",cache:!1,contentType:!1,processData:!1,dataType:"json",data:a,success:function(e,a,t){switch(response=e.message,console.log("Success:"+response),response){case"success":h(wpbackitup_local.scheduled_saved);break;case"error":g(wpbackitup_local.scheduled_not_saved)}},error:function(e,a,t){console.log("Error."+a+":"+t)},complete:function(e,a){console.log("Complete")}}),!1});var j=null;e(".backup-button").click(function(a){a.preventDefault(),x=!1,e("#backup-button").attr("disabled","disabled"),e("#cancel-button").removeClass("cancel-hidden"),e("#cancel-button").removeAttr("disabled"),e("#cancel-button").fadeIn(200),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup")},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),l()}}),j.always(function(e,a,t){console.log("Backup Button Click - Always"),console.log(e.message),"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})});var x=!1;e(".cancel-button").click(function(a){a.preventDefault(),e("#cancel-button").attr("disabled","disabled"),null!=j&&(j.abort(),j=null),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("cancel_backup"),job_id:v},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),u()}}),j.always(function(e,a,t){console.log("Cancel Button Click - Always"),console.log(e),"undefined"!=typeof e.success&&1==e.success?console.log("Job Cancelled successfully"):console.log("Job was not cancelled successfully"),x=!0})}),e("#datatable").on("click","a.restoreRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.confirm_restore)){var t=this.title;this.id.replace("restoreRow","row");userid=e("input[name=user_id]").val();var i=e.ajax({url:ajaxurl,type:"post",data:{action:f("restore"),selected_file:t,user_id:userid},cache:!1,dataType:"json",beforeSend:function(){console.log("BeforeSend:Nothing to report."),r()}});i.always(function(e,a,t){"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})}}),e("#datatable").on("click","a.deleteRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.sure)){var t=this.title,i=e(this).data("id"),s=this.id.replace("deleteRow","row");e.ajax({url:ajaxurl,type:"post",data:{action:f("delete_file"),filed:t,post_id:i},success:function(a){var t=a.search("deleted");0==t?e("#"+s).remove():alert(wpbackitup_local.file_not_del)}})}})}(jQuery),function(e){"use strict";var a="wp-backitup",t=function(e){return a+"_"+e},i=function(a){return e.ajax({url:ajaxurl,type:"GET",data:{action:t(a)},dataType:"json"})},s=function(a,i){var i=i||{};return i.action=t(a),i.security=e("#wpbackitup-core-ajax-nonce").val(),e.ajax({url:ajaxurl,type:"POST",data:i,dataType:"json"})};e(window).load(function(){if(document.querySelector("#wpbackitup-core-settings")){Vue.use(VueTabs);var e=new Vue({el:"#wpbackitup-core-settings",data:{loading:!1,updated:!1,emailsArray:[],errorMessages:{},backup_retained_number:3,logging:!1,single_file_db:!1,single_file_backupset:!1,rversion_compare:!1,remove_supporting_zip_files:!1,backup_plugins_filter:[],backup_themes_filter:[],backup_uploads_filter:[],backup_others_filter:[],dbFilterOptions:[],db_filters:[],allow_usage_tracking:!1,backup_dbtables_batch_size:1e4,backup_sql_merge_batch_size:1e4,backup_sql_batch_size:1e4,backup_plugins_batch_size:5e3,backup_themes_batch_size:5e3,backup_uploads_batch_size:500,backup_others_batch_size:500,backup_zip_max_size:524288e3,backup_max_timeout:120,delete_all:!1,safe_sync:!1},computed:{dbFilterHasSearch:function(){return 0==this.dbFilterOptions.length},dbFilterPlaceholder:function(){return this.dbFilterOptions.length>0?wpbackitup_local.settings_select_database_table_to_filter:wpbackitup_local.settings_no_database_table_to_filter}},methods:{handleEmailInput:function(e){},handleTagsInput:function(e){},setSettings:function(){var a={data:{notification_email:this.emailsArray.join(","),backup_retained_number:this.backup_retained_number,logging:this.logging,single_file_db:this.single_file_db,single_file_backupset:this.single_file_backupset,rversion_compare:this.rversion_compare,remove_supporting_zip_files:this.remove_supporting_zip_files,backup_plugins_filter:this.backup_plugins_filter.join(","),backup_themes_filter:this.backup_themes_filter.join(","),backup_uploads_filter:this.backup_uploads_filter.join(","),backup_others_filter:this.backup_others_filter.join(","),backup_dbtables_filter_list:this.db_filters.map(function(e){return e.value}).join(","),backup_dbtables_batch_size:this.backup_dbtables_batch_size,backup_sql_merge_batch_size:this.backup_sql_merge_batch_size,backup_sql_batch_size:this.backup_sql_batch_size,backup_plugins_batch_size:this.backup_plugins_batch_size,backup_themes_batch_size:this.backup_themes_batch_size,backup_uploads_batch_size:this.backup_uploads_batch_size,backup_others_batch_size:this.backup_others_batch_size,backup_zip_max_size:this.backup_zip_max_size,backup_max_timeout:this.backup_max_timeout,delete_all:this.delete_all,safe_sync:this.safe_sync,allow_usage_tracking:this.allow_usage_tracking}};console.log(a),s("set_settings",a).then(function(a){a.success?(e.updated=!0,e.errorMessages={},swal(wpbackitup_local.settings_save_awesome,wpbackitup_local.settings_save_success_message,"success")):(e.errorMessages=a.data,swal(wpbackitup_local.settings_save_oops,wpbackitup_local.settings_save_error_message,"error"))})},getSettings:function(){this.loading=!0,i("get_settings").then(function(a){e.loading=!1,a.success&&(console.log(a),e.emailsArray=a.data.notification_email.split(",").filter(Boolean),e.backup_retained_number=a.data.backup_retained_number,e.logging="1"===a.data.logging,e.single_file_db="1"===a.data.single_file_db,e.rversion_compare="1"===a.data.rversion_compare,e.single_file_backupset="1"===a.data.single_file_backupset,e.remove_supporting_zip_files="1"===a.data.remove_supporting_zip_files,e.backup_plugins_filter=a.data.backup_plugins_filter.split(",").filter(Boolean),e.backup_themes_filter=a.data.backup_themes_filter.split(",").filter(Boolean),e.backup_uploads_filter=a.data.backup_uploads_filter.split(",").filter(Boolean),e.backup_others_filter=a.data.backup_others_filter.split(",").filter(Boolean),e.db_filters=a.data.backup_dbtables_filter_list.split(",").filter(Boolean).map(function(e){return{label:e,value:e}}),e.dbFilterOptions=Object.keys(a.data.backup_dbtables_filterable).map(function(e){var t=a.data.backup_dbtables_filterable[e];return{label:t,value:t}}),e.allow_usage_tracking=a.data.allow_usage_tracking,e.backup_dbtables_batch_size=a.data.backup_dbtables_batch_size,e.backup_sql_merge_batch_size=a.data.backup_sql_merge_batch_size,e.backup_sql_batch_size=a.data.backup_sql_batch_size,e.backup_plugins_batch_size=a.data.backup_plugins_batch_size,e.backup_themes_batch_size=a.data.backup_themes_batch_size,e.backup_uploads_batch_size=a.data.backup_uploads_batch_size,e.backup_others_batch_size=a.data.backup_others_batch_size,e.backup_zip_max_size=a.data.backup_zip_max_size,e.backup_max_timeout=a.data.backup_max_timeout,e.delete_all="1"===a.data.delete_all,e.safe_sync="1"===a.data.safe_sync)})}},created:function(){this.getSettings()}})}})}(jQuery);
|
1 |
+
var WPBNewBackupData={},ajaxNamespace="wpbackitup-safe",ENUM={GDRIVE:"GDRIVE",AMAZONS3:"AMAZONS3",DROPBOX:"DROPBOX"},CLOUDSTATUS={READY:"ready",UPLOADING:"uploading",UPLOADED:"uploaded",ERROR:"error"},debugFlag=!1;if("undefined"==typeof WPBackItUpSafeLocals)var WPBackItUpSafeLocals=[];var wpbackitup_get_action_name=function(e){return ajaxNamespace+"_"+e},AjaxGetSafe=function(e){return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:wpbackitup_get_action_name(e),security:WPBackItUpSafeLocals[e]},dataType:"json"})},AjaxGetCore=function(e){var a=wpbackitup_local[e];return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:"wp-backitup_"+e,security:a},dataType:"json"})},AjaxPostSafe=function(e,a){var a=a||{};return a.action=wpbackitup_get_action_name(e),a.security=WPBackItUpSafeLocals[e],jQuery.ajax({url:ajaxurl,type:"POST",data:a,dataType:"json"})};!function(e){"use strict";if(document.querySelector("#wpbackitup-core-backup"))var a=new Vue({el:"#wpbackitup-core-backup",data:{cloudStatus:{},isNewRowAvailable:!1,backupNewRow:{}},methods:{getAvailableBackups:function(){AjaxGetCore("get_available_backups").then(function(e){if(e.success)for(var t=0;t<e.data.length;t++){var i=e.data[t].backup_job_id,s=e.data[t].backup_job_cloud_status;a.$set(a.cloudStatus,i,s)}})},getBackupStatus:function(){var e=WPBNewBackupData;if("success"===e.backupStatus){var a=e.backupName,t=a.lastIndexOf("_"),i=a.substring(t+1);this.isNewRowAvailable=!0,this.backupNewRow={name:e.backupName,type:e.backupRuntype,date:e.backupDate,duration:e.backupDuration,status:e.backupStatus,row:99999,jobId:i,zipExist:!0},WPBNewBackupData={}}}},mounted:function(){this.getAvailableBackups(),this.getBackupStatusInterval=setInterval(function(){0!==Object.keys(WPBNewBackupData).length&&this.getBackupStatus()}.bind(this),1e3),this.getAvailableBackupsInterval=setInterval(function(){this.getAvailableBackups()}.bind(this),3e3)},beforeDestroy:function(){clearInterval(this.getAvailableBackupsInterval),clearInterval(this.getBackupStatusInterval)}})}(jQuery),function(e){function a(){e(".viewloglink").click(function(){var a=e(this).attr("href");return e("#backup_name").val(a),e("#viewlog").submit(),!1})}function t(){e(".downloadbackuplink").bind("click",function(){var a=e(this).attr("href");return e("#backup_file").val(a),e(this).append('<i class="fa fa-check"></i>'),e(this).css({color:"green"}),e("#download_backup").submit(),!1})}function i(a,i){var n=({action:f("backup_zip_filelist"),job_id:a},i.replace(/[^A-Za-z0-9\-]/g,"")),o=0,c="",l='<div id="'+n+'"> <h2>'+wpbackitup_local.bl_backup_set+" <em>"+i+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button><span id="wpbiu-note-response">'+wpbackitup_local.bl_note_saved_success+"</span></div> <p>"+wpbackitup_local.bl_backup_download+'</p> <table class="widefat" id="datatable"> <tbody>';e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_zip_filelist"),job_id:a},dataType:"json"}).done(function(i){i.data?(e.each(i.data,function(){var a=e(this)[0].name.split(/[\/]+/).pop(),t=e(this)[0].size,i=e(this)[0].file_exists;if(console.log(a,t),a.indexOf("-backupset-")>-1)c='<p><a class="downloadbackuplink" href="'+a+'"><i class="fa fa-cloud-download fa-3x"></i> <strong>'+wpbackitup_local.bl_backup_download_single+"</strong></a> <br><em>"+wpbackitup_local.bl_please_note+t+wpbackitup_local.bl_may_timeout+"</em></p>";else{o++;var s="";o%2!=0&&(s="alternate"),l+='<tr class="'+s+'" id="row'+o+'">',l+=i?'<td><a class="downloadbackuplink" href="'+a+'">'+a+"</a></td>":"<td>"+a+"</td>",l+="<td>"+t+"</td> </tr>"}}),l+=c+"</tbody></table></div>",e("#TB_ajaxContent").html(l),t(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-note-box").val(a.data)}}),e("#wpbiu-note-btn").click(function(){var t=e("#wpbiu-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-note-response").fadeIn()})}),e("#wpbiu-note-box").focus(function(){e("#wpbiu-note-response").hide()})):s(i,null,null)}).fail(function(e,a,t){s(e,a,t)})}function s(e,a,t){var i="Error-Invalid response from server: ";a&&(i+=a+"\n"),t&&(i+=t+"\n"),i+="\nResponse: \n\n"+JSON.stringify(e),alert(i)}function n(){var a={action:f("restore_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),e(a).find(".isa_error").fadeIn(1500),clearInterval(window.intervalDefine)),e(this).html()==-2&&e(a).find(".isa_warning").fadeIn(1500),99==e(this).html()&&(e(a).find(".isa_success").fadeIn(1500),clearInterval(window.intervalDefine))})})}function o(){var a={action:f("backup_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){if(x)return clearInterval(window.intervalDefine),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").fadeOut(200),e(".backup-cancelled").fadeIn(200),!1;var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),clearInterval(window.intervalDefine),c()),e(this).html()==-2&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".wpbackitup-warning").fadeIn(1500)),99==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500),clearInterval(window.intervalDefine),c())})})}function c(){var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_response_reader")},dataType:"json"});a.always(function(a,t,i){if(console.log("Backup Response:"+JSON.stringify(a)),"undefined"!=typeof a.backupStatus&&"undefined"!=typeof a.backupMessage){if(console.log("JSON Backup Status:"+a.backupStatus),console.log("JSON Backup Message:"+a.backupMessage),y)return;switch(y=!0,a.backupStatus){case"success":if(console.log("JSON success response received."),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden"),e(".isa_success").show,e(".backup-success").fadeIn(1500),_(a),"undefined"!=typeof a.backupWarnings){var s=e(".backup-warning"),n=a.backupWarnings;n.forEach(function(e){var a=e.warningMessage;s.append('<li class="isa_warning">'+wpbackitup_local.warning+": "+a+"</li>")}),s.fadeIn(1500)}break;case"error":console.log("JSON error response received.");var o=wpbackitup_local.unexpected_err;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+": "+o,l=e(".backup-error");l.html(c),l.addClass("isa_error"),l.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden");break;default:console.log("Unexpected JSON response status received.");var o=wpbackitup_local.unexpected_err2;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+"(JS998) : "+o,u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden")}}else{console.log("NON JSON response received."),console.log("Backup Response:"+i),c=wpbackitup_local.unexpected_err3+": ",c+="</br>"+wpbackitup_local.response+": "+JSON.stringify(a),c+="</br>"+wpbackitup_local.status+": "+t,c+="</br>"+wpbackitup_local.error+": "+JSON.stringify(i),e(".backup-status").hide();var u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.show(),e(".status-icon").fadeOut(200)}})}function l(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-success").hide(),e(".default-status").hide(),e(".backup-error").hide(),e(".backup-cancelled").hide(),e("ul.backup-status").children().children().hide(),e(".backup-errors").children().children().hide(),e(".backup-success").children().children().hide(),e(".backup-status").show(),y=!1,window.intervalDefine=setInterval(o,5e3)}function u(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-status").show(),y=!1,clearInterval(window.intervalDefine),window.intervalDefine=setInterval(o,5e3)}function r(){e(".restore-icon").css("visibility","visible"),e(".default-status, .upload-status").hide(),e("ul.restore-status").children().children().hide(),e(".restore-errors").children().children().hide(),e(".restore-success").children().children().hide(),e(".restore-status, .restore-errors, .restore-success").show(),e(".preparing-icon").css("visibility","visible"),e(".preparing").find(".status-icon").fadeIn(1500),window.intervalDefine=setInterval(n,5e3)}function p(a){var t=new plupload.Uploader(a);t.init(),t.bind("FilesAdded",function(a,t){plupload.each(t,function(a){e("#filelist").append('<div id="media-item-'+a.id+'" class="media-item child-of-0"><img class="pinkynail" alt="" src="'+site_url+'/wp-includes/images/media/archive.png"><div class="filename new" id="'+a.id+'">'+a.name+" (<span>"+plupload.formatSize(0)+"</span> of "+plupload.formatSize(a.size)+') <div class="progress" style="width: 0%;"></div></div></div>')}),a.refresh(),a.start()}),t.bind("UploadProgress",function(a,t){e("#"+t.id+" .progress").width(.15*t.percent+"%"),e("#"+t.id+" span").html(plupload.formatSize(parseInt(t.size*t.percent/100)))}),t.bind(" ChunkUploaded",function(e,a,t){console.log("Chunk Uploaded:"),console.log(t),d(t,e,a)&&console.log("chunk error")}),t.bind("Error",function(a,t){console.log("PlUpload Error:"),console.log(t);var i="error-item-"+t.file.id;e("#"+i).length||e("#filelist").append('<div class="error-div error" id="'+i+'" ><strong>'+t.file.name+" has failed to upload due to error: </strong> <span>"+t.message+"</span> </div>")}),t.bind("FileUploaded",function(a,t,i){console.log("File Uploaded"),console.log(i),d(i,a,t)?console.log("uploaded error"):(console.log("uploaded success"),e("#"+t.id+" .progress").css("background-color","green"),e("#import-uploads").show())})}function d(e,a,t){if("200"!=e.status)return alert("Unknown server response status: "+e.code),console.log(e),b(a,t,999,e.response),!0;try{return response_json=jQuery.parseJSON(e.response),!!response_json.error&&(b(a,t,100,response_json.error),!0)}catch(i){return console.log("Unexpected JSON Error"+i),b(a,t,998,e.response),!0}}function b(a,t,i,s){t.status=plupload.FAILED,a.trigger("Error",{code:i,message:s,file:t}),e("#media-item-"+t.id).hide()}function _(i){"undefined"!=typeof i&&(WPBNewBackupData=i,e("#nofiles")&&e("#nofiles").remove(),a(),t())}function f(e){return w+"_"+e}function k(){notification_bar=e("#wp-backitup-notification-parent"),notification_bar.fadeOut("slow")}function h(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("error",!1),notification_bar.toggleClass("updated",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}function g(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("updated",!1),notification_bar.toggleClass("error",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}var w="wp-backitup",v=0;a(),t();try{"undefined"!=typeof wpbackitup_plupload_config&&p(wpbackitup_plupload_config)}catch(m){console.log(m)}e(".logs_backup").click(function(){var a=e(this).attr("href");return e("#backup_file").val(a),e("#download_logs").val(),e("#download_backup").submit(),!1}),e("#scheduled-backups-accordian").click(function(){scheduled_backups=e("#scheduled-backups"),scheduled_backups_button=e("#scheduled-backups-accordian"),e(this).is(".fa-angle-double-down")?(scheduled_backups.fadeIn("slow"),scheduled_backups_button.toggleClass("fa-angle-double-down",!1),scheduled_backups_button.toggleClass("fa-angle-double-up",!0)):(scheduled_backups_button.toggleClass("fa-angle-double-down",!0),scheduled_backups_button.toggleClass("fa-angle-double-up",!1),scheduled_backups.fadeOut("slow"))}),e("#upload-backups-accordian").click(function(){upload_backups=e("#wpbackitup-plupload-modal"),upload_backups_button=e("#upload-backups-accordian"),e(this).is(".fa-angle-double-down")?(upload_backups.fadeIn("slow"),upload_backups_button.toggleClass("fa-angle-double-down",!1),upload_backups_button.toggleClass("fa-angle-double-up",!0)):(upload_backups_button.toggleClass("fa-angle-double-down",!0),upload_backups_button.toggleClass("fa-angle-double-up",!1),upload_backups.fadeOut("slow"))}),e("#wpbackitup-zip").bind("change",function(){var a=this.files[0].size,t=e("#maxfilesize").val();"undefined"!=a&&"undefined"!=t&&""!=a&&""!=t&&a>t&&(alert(wpbackitup_local.upload_file_size_exceed),e("#wpbackitup-zip").val(""))}),e("#import-uploads").click(function(){setTimeout(function(){window.location.reload()},100)}),e(document.body).on("click",".thickbox",function(){if(!e(this).parents(".wpbiu-restore-item").length){var a=e(this).data("jobid");console.log(a);var t=this.name;i(a,t)}}),e(document.body).on("click",".thickbox",function(){var a=e(this).data("jobid"),t=e(this).attr("name");if(e(this).parents(".wpbiu-restore-item").length){var i="<h2>"+wpbackitup_local.bl_backup_set+" <em>"+t+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-restore-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-restore-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button> <span id="wpbiu-restore-note-response">'+wpbackitup_local.bl_note_saved_success+"</span> </div>";e("#wpbiu-restore-note").html(i),e("#wpbiu-restore-note-response").hide(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-restore-note-box").val(a.data)}}),e("#wpbiu-restore-note-btn").click(function(){var t=e("#wpbiu-restore-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-restore-note-response").fadeIn()})})}e("#wpbiu-restore-note-box").focus(function(){e("#wpbiu-restore-note-response").hide()})});var y=!1;e("#wp-backitup-notification-widget-close").click(function(){notification_bar=e("#wp-backitup-notification-widget"),notification_bar.fadeOut("slow");var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("delete_transient")},dataType:"json"});a.always(function(a,t,i){a!==!1&&(notification_bar.removeClass(),notification_bar.addClass("notice"),notification_bar.addClass("notice-"+a.message_type),e("#wp-backitup-notification-widget-message p").html(a.message),notification_bar.hide().fadeIn("slow"))})}),e("#wp-backitup-notification-close").click(function(){k()}),e("#wp-backitup-save_schedule_form").submit(function(){var a=new FormData;a.append("action",f("update-schedule")),a.append("_wpnonce",e("#wp-backitup_nonce-update-schedule").val()),a.append("_wp_http_referer",e("[name='_wp_http_referer']").val());var t=[];return e.each(e("input[name='dow']:checked"),function(){t.push(e(this).val())}),a.append("days_selected",t),jQuery.ajax({url:ajaxurl,type:"POST",cache:!1,contentType:!1,processData:!1,dataType:"json",data:a,success:function(e,a,t){switch(response=e.message,console.log("Success:"+response),response){case"success":h(wpbackitup_local.scheduled_saved);break;case"error":g(wpbackitup_local.scheduled_not_saved)}},error:function(e,a,t){console.log("Error."+a+":"+t)},complete:function(e,a){console.log("Complete")}}),!1});var j=null;e(".backup-button").click(function(a){a.preventDefault(),x=!1,e("#backup-button").attr("disabled","disabled"),e("#cancel-button").removeClass("cancel-hidden"),e("#cancel-button").removeAttr("disabled"),e("#cancel-button").fadeIn(200),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup")},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),l()}}),j.always(function(e,a,t){console.log("Backup Button Click - Always"),console.log(e.message),"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})});var x=!1;e(".cancel-button").click(function(a){a.preventDefault(),e("#cancel-button").attr("disabled","disabled"),null!=j&&(j.abort(),j=null),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("cancel_backup"),job_id:v},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),u()}}),j.always(function(e,a,t){console.log("Cancel Button Click - Always"),console.log(e),"undefined"!=typeof e.success&&1==e.success?console.log("Job Cancelled successfully"):console.log("Job was not cancelled successfully"),x=!0})}),e("#datatable").on("click","a.restoreRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.confirm_restore)){var t=this.title;this.id.replace("restoreRow","row");userid=e("input[name=user_id]").val();var i=e.ajax({url:ajaxurl,type:"post",data:{action:f("restore"),selected_file:t,user_id:userid},cache:!1,dataType:"json",beforeSend:function(){console.log("BeforeSend:Nothing to report."),r()}});i.always(function(e,a,t){"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})}}),e("#datatable").on("click","a.deleteRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.sure)){var t=this.title,i=e(this).data("id"),s=this.id.replace("deleteRow","row");e.ajax({url:ajaxurl,type:"post",data:{action:f("delete_file"),filed:t,post_id:i},success:function(a){var t=a.search("deleted");0==t?e("#"+s).remove():alert(wpbackitup_local.file_not_del)}})}})}(jQuery),function(e){"use strict";var a="wp-backitup",t=function(e){return a+"_"+e},i=function(a){return e.ajax({url:ajaxurl,type:"GET",data:{action:t(a)},dataType:"json"})},s=function(a,i){var i=i||{};return i.action=t(a),i.security=e("#wpbackitup-core-ajax-nonce").val(),e.ajax({url:ajaxurl,type:"POST",data:i,dataType:"json"})};e(window).load(function(){if(document.querySelector("#wpbackitup-core-settings")){Vue.use(VueTabs);var e=new Vue({el:"#wpbackitup-core-settings",data:{loading:!1,updated:!1,emailsArray:[],errorMessages:{},backup_retained_number:3,logging:!1,single_file_db:!1,single_file_backupset:!1,rversion_compare:!1,remove_supporting_zip_files:!1,backup_plugins_filter:[],backup_themes_filter:[],backup_uploads_filter:[],backup_others_filter:[],dbFilterOptions:[],db_filters:[],allow_usage_tracking:!1,backup_dbtables_batch_size:1e4,backup_sql_merge_batch_size:1e4,backup_sql_batch_size:1e4,backup_plugins_batch_size:5e3,backup_themes_batch_size:5e3,backup_uploads_batch_size:500,backup_others_batch_size:500,backup_zip_max_size:524288e3,backup_max_timeout:120,delete_all:!1,safe_sync:!1},computed:{dbFilterHasSearch:function(){return 0==this.dbFilterOptions.length},dbFilterPlaceholder:function(){return this.dbFilterOptions.length>0?wpbackitup_local.settings_select_database_table_to_filter:wpbackitup_local.settings_no_database_table_to_filter}},methods:{handleEmailInput:function(e){},handleTagsInput:function(e){},setSettings:function(){var a={data:{notification_email:this.emailsArray.join(","),backup_retained_number:this.backup_retained_number,logging:this.logging,single_file_db:this.single_file_db,single_file_backupset:this.single_file_backupset,rversion_compare:this.rversion_compare,remove_supporting_zip_files:this.remove_supporting_zip_files,backup_plugins_filter:this.backup_plugins_filter.join(","),backup_themes_filter:this.backup_themes_filter.join(","),backup_uploads_filter:this.backup_uploads_filter.join(","),backup_others_filter:this.backup_others_filter.join(","),backup_dbtables_filter_list:this.db_filters.map(function(e){return e.value}).join(","),backup_dbtables_batch_size:this.backup_dbtables_batch_size,backup_sql_merge_batch_size:this.backup_sql_merge_batch_size,backup_sql_batch_size:this.backup_sql_batch_size,backup_plugins_batch_size:this.backup_plugins_batch_size,backup_themes_batch_size:this.backup_themes_batch_size,backup_uploads_batch_size:this.backup_uploads_batch_size,backup_others_batch_size:this.backup_others_batch_size,backup_zip_max_size:this.backup_zip_max_size,backup_max_timeout:this.backup_max_timeout,delete_all:this.delete_all,safe_sync:this.safe_sync,allow_usage_tracking:this.allow_usage_tracking}};console.log(a),s("set_settings",a).then(function(a){a.success?(e.updated=!0,e.errorMessages={},swal(wpbackitup_local.settings_save_awesome,wpbackitup_local.settings_save_success_message,"success")):(e.errorMessages=a.data,swal(wpbackitup_local.settings_save_oops,wpbackitup_local.settings_save_error_message,"error"))})},getSettings:function(){this.loading=!0,i("get_settings").then(function(a){e.loading=!1,a.success&&(console.log(a),e.emailsArray=a.data.notification_email.split(",").filter(Boolean),e.backup_retained_number=a.data.backup_retained_number,e.logging="1"===a.data.logging,e.single_file_db="1"===a.data.single_file_db,e.rversion_compare="1"===a.data.rversion_compare,e.single_file_backupset="1"===a.data.single_file_backupset,e.remove_supporting_zip_files="1"===a.data.remove_supporting_zip_files,e.backup_plugins_filter=a.data.backup_plugins_filter.split(",").filter(Boolean),e.backup_themes_filter=a.data.backup_themes_filter.split(",").filter(Boolean),e.backup_uploads_filter=a.data.backup_uploads_filter.split(",").filter(Boolean),e.backup_others_filter=a.data.backup_others_filter.split(",").filter(Boolean),e.db_filters=a.data.backup_dbtables_filter_list.split(",").filter(Boolean).map(function(e){return{label:e,value:e}}),e.dbFilterOptions=Object.keys(a.data.backup_dbtables_filterable).map(function(e){var t=a.data.backup_dbtables_filterable[e];return{label:t,value:t}}),e.allow_usage_tracking=a.data.allow_usage_tracking,e.backup_dbtables_batch_size=a.data.backup_dbtables_batch_size,e.backup_sql_merge_batch_size=a.data.backup_sql_merge_batch_size,e.backup_sql_batch_size=a.data.backup_sql_batch_size,e.backup_plugins_batch_size=a.data.backup_plugins_batch_size,e.backup_themes_batch_size=a.data.backup_themes_batch_size,e.backup_uploads_batch_size=a.data.backup_uploads_batch_size,e.backup_others_batch_size=a.data.backup_others_batch_size,e.backup_zip_max_size=a.data.backup_zip_max_size,e.backup_max_timeout=a.data.backup_max_timeout,e.delete_all="1"===a.data.delete_all,e.safe_sync="1"===a.data.safe_sync)})}},created:function(){this.getSettings()}})}})}(jQuery);
|
lib/includes/class-admin-notices.php
CHANGED
@@ -40,9 +40,9 @@ if ( ! class_exists( 'WPBackitup_Admin_Notices' ) ) {
|
|
40 |
private function get_active_promo() {
|
41 |
|
42 |
//Is the independence day sale active?
|
43 |
-
if ( false !== $this->get_indepence_day_promo_id()) {
|
44 |
-
return $this->INDEPENDENCE_DAY_PROMO;
|
45 |
-
}
|
46 |
|
47 |
//Is the safe beta promo active
|
48 |
// if ( false !== $this->get_safe_beta_notice_id()) {
|
40 |
private function get_active_promo() {
|
41 |
|
42 |
//Is the independence day sale active?
|
43 |
+
// if ( false !== $this->get_indepence_day_promo_id()) {
|
44 |
+
// return $this->INDEPENDENCE_DAY_PROMO;
|
45 |
+
// }
|
46 |
|
47 |
//Is the safe beta promo active
|
48 |
// if ( false !== $this->get_safe_beta_notice_id()) {
|
lib/includes/class-job-scheduler.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (!defined ('ABSPATH')) die('No direct access allowed');
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WP BackItUp - Job Scheduler Class
|
5 |
+
*
|
6 |
+
* @package WP BackItUp
|
7 |
+
* @author Chris Simmons <chris.simmons@wpbackitup.com>
|
8 |
+
* @link http://www.wpbackitup.com
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
|
12 |
+
class WPBackItUp_Job_Scheduler {
|
13 |
+
|
14 |
+
private $log_name;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
+
*/
|
19 |
+
function __construct() {
|
20 |
+
try {
|
21 |
+
|
22 |
+
$this->log_name = 'debug_job_scheduler';//default log name
|
23 |
+
|
24 |
+
} catch(Exception $e) {
|
25 |
+
error_log($e);
|
26 |
+
WPBackItUp_Logger::log_error($this->log_name,__METHOD__,'Constructor Exception: ' .$e);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Destructor
|
32 |
+
*/
|
33 |
+
function __destruct() {
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Check the backup schedule to determine if the backup
|
39 |
+
* task should be run today.
|
40 |
+
*
|
41 |
+
* @return bool
|
42 |
+
*/
|
43 |
+
public function is_backup_scheduled(){
|
44 |
+
WPBackItUp_Logger::log($this->log_name,'**Check Backup Schedule**');
|
45 |
+
|
46 |
+
try {
|
47 |
+
// $wpbackitup_license = new WPBackItUp_License();
|
48 |
+
|
49 |
+
// ///ONLY active premium get this feature
|
50 |
+
// if (! $wpbackitup_license->is_premium_license()) {
|
51 |
+
// WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'No premium license.');
|
52 |
+
// return false;
|
53 |
+
// }
|
54 |
+
//
|
55 |
+
// ///ONLY work for 30 days after expiration
|
56 |
+
// if ($wpbackitup_license->is_license_30_days_past_expire()){
|
57 |
+
// WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'License expired 30 days ago');
|
58 |
+
// return false;
|
59 |
+
// }
|
60 |
+
|
61 |
+
|
62 |
+
//Get days scheduled to run on.
|
63 |
+
$scheduled_dow = $this->get_backup_schedule();
|
64 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Scheduled Days of week: ' .$scheduled_dow); //1=monday, 2=tuesday..
|
65 |
+
|
66 |
+
//What is the current day of the week
|
67 |
+
$current_datetime = current_time( 'timestamp' );
|
68 |
+
$current_date = date("Ymd",$current_datetime);
|
69 |
+
$current_dow = date("N",$current_datetime); //1=monday
|
70 |
+
|
71 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Current Date time:' . date( 'Y-m-d H:i:s',$current_datetime));
|
72 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Current Day of Week:' . $current_dow );
|
73 |
+
|
74 |
+
// Removing cache.
|
75 |
+
wp_cache_delete ( 'alloptions', 'options' );
|
76 |
+
|
77 |
+
//Get Last RUN date
|
78 |
+
$lastrun_datetime = WPBackItUp_Utility::get_option('backup_lastrun_date');
|
79 |
+
|
80 |
+
//Testing Only - need to add time and test for constant doesnt exist
|
81 |
+
if (defined ('WPBACKITUP__TEST_RUN_HOURLY') && WPBACKITUP__TEST_RUN_HOURLY===true && $current_datetime>=$lastrun_datetime+3600) {
|
82 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Run scheduled backup hourly');
|
83 |
+
return true;
|
84 |
+
}
|
85 |
+
|
86 |
+
$lastrun_date = date("Ymd",$lastrun_datetime);
|
87 |
+
$lastrun_dow =0;//0=none
|
88 |
+
if ($lastrun_datetime!=-2147483648){// 1901-12-13:never run
|
89 |
+
$lastrun_dow = date("N",$lastrun_datetime);
|
90 |
+
}
|
91 |
+
|
92 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Last Run Date Time:' . date( 'Y-m-d H:i:s',$lastrun_datetime));
|
93 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Last Run Day of Week:' . $lastrun_dow);
|
94 |
+
|
95 |
+
|
96 |
+
//Did backup already run today
|
97 |
+
if ($current_date==$lastrun_date){
|
98 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Backup already ran today');
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
+
//Should it run on this day of the week
|
103 |
+
if (false===strpos($scheduled_dow,$current_dow)){
|
104 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Not scheduled for: ' .$current_dow);
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Backup should be run now.');
|
109 |
+
return true;
|
110 |
+
|
111 |
+
}catch(Exception $e) {
|
112 |
+
WPBackItUp_Logger::log_error($this->log_name,__METHOD__,'Exception: ' .$e);
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Save the days selected and add cron job if needed
|
120 |
+
*
|
121 |
+
* @param $days_selected
|
122 |
+
*
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
public function save_backup_schedule($days_selected) {
|
126 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__, 'Save Schedule');
|
127 |
+
WPBackItUp_Logger::log($this->log_name,$days_selected);
|
128 |
+
|
129 |
+
//save option to DB even if empty
|
130 |
+
$rtn = $this->set_backup_schedule($days_selected);
|
131 |
+
|
132 |
+
//Add backup scheduled if doesnt exist
|
133 |
+
if(!wp_next_scheduled( 'wpbackitup_queue_scheduled_jobs' ) ){
|
134 |
+
wp_schedule_event( time()+3600, 'hourly', 'wpbackitup_queue_scheduled_jobs');
|
135 |
+
}
|
136 |
+
|
137 |
+
return $rtn;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Job Schedule Filter
|
142 |
+
*
|
143 |
+
* @param $jobs
|
144 |
+
*
|
145 |
+
* @return array
|
146 |
+
*/
|
147 |
+
public function jobs_scheduled($jobs) {
|
148 |
+
|
149 |
+
if (true === $this->is_backup_scheduled()){
|
150 |
+
$jobs[] = "backup";
|
151 |
+
}
|
152 |
+
|
153 |
+
//Add additional scheduled jobs here.
|
154 |
+
|
155 |
+
return $jobs;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Getter- Get backup schedule
|
160 |
+
*
|
161 |
+
* @return mixed
|
162 |
+
*/
|
163 |
+
public function get_backup_schedule(){
|
164 |
+
return WPBackItUp_Utility::get_option('backup_schedule','');
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Setter- Set backup schedule
|
169 |
+
*
|
170 |
+
* @return mixed
|
171 |
+
*/
|
172 |
+
public function set_backup_schedule($value){
|
173 |
+
WPBackItUp_Utility::set_option('backup_schedule',$value);
|
174 |
+
}
|
175 |
+
}
|
lib/includes/class-license.php
CHANGED
@@ -26,19 +26,25 @@ class WPBackItUp_License {
|
|
26 |
private $customer_name=null;
|
27 |
private $license_expires_date=null;
|
28 |
private $license_last_check_date=null;
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
//Default license property values
|
31 |
private static $defaults = array(
|
32 |
-
'license_key' => "
|
33 |
'license_last_check_date'=> "1970-01-01 00:00:00",
|
34 |
'license_status' => "",
|
35 |
'license_status_message'=> "",
|
36 |
-
'license_type' => "
|
37 |
'license_expires'=> "1970-01-01 00:00:00",
|
38 |
'license_limit'=> "1",
|
39 |
'license_sitecount'=> "",
|
40 |
'license_customer_name' => "",
|
41 |
-
'license_customer_email' => ""
|
|
|
42 |
);
|
43 |
|
44 |
function __construct() {
|
@@ -57,8 +63,8 @@ class WPBackItUp_License {
|
|
57 |
|
58 |
/**
|
59 |
* Is license active
|
60 |
-
* - license key will be empty for unregistered
|
61 |
-
* - license key will contain free for
|
62 |
*
|
63 |
*/
|
64 |
public function is_license_active(){
|
@@ -168,7 +174,7 @@ class WPBackItUp_License {
|
|
168 |
/**
|
169 |
* Getter: Get license type or default
|
170 |
*
|
171 |
-
* @return string default
|
172 |
*/
|
173 |
public function get_license_type() {
|
174 |
|
@@ -180,14 +186,29 @@ class WPBackItUp_License {
|
|
180 |
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
/**
|
185 |
-
* Getter - Is
|
186 |
*
|
187 |
* @return bool
|
188 |
*/
|
189 |
-
function
|
190 |
-
if (
|
191 |
return true;
|
192 |
} else {
|
193 |
return false;
|
@@ -204,6 +225,9 @@ class WPBackItUp_License {
|
|
204 |
if (is_null($this->license_type_description)) {
|
205 |
|
206 |
switch ($this->get_license_type()) {
|
|
|
|
|
|
|
207 |
case 0:
|
208 |
$this->license_type_description = 'lite';
|
209 |
break;
|
@@ -272,23 +296,23 @@ class WPBackItUp_License {
|
|
272 |
*
|
273 |
* @param $license
|
274 |
*
|
275 |
-
* @param $
|
276 |
*
|
277 |
* @return bool|mixed
|
278 |
*/
|
279 |
-
public function activate_license($license, $
|
280 |
|
281 |
$request_data = array(
|
282 |
-
'license'
|
283 |
-
'
|
284 |
-
'url'
|
285 |
);
|
286 |
|
287 |
-
$license_data = $this->edd_license_api_request(
|
288 |
|
289 |
//if false try using site directly
|
290 |
if ( false === $license_data) {
|
291 |
-
WPBackItUp_Logger::log_error($this->log_name,__METHOD__, 'Unable to activate using Gateway -
|
292 |
$license_data= $this->edd_license_api_request(WPBACKITUP__SECURESITE_URL,'activate_license', $request_data);
|
293 |
}
|
294 |
|
@@ -296,33 +320,68 @@ class WPBackItUp_License {
|
|
296 |
|
297 |
}
|
298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
/**
|
300 |
-
*
|
|
|
301 |
*
|
302 |
-
* @
|
303 |
-
*
|
304 |
-
* @param $item_name
|
305 |
*
|
306 |
-
* @return bool|mixed
|
307 |
*/
|
308 |
-
public function check_license($
|
309 |
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
);
|
315 |
|
316 |
-
|
|
|
|
|
|
|
317 |
|
318 |
-
|
319 |
-
|
320 |
-
WPBackItUp_Logger::log_error($this->log_name,__METHOD__, 'Unable to activate using Gateway - attempting direct');
|
321 |
-
$license_data= $this->edd_license_api_request(WPBACKITUP__SECURESITE_URL,'activate_license', $request_data);
|
322 |
-
}
|
323 |
|
324 |
-
|
|
|
|
|
325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
}
|
327 |
|
328 |
/**
|
@@ -330,19 +389,19 @@ class WPBackItUp_License {
|
|
330 |
*
|
331 |
* @param $license
|
332 |
*
|
333 |
-
* @param $
|
334 |
*
|
335 |
* @return bool|mixed
|
336 |
*/
|
337 |
-
public function deactivate_license($license, $
|
338 |
|
339 |
$request_data = array(
|
340 |
-
'license'
|
341 |
-
'
|
342 |
-
'url'
|
343 |
);
|
344 |
|
345 |
-
$license_data = $this->edd_license_api_request(
|
346 |
|
347 |
//if false try using site directly
|
348 |
if ( false === $license_data) {
|
@@ -389,12 +448,45 @@ class WPBackItUp_License {
|
|
389 |
return false;
|
390 |
}
|
391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
/**
|
393 |
* Update ALL the license options
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
*/
|
395 |
-
public function update_license_options($license)
|
396 |
{
|
397 |
-
|
398 |
// Clearing any old notices
|
399 |
delete_transient( 'wpbackitup_admin_notices' );
|
400 |
|
@@ -418,17 +510,22 @@ class WPBackItUp_License {
|
|
418 |
$data['license_customer_name'] = $this->get_customer_name();
|
419 |
$data['license_customer_email'] = $this->get_customer_email();
|
420 |
|
421 |
-
|
422 |
-
|
|
|
|
|
|
|
423 |
$data['license_status'] = 'free';
|
424 |
$data['license_expires']= self::$defaults['license_expires'];
|
425 |
$data['license_limit']= 1;
|
426 |
$data['license_sitecount']= 1;
|
427 |
-
$data['license_type']=
|
428 |
} else {
|
429 |
|
|
|
430 |
//activate license using SSL
|
431 |
-
$license_data= $this->activate_license($license
|
|
|
432 |
|
433 |
if ( false === $license_data){
|
434 |
//update license last checked date and
|
@@ -471,6 +568,8 @@ class WPBackItUp_License {
|
|
471 |
$data['license_key'] = $license;
|
472 |
$data['license_status'] = $license_data->license;
|
473 |
|
|
|
|
|
474 |
if (property_exists($license_data,'error')) {
|
475 |
$data['license_status_message'] = $license_data->error;
|
476 |
}
|
@@ -482,24 +581,31 @@ class WPBackItUp_License {
|
|
482 |
$data['license_customer_name'] = $license_data->customer_name;
|
483 |
$data['license_customer_email'] = $license_data->customer_email;
|
484 |
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
|
|
|
|
|
|
502 |
}
|
|
|
|
|
|
|
|
|
503 |
}
|
504 |
|
505 |
// admin notices
|
@@ -525,7 +631,7 @@ class WPBackItUp_License {
|
|
525 |
)
|
526 |
);
|
527 |
|
528 |
-
// add scheduler
|
529 |
array_push($admin_notices,
|
530 |
array(
|
531 |
'message_type' => 'warning',
|
@@ -561,7 +667,7 @@ class WPBackItUp_License {
|
|
561 |
return true;
|
562 |
}
|
563 |
|
564 |
-
public function
|
565 |
$registration_logname='debug_registration';
|
566 |
$post_url = '/api/wpbackitup/register_lite';
|
567 |
|
@@ -570,8 +676,8 @@ class WPBackItUp_License {
|
|
570 |
} else {
|
571 |
$post_url = WPBACKITUP__SITE_URL . $post_url;
|
572 |
}
|
573 |
-
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, '
|
574 |
-
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, '
|
575 |
WPBackItUp_Logger::log($registration_logname,$form_data );
|
576 |
|
577 |
$response = wp_remote_post( $post_url, array(
|
@@ -586,12 +692,12 @@ class WPBackItUp_License {
|
|
586 |
|
587 |
if ( is_wp_error( $response ) ) {
|
588 |
$error_message = $response->get_error_message();
|
589 |
-
WPBackItUp_Logger::log_error($registration_logname,__METHOD__, '
|
590 |
|
591 |
return false;
|
592 |
|
593 |
} else {
|
594 |
-
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, '
|
595 |
WPBackItUp_Logger::log($registration_logname,$response );
|
596 |
|
597 |
return true;
|
@@ -615,22 +721,21 @@ class WPBackItUp_License {
|
|
615 |
$api_params = array(
|
616 |
'edd_action' => $action,
|
617 |
'license' => $request_data['license'],
|
618 |
-
'
|
619 |
'url' => $request_data['url']
|
620 |
);
|
621 |
-
|
622 |
WPBackItUp_Logger::log_info($this->log_name,__METHOD__, 'Activate License Request Info:');
|
623 |
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'API URL:' .$activation_url);
|
624 |
WPBackItUp_Logger::log($this->log_name,$api_params);
|
625 |
|
626 |
-
|
627 |
-
|
628 |
-
array( 'timeout' =>
|
629 |
-
|
630 |
-
|
631 |
);
|
632 |
-
WPBackItUp_Logger::log_info($this->log_name,__METHOD__, 'API Response:'. var_export( $response,true ));
|
633 |
|
|
|
634 |
|
635 |
$response_code = wp_remote_retrieve_response_code($response);
|
636 |
WPBackItUp_Logger::log_info($this->log_name,__METHOD__, 'Response Code:'. $response_code);
|
@@ -654,6 +759,4 @@ class WPBackItUp_License {
|
|
654 |
return false;
|
655 |
}
|
656 |
}
|
657 |
-
|
658 |
-
|
659 |
}
|
26 |
private $customer_name=null;
|
27 |
private $license_expires_date=null;
|
28 |
private $license_last_check_date=null;
|
29 |
+
private $license_product_id=null;
|
30 |
+
|
31 |
+
const PREMIUM_PRODUCT_ID =679;
|
32 |
+
const LITE_PRODUCT_ID =448151;
|
33 |
+
const SAFE_PRODUCT_ID =436624;
|
34 |
|
35 |
//Default license property values
|
36 |
private static $defaults = array(
|
37 |
+
'license_key' => "",
|
38 |
'license_last_check_date'=> "1970-01-01 00:00:00",
|
39 |
'license_status' => "",
|
40 |
'license_status_message'=> "",
|
41 |
+
'license_type' => "-1",
|
42 |
'license_expires'=> "1970-01-01 00:00:00",
|
43 |
'license_limit'=> "1",
|
44 |
'license_sitecount'=> "",
|
45 |
'license_customer_name' => "",
|
46 |
+
'license_customer_email' => "",
|
47 |
+
'license_product_id' => "ce",
|
48 |
);
|
49 |
|
50 |
function __construct() {
|
63 |
|
64 |
/**
|
65 |
* Is license active
|
66 |
+
* - license key will be empty for unregistered ce customers
|
67 |
+
* - license key will contain free for ce user license status
|
68 |
*
|
69 |
*/
|
70 |
public function is_license_active(){
|
174 |
/**
|
175 |
* Getter: Get license type or default
|
176 |
*
|
177 |
+
* @return string default -1
|
178 |
*/
|
179 |
public function get_license_type() {
|
180 |
|
186 |
|
187 |
}
|
188 |
|
189 |
+
/**
|
190 |
+
* Getter: Get license product id
|
191 |
+
*
|
192 |
+
* @return string
|
193 |
+
*/
|
194 |
+
public function get_license_product_id() {
|
195 |
+
|
196 |
+
if ( is_null($this->license_product_id)){
|
197 |
+
$this->license_product_id = WPBackItUp_Utility::get_option( 'license_product_id',self::$defaults['license_product_id'] );
|
198 |
+
}
|
199 |
+
|
200 |
+
return $this->license_product_id;
|
201 |
+
|
202 |
+
}
|
203 |
+
|
204 |
|
205 |
/**
|
206 |
+
* Getter - Is ce license registered
|
207 |
*
|
208 |
* @return bool
|
209 |
*/
|
210 |
+
function is_ce_registered(){
|
211 |
+
if (-1 == $this->get_license_type() && $this->get_customer_email()) {
|
212 |
return true;
|
213 |
} else {
|
214 |
return false;
|
225 |
if (is_null($this->license_type_description)) {
|
226 |
|
227 |
switch ($this->get_license_type()) {
|
228 |
+
case -1:
|
229 |
+
$this->license_type_description = 'community edition';
|
230 |
+
break;
|
231 |
case 0:
|
232 |
$this->license_type_description = 'lite';
|
233 |
break;
|
296 |
*
|
297 |
* @param $license
|
298 |
*
|
299 |
+
* @param $item_nid
|
300 |
*
|
301 |
* @return bool|mixed
|
302 |
*/
|
303 |
+
public function activate_license($license, $item_id){
|
304 |
|
305 |
$request_data = array(
|
306 |
+
'license' => $license,
|
307 |
+
'item_id' => $item_id,
|
308 |
+
'url' => home_url()
|
309 |
);
|
310 |
|
311 |
+
$license_data = $this->edd_license_api_request(WPBACKITUP__API_URL_V2, 'activate_license', $request_data);
|
312 |
|
313 |
//if false try using site directly
|
314 |
if ( false === $license_data) {
|
315 |
+
WPBackItUp_Logger::log_error($this->log_name,__METHOD__, 'Unable to activate using Gateway - attempting direct');
|
316 |
$license_data= $this->edd_license_api_request(WPBACKITUP__SECURESITE_URL,'activate_license', $request_data);
|
317 |
}
|
318 |
|
320 |
|
321 |
}
|
322 |
|
323 |
+
// /**
|
324 |
+
// * Check WPBackItUp License - dont think this is being used anywhere
|
325 |
+
// *
|
326 |
+
// * @param $license
|
327 |
+
// *
|
328 |
+
// * @param $item_id
|
329 |
+
// *
|
330 |
+
// * @return bool|mixed
|
331 |
+
// */
|
332 |
+
// public function check_license($license, $item_id){
|
333 |
+
//
|
334 |
+
// $request_data = array(
|
335 |
+
// 'license' => $license,
|
336 |
+
// 'item_id' => $item_id ,
|
337 |
+
// 'url' => home_url()
|
338 |
+
// );
|
339 |
+
//
|
340 |
+
// $license_data = $this->edd_license_api_request(WPBACKITUP__API_URL_V2, 'check_license', $request_data);
|
341 |
+
//
|
342 |
+
// //if false try using site directly
|
343 |
+
// if ( false === $license_data) {
|
344 |
+
// WPBackItUp_Logger::log_error($this->log_name,__METHOD__, 'Unable to activate using Gateway - attempting direct');
|
345 |
+
// $license_data= $this->edd_license_api_request(WPBACKITUP__SECURESITE_URL,'activate_license', $request_data);
|
346 |
+
// }
|
347 |
+
//
|
348 |
+
// return $license_data;
|
349 |
+
//
|
350 |
+
// }
|
351 |
+
|
352 |
/**
|
353 |
+
* Acion: Validate License Info
|
354 |
+
* - This is only used for PREMIUM and LITE plugins - not used in CE
|
355 |
*
|
356 |
+
* @since 1.24
|
|
|
|
|
357 |
*
|
|
|
358 |
*/
|
359 |
+
public function check_license($force_check=false){
|
360 |
|
361 |
+
//Get License Info
|
362 |
+
$license_key=$this->get_license_key();
|
363 |
+
$license_product_id=$this->get_license_product_id();
|
364 |
+
$license_type=$this->get_license_type();
|
|
|
365 |
|
366 |
+
//If there is no product id but the license type is premium then default product id
|
367 |
+
// error_log(var_export($license_key,true));
|
368 |
+
// error_log(var_export($license_product_id,true));
|
369 |
+
// error_log(var_export($license_type,true));
|
370 |
|
371 |
+
$license_last_check_date=$this->get_license_last_check_date();
|
372 |
+
//error_log('Last License Check:' . $license_last_check_date->format('Y-m-d H:i:s'));
|
|
|
|
|
|
|
373 |
|
374 |
+
$now = new DateTime('now');//Get NOW
|
375 |
+
$yesterday = $now->modify('-1 day');//subtract a day
|
376 |
+
//error_log('Yesterday:' .$yesterday->format('Y-m-d H:i:s'));
|
377 |
|
378 |
+
//Validate License
|
379 |
+
//error_log('Check:' . ($license_last_check_date<$yesterday || $force_check?'true' :'false') );
|
380 |
+
if ($license_last_check_date<$yesterday || $force_check)
|
381 |
+
{
|
382 |
+
//error_log('Checking license...');
|
383 |
+
$this->update_license_options($license_key,$license_product_id);
|
384 |
+
}
|
385 |
}
|
386 |
|
387 |
/**
|
389 |
*
|
390 |
* @param $license
|
391 |
*
|
392 |
+
* @param $item_id
|
393 |
*
|
394 |
* @return bool|mixed
|
395 |
*/
|
396 |
+
public function deactivate_license($license, $item_id){
|
397 |
|
398 |
$request_data = array(
|
399 |
+
'license' => $license,
|
400 |
+
'item_id' => $item_id,
|
401 |
+
'url' => home_url()
|
402 |
);
|
403 |
|
404 |
+
$license_data = $this->edd_license_api_request(WPBACKITUP__API_URL_V2, 'deactivate_license', $request_data);
|
405 |
|
406 |
//if false try using site directly
|
407 |
if ( false === $license_data) {
|
448 |
return false;
|
449 |
}
|
450 |
|
451 |
+
/**
|
452 |
+
* Customer has lite license
|
453 |
+
*
|
454 |
+
* @return bool
|
455 |
+
*/
|
456 |
+
public function is_lite_license(){
|
457 |
+
|
458 |
+
if (0==$this->get_license_type()){
|
459 |
+
return true;
|
460 |
+
}
|
461 |
+
|
462 |
+
return false;
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Customer has CE
|
467 |
+
*
|
468 |
+
* @return bool
|
469 |
+
*/
|
470 |
+
public function is_ce_license(){
|
471 |
+
|
472 |
+
if (-1==$this->get_license_type()){
|
473 |
+
return true;
|
474 |
+
}
|
475 |
+
|
476 |
+
return false;
|
477 |
+
}
|
478 |
+
|
479 |
/**
|
480 |
* Update ALL the license options
|
481 |
+
* Product ids
|
482 |
+
* 679 - Premium
|
483 |
+
* 448151 - Lite
|
484 |
+
* 436624 - Safe
|
485 |
+
*
|
486 |
+
*
|
487 |
*/
|
488 |
+
public function update_license_options($license,$product_id)
|
489 |
{
|
|
|
490 |
// Clearing any old notices
|
491 |
delete_transient( 'wpbackitup_admin_notices' );
|
492 |
|
510 |
$data['license_customer_name'] = $this->get_customer_name();
|
511 |
$data['license_customer_email'] = $this->get_customer_email();
|
512 |
|
513 |
+
$data['license_product_id'] = self::$defaults['license_product_id'];
|
514 |
+
|
515 |
+
//If no value then default to CE
|
516 |
+
if (empty($license)){
|
517 |
+
//error_log('empty_license');
|
518 |
$data['license_status'] = 'free';
|
519 |
$data['license_expires']= self::$defaults['license_expires'];
|
520 |
$data['license_limit']= 1;
|
521 |
$data['license_sitecount']= 1;
|
522 |
+
$data['license_type']= -1;
|
523 |
} else {
|
524 |
|
525 |
+
//error_log('activate license');
|
526 |
//activate license using SSL
|
527 |
+
$license_data= $this->activate_license($license,$product_id);
|
528 |
+
//error_log('here:' .var_export($license_data,true));
|
529 |
|
530 |
if ( false === $license_data){
|
531 |
//update license last checked date and
|
568 |
$data['license_key'] = $license;
|
569 |
$data['license_status'] = $license_data->license;
|
570 |
|
571 |
+
$data['license_product_id'] = $license_data->item_id;
|
572 |
+
|
573 |
if (property_exists($license_data,'error')) {
|
574 |
$data['license_status_message'] = $license_data->error;
|
575 |
}
|
581 |
$data['license_customer_name'] = $license_data->customer_name;
|
582 |
$data['license_customer_email'] = $license_data->customer_email;
|
583 |
|
584 |
+
$item_id = urldecode($license_data->item_id);
|
585 |
+
|
586 |
+
//Which product? - Would be better to use item ID when refactored
|
587 |
+
if (self::PREMIUM_PRODUCT_ID==$item_id) {
|
588 |
+
|
589 |
+
//This is how we determine the type of license because
|
590 |
+
//there is no difference in EDD
|
591 |
+
if ( is_numeric( $license_data->price_id ) ) {
|
592 |
+
|
593 |
+
switch ( $license_data->price_id ) {
|
594 |
+
case 0: //personal
|
595 |
+
$data['license_type'] = 1;
|
596 |
+
break;
|
597 |
+
case 1://professional
|
598 |
+
$data['license_type'] = 2;
|
599 |
+
break;
|
600 |
+
case 2://premium
|
601 |
+
$data['license_type'] = 3;
|
602 |
+
break;
|
603 |
+
}
|
604 |
}
|
605 |
+
} else if (self::LITE_PRODUCT_ID==$item_id) {
|
606 |
+
$data['license_type'] = 0;
|
607 |
+
} else {
|
608 |
+
$data['license_type'] = -1; //CE
|
609 |
}
|
610 |
|
611 |
// admin notices
|
631 |
)
|
632 |
);
|
633 |
|
634 |
+
// add scheduler stopped
|
635 |
array_push($admin_notices,
|
636 |
array(
|
637 |
'message_type' => 'warning',
|
667 |
return true;
|
668 |
}
|
669 |
|
670 |
+
public function register_ce($form_data,$use_ssl=true){
|
671 |
$registration_logname='debug_registration';
|
672 |
$post_url = '/api/wpbackitup/register_lite';
|
673 |
|
676 |
} else {
|
677 |
$post_url = WPBACKITUP__SITE_URL . $post_url;
|
678 |
}
|
679 |
+
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, 'CE User Registration Post URL: ' . $post_url );
|
680 |
+
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, 'CE User Registration Post Form Data: ' );
|
681 |
WPBackItUp_Logger::log($registration_logname,$form_data );
|
682 |
|
683 |
$response = wp_remote_post( $post_url, array(
|
692 |
|
693 |
if ( is_wp_error( $response ) ) {
|
694 |
$error_message = $response->get_error_message();
|
695 |
+
WPBackItUp_Logger::log_error($registration_logname,__METHOD__, 'CE User Registration Error: ' . $error_message );
|
696 |
|
697 |
return false;
|
698 |
|
699 |
} else {
|
700 |
+
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, 'CE User Registered Successfully:' );
|
701 |
WPBackItUp_Logger::log($registration_logname,$response );
|
702 |
|
703 |
return true;
|
721 |
$api_params = array(
|
722 |
'edd_action' => $action,
|
723 |
'license' => $request_data['license'],
|
724 |
+
'item_id' => $request_data['item_id'],
|
725 |
'url' => $request_data['url']
|
726 |
);
|
|
|
727 |
WPBackItUp_Logger::log_info($this->log_name,__METHOD__, 'Activate License Request Info:');
|
728 |
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'API URL:' .$activation_url);
|
729 |
WPBackItUp_Logger::log($this->log_name,$api_params);
|
730 |
|
731 |
+
// Call the custom API.
|
732 |
+
$response = wp_remote_post( $activation_url,
|
733 |
+
array( 'timeout' => 15,
|
734 |
+
'sslverify' => false,
|
735 |
+
'body' => $api_params )
|
736 |
);
|
|
|
737 |
|
738 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__, 'API Response:'. var_export( $response,true ));
|
739 |
|
740 |
$response_code = wp_remote_retrieve_response_code($response);
|
741 |
WPBackItUp_Logger::log_info($this->log_name,__METHOD__, 'Response Code:'. $response_code);
|
759 |
return false;
|
760 |
}
|
761 |
}
|
|
|
|
|
762 |
}
|
lib/includes/class-usage.php
CHANGED
@@ -140,10 +140,18 @@ class WPBackItUp_Usage {
|
|
140 |
|
141 |
/** Plugin Data Points **/
|
142 |
$data['wpbackitup_version'] = WPBACKITUP__VERSION;
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
$data['wpbackitup_backup_count'] = WPBackItUp_Utility::get_option( 'successful_backup_count' );
|
145 |
$data['wpbackitup_backup_last_run_date'] = date("Y-m-d",WPBackItUp_Utility::get_option( 'backup_lastrun_date' ));
|
146 |
|
|
|
147 |
$this->data = apply_filters('wpbackitup_ut_data',$data);
|
148 |
|
149 |
} catch (Exception $e) {
|
140 |
|
141 |
/** Plugin Data Points **/
|
142 |
$data['wpbackitup_version'] = WPBACKITUP__VERSION;
|
143 |
+
|
144 |
+
//Get license info if exists
|
145 |
+
$wpb_license = new WPBackItUp_License();
|
146 |
+
$data['wpbackitup_license_key'] =$wpb_license->get_license_key();
|
147 |
+
$data['wpbackitup_license_type'] =$wpb_license->get_license_type();
|
148 |
+
$data['wpbackitup_license_expires'] =$wpb_license->get_license_expires_date();
|
149 |
+
$data['wpbackitup_license_status'] =$wpb_license->get_license_status();
|
150 |
+
|
151 |
$data['wpbackitup_backup_count'] = WPBackItUp_Utility::get_option( 'successful_backup_count' );
|
152 |
$data['wpbackitup_backup_last_run_date'] = date("Y-m-d",WPBackItUp_Utility::get_option( 'backup_lastrun_date' ));
|
153 |
|
154 |
+
//get additional data if exists
|
155 |
$this->data = apply_filters('wpbackitup_ut_data',$data);
|
156 |
|
157 |
} catch (Exception $e) {
|
lib/includes/class-wpbackitup-admin.php
CHANGED
@@ -113,9 +113,15 @@ class WPBackitup_Admin {
|
|
113 |
*/
|
114 |
private function load_dependencies() {
|
115 |
|
|
|
|
|
|
|
116 |
//API Class
|
117 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-api.php';
|
118 |
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
/**
|
@@ -193,10 +199,17 @@ class WPBackitup_Admin {
|
|
193 |
//Create Daily backup action
|
194 |
add_action( 'wpbackitup_queue_scheduled_jobs', array( &$this,'wpbackitup_queue_scheduled_jobs'));
|
195 |
|
|
|
|
|
|
|
|
|
196 |
|
197 |
$api = new WPBackItUp_API();
|
198 |
add_action( $ajax_prefix. 'get_available_backups',array($api,'get_available_backups'));
|
199 |
|
|
|
|
|
|
|
200 |
|
201 |
}
|
202 |
|
@@ -452,14 +465,22 @@ class WPBackitup_Admin {
|
|
452 |
|
453 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
|
454 |
WPBackItUp_Logger::log_info($wpbdebug_logname,__METHOD__,'Update Options Form Post');
|
455 |
-
|
|
|
456 |
}
|
457 |
|
458 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-register" ) ) {
|
|
|
459 |
WPBackItUp_Logger::log_info($wpbdebug_logname,__METHOD__,'Register Lite Form Post');
|
460 |
$this->_admin_register();
|
461 |
}
|
462 |
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-update-schedule" ) ) {
|
464 |
WPBackItUp_Logger::log_info($wpbdebug_logname,__METHOD__,'Update Schedule Form Post');
|
465 |
|
@@ -512,7 +533,7 @@ class WPBackitup_Admin {
|
|
512 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-job-task.php' );
|
513 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-job-item.php' );
|
514 |
|
515 |
-
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-license.php' );
|
516 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-cleanup.php' );
|
517 |
|
518 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-cron.php' );
|
@@ -530,7 +551,6 @@ class WPBackitup_Admin {
|
|
530 |
//Admin Bar
|
531 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-admin-bar.php' );
|
532 |
|
533 |
-
|
534 |
$languages_path = dirname(dirname(dirname( plugin_basename( __FILE__ )))) . '/languages/';
|
535 |
|
536 |
load_plugin_textdomain(
|
@@ -1212,48 +1232,50 @@ class WPBackitup_Admin {
|
|
1212 |
* Process update page form submissions and validate license key
|
1213 |
*
|
1214 |
*/
|
1215 |
-
public function _admin_options_update() {
|
1216 |
-
// Verify submission for processing using wp_nonce
|
1217 |
-
if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
|
1218 |
-
|
1219 |
-
/**
|
1220 |
-
* Loop through each POSTed value and sanitize it to protect against malicious code. Please
|
1221 |
-
* note that rich text (or full HTML fields) should not be processed by this function and
|
1222 |
-
* dealt with directly.
|
1223 |
-
*/
|
1224 |
-
|
1225 |
-
$debug_logname='wpb_debug';
|
1226 |
-
WPBackItUp_Logger::log_info($debug_logname,__METHOD__, 'Posted Fields');
|
1227 |
-
WPBackItUp_Logger::log($debug_logname, $_POST['data']); //License will not be in this array
|
1228 |
-
|
1229 |
-
$wpbackitup_license = new WPBackItUp_License();
|
1230 |
-
foreach( $_POST['data'] as $key => $val ) {
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
|
|
|
|
1257 |
|
1258 |
|
1259 |
/***
|
@@ -1643,71 +1665,66 @@ class WPBackitup_Admin {
|
|
1643 |
*
|
1644 |
*/
|
1645 |
public function _admin_register() {
|
1646 |
-
// Verify submission for processing using wp_nonce
|
1647 |
-
if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-register" ) ) {
|
1648 |
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
* dealt with directly.
|
1653 |
-
*/
|
1654 |
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
|
1659 |
-
|
1660 |
-
|
1661 |
-
$license_key = $this->_sanitize($val);
|
1662 |
|
1663 |
-
|
1664 |
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
|
1669 |
-
|
1670 |
-
|
1671 |
|
1672 |
-
|
1673 |
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
|
1680 |
-
|
1681 |
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
|
1695 |
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
}
|
1703 |
}
|
1704 |
}
|
1705 |
}
|
1706 |
-
|
1707 |
-
// Redirect back to the options page with the message flag to show the saved message
|
1708 |
-
wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
|
1709 |
-
exit;
|
1710 |
}
|
|
|
|
|
|
|
|
|
|
|
1711 |
}
|
1712 |
|
1713 |
|
@@ -1820,7 +1837,10 @@ class WPBackitup_Admin {
|
|
1820 |
$wpbackitup_license = new WPBackItUp_License();
|
1821 |
|
1822 |
switch ($wpbackitup_license->get_license_type()) {
|
1823 |
-
|
|
|
|
|
|
|
1824 |
$this->backup_retained_number=1;
|
1825 |
break;
|
1826 |
case 1: //Personal
|
113 |
*/
|
114 |
private function load_dependencies() {
|
115 |
|
116 |
+
//Scheduler Class
|
117 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-job-scheduler.php';
|
118 |
+
|
119 |
//API Class
|
120 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-api.php';
|
121 |
|
122 |
+
//License Class
|
123 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-license.php';
|
124 |
+
|
125 |
}
|
126 |
|
127 |
/**
|
199 |
//Create Daily backup action
|
200 |
add_action( 'wpbackitup_queue_scheduled_jobs', array( &$this,'wpbackitup_queue_scheduled_jobs'));
|
201 |
|
202 |
+
//add scheduler actions
|
203 |
+
$job_scheduler = new WPBackItUp_Job_Scheduler();
|
204 |
+
add_action( 'wpbackitup_jobs_scheduled', array($job_scheduler, 'jobs_scheduled' ));
|
205 |
+
add_action( 'wpbackitup_save_schedule', array($job_scheduler, 'save_backup_schedule' ));
|
206 |
|
207 |
$api = new WPBackItUp_API();
|
208 |
add_action( $ajax_prefix. 'get_available_backups',array($api,'get_available_backups'));
|
209 |
|
210 |
+
//License action
|
211 |
+
$wpbackitup_license = new WPBackItUp_License();
|
212 |
+
add_action( 'wpbackitup_check_license', array($wpbackitup_license, 'check_license'));
|
213 |
|
214 |
}
|
215 |
|
465 |
|
466 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
|
467 |
WPBackItUp_Logger::log_info($wpbdebug_logname,__METHOD__,'Update Options Form Post');
|
468 |
+
//error_log('update options');
|
469 |
+
$this->_admin_register();
|
470 |
}
|
471 |
|
472 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-register" ) ) {
|
473 |
+
//error_log('register');
|
474 |
WPBackItUp_Logger::log_info($wpbdebug_logname,__METHOD__,'Register Lite Form Post');
|
475 |
$this->_admin_register();
|
476 |
}
|
477 |
|
478 |
+
if( wp_verify_nonce( $nonce, "{$this->namespace}-register-ce" ) ) {
|
479 |
+
//error_log('register-ce');
|
480 |
+
WPBackItUp_Logger::log_info($wpbdebug_logname,__METHOD__,'Register Lite Form Post');
|
481 |
+
$this->_admin_register();
|
482 |
+
}
|
483 |
+
|
484 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-update-schedule" ) ) {
|
485 |
WPBackItUp_Logger::log_info($wpbdebug_logname,__METHOD__,'Update Schedule Form Post');
|
486 |
|
533 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-job-task.php' );
|
534 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-job-item.php' );
|
535 |
|
536 |
+
// require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-license.php' );
|
537 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-cleanup.php' );
|
538 |
|
539 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-cron.php' );
|
551 |
//Admin Bar
|
552 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-admin-bar.php' );
|
553 |
|
|
|
554 |
$languages_path = dirname(dirname(dirname( plugin_basename( __FILE__ )))) . '/languages/';
|
555 |
|
556 |
load_plugin_textdomain(
|
1232 |
* Process update page form submissions and validate license key
|
1233 |
*
|
1234 |
*/
|
1235 |
+
// public function _admin_options_update() {
|
1236 |
+
// // Verify submission for processing using wp_nonce
|
1237 |
+
// if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
|
1238 |
+
//
|
1239 |
+
// /**
|
1240 |
+
// * Loop through each POSTed value and sanitize it to protect against malicious code. Please
|
1241 |
+
// * note that rich text (or full HTML fields) should not be processed by this function and
|
1242 |
+
// * dealt with directly.
|
1243 |
+
// */
|
1244 |
+
//
|
1245 |
+
// $debug_logname='wpb_debug';
|
1246 |
+
// WPBackItUp_Logger::log_info($debug_logname,__METHOD__, 'Posted Fields');
|
1247 |
+
// WPBackItUp_Logger::log($debug_logname, $_POST['data']); //License will not be in this array
|
1248 |
+
//
|
1249 |
+
// $wpbackitup_license = new WPBackItUp_License();
|
1250 |
+
// foreach( $_POST['data'] as $key => $val ) {
|
1251 |
+
// error_log('here'. $val);
|
1252 |
+
//
|
1253 |
+
// $posted_value = $this->_sanitize($val);
|
1254 |
+
// //If license updated then validate
|
1255 |
+
// if (!empty($key) && $key=='license_key') {
|
1256 |
+
// WPBackItUp_Logger::log_info($debug_logname,__METHOD__, 'License Posted:' .$posted_value);
|
1257 |
+
// $wpbackitup_license->update_license_options($posted_value);
|
1258 |
+
// }
|
1259 |
+
// else {
|
1260 |
+
// $data[$key] =$posted_value;
|
1261 |
+
// }
|
1262 |
+
// }
|
1263 |
+
//
|
1264 |
+
// //Could have just been a license update
|
1265 |
+
// if(!empty($data)) {
|
1266 |
+
//
|
1267 |
+
// // Update the options value with the data submitted
|
1268 |
+
// foreach( $data as $key => $val ) {
|
1269 |
+
// $this->set_option($key, $val);
|
1270 |
+
// WPBackItUp_Logger::log_info($debug_logname,__METHOD__, 'Updated Option: ' .$key .':' .$val);
|
1271 |
+
// }
|
1272 |
+
// }
|
1273 |
+
//
|
1274 |
+
// // Redirect back to the options page with the message flag to show the saved message
|
1275 |
+
// wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
|
1276 |
+
// exit;
|
1277 |
+
// }
|
1278 |
+
// }
|
1279 |
|
1280 |
|
1281 |
/***
|
1665 |
*
|
1666 |
*/
|
1667 |
public function _admin_register() {
|
|
|
|
|
1668 |
|
1669 |
+
$registration_logname='debug_registration';
|
1670 |
+
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, 'Register WPBackItUp');
|
1671 |
+
WPBackItUp_Logger::log($registration_logname,var_export($_POST,true));
|
|
|
|
|
1672 |
|
1673 |
+
//First lets check the license
|
1674 |
+
$license_key = $_POST['license_key'];
|
1675 |
+
$license_key = $this->_sanitize($license_key);
|
1676 |
|
1677 |
+
$product_id = $_POST['product_id'];
|
1678 |
+
$product_id = $this->_sanitize($product_id);
|
|
|
1679 |
|
1680 |
+
$wpbackitup_license = new WPBackItUp_License();
|
1681 |
|
1682 |
+
//activate the license if entered
|
1683 |
+
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, 'Activate License');
|
1684 |
+
$wpbackitup_license->update_license_options($license_key,$product_id);
|
1685 |
|
1686 |
+
//CE users only
|
1687 |
+
if ('-1' == $wpbackitup_license->get_license_type()) {
|
1688 |
|
1689 |
+
WPBackItUp_Logger::log_info($registration_logname,__METHOD__, 'Register WPBackItUp LITE');
|
1690 |
|
1691 |
+
$val = $_POST['license_email'];
|
1692 |
+
$license_email = $this->_sanitize( $val );
|
1693 |
+
if ( ! empty( $license_email ) && filter_var( $license_email, FILTER_VALIDATE_EMAIL ) ) {
|
1694 |
+
$urlparts = parse_url( site_url() );
|
1695 |
+
$domain = $urlparts['host'];
|
1696 |
|
1697 |
+
$license_name = $_POST['license_name'];
|
1698 |
|
1699 |
+
//save options to DB
|
1700 |
+
$this->set_option( 'license_customer_email', $license_email );
|
1701 |
+
if ( ! empty( $license_name ) ) {
|
1702 |
+
$this->set_option( 'license_customer_name', $license_name );
|
1703 |
+
}
|
1704 |
|
1705 |
+
$form_data = array(
|
1706 |
+
'email' => $license_email,
|
1707 |
+
'site' => $domain,
|
1708 |
+
'name' => $license_name,
|
1709 |
+
'time_zone' => get_option( 'timezone_string' ),
|
1710 |
+
);
|
1711 |
|
1712 |
|
1713 |
+
$registration_response = $wpbackitup_license->register_ce($form_data);
|
1714 |
+
if ( false===$registration_response ) {
|
1715 |
+
WPBackItUp_Logger::log_error($registration_logname,__METHOD__, 'Unable to register using SSL - attempting NONSSL' );
|
1716 |
+
//try without SSL
|
1717 |
+
if ( false===$wpbackitup_license->register_ce($form_data,false) ) {
|
1718 |
+
WPBackItUp_Logger::log_error($registration_logname,__METHOD__, 'Unable to register using SSL' );
|
|
|
1719 |
}
|
1720 |
}
|
1721 |
}
|
|
|
|
|
|
|
|
|
1722 |
}
|
1723 |
+
|
1724 |
+
// Redirect back to the options page with the message flag to show the saved message
|
1725 |
+
wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
|
1726 |
+
exit;
|
1727 |
+
|
1728 |
}
|
1729 |
|
1730 |
|
1837 |
$wpbackitup_license = new WPBackItUp_License();
|
1838 |
|
1839 |
switch ($wpbackitup_license->get_license_type()) {
|
1840 |
+
case -1: //CE
|
1841 |
+
$this->backup_retained_number=1;
|
1842 |
+
break;
|
1843 |
+
case 0: //Lite
|
1844 |
$this->backup_retained_number=1;
|
1845 |
break;
|
1846 |
case 1: //Personal
|
lib/includes/update_plugin.php
CHANGED
@@ -174,4 +174,24 @@ function wpbackitup_update_plugin_minor_routine_1_12($log_name){
|
|
174 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'End upgrade plugin to V1.12' );
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
174 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'End upgrade plugin to V1.12' );
|
175 |
}
|
176 |
|
177 |
+
/**
|
178 |
+
* Minor Version update 1.14
|
179 |
+
*/
|
180 |
+
function wpbackitup_update_plugin_minor_routine_1_24($log_name){
|
181 |
+
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'Begin upgrade plugin to V1.24' );
|
182 |
+
|
183 |
+
if (false===WPBackItUp_Utility::get_option( 'license_product_id') ||
|
184 |
+
empty(WPBackItUp_Utility::get_option( 'license_product_id'))&&
|
185 |
+
WPBackItUp_Utility::get_option( 'license_type',-1)>0
|
186 |
+
){
|
187 |
+
WPBackItUp_Utility::set_option( 'license_product_id','679');
|
188 |
+
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'Product Id added to license.' );
|
189 |
+
} else {
|
190 |
+
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'Product Id NOT added to license.' );
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'End upgrade plugin to V1.24' );
|
195 |
+
}
|
196 |
+
|
197 |
|
readme.txt
CHANGED
@@ -217,6 +217,13 @@ Our online documentation and full list of FAQs can be found at [support.wpbackit
|
|
217 |
|
218 |
|
219 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
= 1.23 =
|
221 |
*Release Date - July 2, 2018
|
222 |
|
217 |
|
218 |
|
219 |
== Changelog ==
|
220 |
+
= 1.24 =
|
221 |
+
*Release Date - July 19, 2018
|
222 |
+
|
223 |
+
* UPDATE: Remove Independence Day Promo
|
224 |
+
* UPDATE: Updates to core to support LITE version of plugin
|
225 |
+
* Fix : Fix JS error when WPBackItUp-Safe not installed
|
226 |
+
|
227 |
= 1.23 =
|
228 |
*Release Date - July 2, 2018
|
229 |
|
views/backup.php
CHANGED
@@ -34,7 +34,7 @@
|
|
34 |
$safe_sync_on = $this->get_option('safe_sync');
|
35 |
|
36 |
$wpbackitup_license = new WPBackItUp_License();
|
37 |
-
$
|
38 |
|
39 |
|
40 |
//Make sure backup folder exists - should this be in activation?
|
@@ -488,11 +488,11 @@ if (!$backup_folder_exists) {
|
|
488 |
if( has_action('wpbackitup_render_license_registration_form')) {
|
489 |
do_action('wpbackitup_render_license_registration_form');
|
490 |
} else {
|
491 |
-
if (false
|
492 |
<div class="widget">
|
493 |
<h3 class="promo"><span><?php _e('Register WPBackItUp', 'wp-backitup'); ?></span></h3>
|
494 |
<form action="" method="post" id="<?php echo $namespace; ?>-form">
|
495 |
-
<?php wp_nonce_field($namespace . "-register"); ?>
|
496 |
<p><?php _e('Enter your name and email address below to receive <b>special offers</b> and access to our world class <b>support</b> team. <br />', 'wp-backitup'); ?></p>
|
497 |
<input type="text" name="license_name" id="license_name" placeholder="<?php _e('name','wp-backitup')?>" /><br/>
|
498 |
<input type="text" name="license_email" id="license_email" placeholder="<?php _e('email address','wp-backitup')?>" /><br/>
|
34 |
$safe_sync_on = $this->get_option('safe_sync');
|
35 |
|
36 |
$wpbackitup_license = new WPBackItUp_License();
|
37 |
+
$is_ce_registered = $wpbackitup_license->is_ce_registered();
|
38 |
|
39 |
|
40 |
//Make sure backup folder exists - should this be in activation?
|
488 |
if( has_action('wpbackitup_render_license_registration_form')) {
|
489 |
do_action('wpbackitup_render_license_registration_form');
|
490 |
} else {
|
491 |
+
if ( false === $is_ce_registered) { ?>
|
492 |
<div class="widget">
|
493 |
<h3 class="promo"><span><?php _e('Register WPBackItUp', 'wp-backitup'); ?></span></h3>
|
494 |
<form action="" method="post" id="<?php echo $namespace; ?>-form">
|
495 |
+
<?php wp_nonce_field($namespace . "-register-ce"); ?>
|
496 |
<p><?php _e('Enter your name and email address below to receive <b>special offers</b> and access to our world class <b>support</b> team. <br />', 'wp-backitup'); ?></p>
|
497 |
<input type="text" name="license_name" id="license_name" placeholder="<?php _e('name','wp-backitup')?>" /><br/>
|
498 |
<input type="text" name="license_email" id="license_email" placeholder="<?php _e('email address','wp-backitup')?>" /><br/>
|
wp-backitup.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
7 |
* Author: WPBackItUp
|
8 |
* Author URI: https://www.wpbackitup.com
|
9 |
-
* Version: 1.
|
10 |
* Text Domain: wp-backitup
|
11 |
*
|
12 |
* License: GPL3
|
@@ -32,7 +32,7 @@ define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
|
32 |
define( 'WPBACKITUP__CLASSNAMESPACE', 'WPBackItUp' );
|
33 |
|
34 |
define( 'WPBACKITUP__MAJOR_VERSION', 1);
|
35 |
-
define( 'WPBACKITUP__MINOR_VERSION',
|
36 |
define( 'WPBACKITUP__MAINTENANCE_VERSION', 0); //Dont forget to update version in header on WP release
|
37 |
define( 'WPBACKITUP__BUILD_VERSION', 0); //Used for hotfix releases
|
38 |
|
@@ -43,14 +43,15 @@ define( 'WPBACKITUP__DEBUG', false );
|
|
43 |
|
44 |
//define( 'WPBACKITUP__TEST_RUN_HOURLY', true );
|
45 |
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
46 |
-
//define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
|
47 |
-
define( 'WPBACKITUP__ITEM_NAME', 'WP BackItUp Premium' );
|
48 |
define( 'WPBACKITUP__FRIENDLY_NAME', 'WPBackItUp' );
|
49 |
define( 'WPBACKITUP__CONTENT_PATH', WP_CONTENT_DIR );
|
50 |
define( 'WPBACKITUP__SITE_URL', 'http://www.wpbackitup.com');
|
51 |
define( 'WPBACKITUP__SECURESITE_URL', 'https://www.wpbackitup.com' );
|
52 |
define( 'WPBACKITUP__SUPPORTSITE_URL', 'http://support.wpbackitup.com' );
|
|
|
53 |
define( 'WPBACKITUP__API_URL', 'https://7aj6amlu38.execute-api.us-east-1.amazonaws.com/prod/v1' );
|
|
|
|
|
54 |
define( 'WPBACKITUP__PLUGIN_FILE_PATH', __FILE__ );//path to main plugin file
|
55 |
define( 'WPBACKITUP__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
56 |
define( 'WPBACKITUP__PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
6 |
* Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
7 |
* Author: WPBackItUp
|
8 |
* Author URI: https://www.wpbackitup.com
|
9 |
+
* Version: 1.24.0
|
10 |
* Text Domain: wp-backitup
|
11 |
*
|
12 |
* License: GPL3
|
32 |
define( 'WPBACKITUP__CLASSNAMESPACE', 'WPBackItUp' );
|
33 |
|
34 |
define( 'WPBACKITUP__MAJOR_VERSION', 1);
|
35 |
+
define( 'WPBACKITUP__MINOR_VERSION', 24);
|
36 |
define( 'WPBACKITUP__MAINTENANCE_VERSION', 0); //Dont forget to update version in header on WP release
|
37 |
define( 'WPBACKITUP__BUILD_VERSION', 0); //Used for hotfix releases
|
38 |
|
43 |
|
44 |
//define( 'WPBACKITUP__TEST_RUN_HOURLY', true );
|
45 |
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
|
|
|
|
46 |
define( 'WPBACKITUP__FRIENDLY_NAME', 'WPBackItUp' );
|
47 |
define( 'WPBACKITUP__CONTENT_PATH', WP_CONTENT_DIR );
|
48 |
define( 'WPBACKITUP__SITE_URL', 'http://www.wpbackitup.com');
|
49 |
define( 'WPBACKITUP__SECURESITE_URL', 'https://www.wpbackitup.com' );
|
50 |
define( 'WPBACKITUP__SUPPORTSITE_URL', 'http://support.wpbackitup.com' );
|
51 |
+
|
52 |
define( 'WPBACKITUP__API_URL', 'https://7aj6amlu38.execute-api.us-east-1.amazonaws.com/prod/v1' );
|
53 |
+
define( 'WPBACKITUP__API_URL_V2', 'https://7aj6amlu38.execute-api.us-east-1.amazonaws.com/prod/v2' );
|
54 |
+
|
55 |
define( 'WPBACKITUP__PLUGIN_FILE_PATH', __FILE__ );//path to main plugin file
|
56 |
define( 'WPBACKITUP__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
57 |
define( 'WPBACKITUP__PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|