Version Description
- Added an 'Send Debug Information to Us' button in Website Info page.
- Improved the compatibility with PHP v5.3 to v5.5.
- Fixed the compatibility issue with MainWP plugin.
- Fixed: Could not correctly calculate files size when backing up.
- Fixed: Could not back up to SFTP server sometimes.
- Fixed: Database backup failure because of insufficient privileges.
- Enriched backup logs with more details.
- Refined some descriptions on user interface.
- Optimized code of the plugin.
Download this release
Release Info
Developer | wpvivid |
Plugin | Migration, Backup, Staging – WPvivid |
Version | 0.9.12 |
Comparing to | |
See all releases |
Code changes from version 0.9.11 to 0.9.12
- admin/class-wpvivid-admin.php +6 -8
- admin/css/wpvivid-admin.css +2 -1
- admin/js/wpvivid-admin.js +281 -167
- admin/partials/images/storage-local(gray).png +0 -0
- admin/partials/images/storage-local.png +0 -0
- admin/partials/wpvivid-admin-display.php +8 -9
- admin/partials/wpvivid-backup-restore-page-display.php +15 -3
- admin/partials/wpvivid-settings-page-display.php +14 -0
- admin/partials/wpvivid-website-info-page-display.php +13 -1
- includes/class-wpvivid-backup-database.php +231 -53
- includes/class-wpvivid-backup-site.php +3 -2
- includes/class-wpvivid-backup.php +198 -30
- includes/class-wpvivid-backuplist.php +26 -6
- includes/class-wpvivid-downloader.php +150 -13
- includes/class-wpvivid-log.php +52 -0
- includes/class-wpvivid-mail-report.php +95 -31
- includes/class-wpvivid-mysqldump.php +62 -22
- includes/class-wpvivid-remote-collection.php +6 -4
- includes/class-wpvivid-restore-database.php +69 -11
- includes/class-wpvivid-restore-site.php +12 -7
- includes/class-wpvivid-rollback.php +47 -9
- includes/class-wpvivid-setting.php +5 -2
- includes/class-wpvivid-taskmanager.php +248 -3
- includes/class-wpvivid-tools.php +14 -7
- includes/class-wpvivid-upload.php +94 -0
- includes/class-wpvivid-zipclass.php +7 -3
- includes/class-wpvivid.php +824 -553
- includes/customclass/class-wpvivid-amazons3-plus.php +3 -2
- includes/customclass/class-wpvivid-dropbox.php +5 -2
- includes/customclass/class-wpvivid-ftpclass.php +50 -27
- includes/customclass/class-wpvivid-google-drive.php +44 -10
- includes/customclass/class-wpvivid-one-drive.php +14 -10
- includes/customclass/class-wpvivid-s3compat.php +67 -14
- includes/customclass/class-wpvivid-sftpclass.php +5 -3
- readme.txt +30 -18
- vendor/composer/autoload_files.php +20 -8
- vendor/google/apiclient-services/README.md +6 -13
- vendor/google/apiclient-services/src/Google/Service/Drive.php +38 -2
- vendor/google/apiclient-services/src/Google/Service/Drive/About.php +9 -0
- vendor/google/apiclient-services/src/Google/Service/Drive/DriveFile.php +27 -0
- vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileCapabilities.php +63 -0
- vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Files.php +6 -5
- vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Permissions.php +16 -1
- vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Teamdrives.php +12 -0
- vendor/google/apiclient-services/src/Google/Service/Drive/Revision.php +9 -0
- vendor/google/apiclient-services/src/Google/Service/Drive/TeamDrive.php +25 -0
- vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveCapabilities.php +45 -0
- wpvivid-backuprestore.php +5 -5
admin/class-wpvivid-admin.php
CHANGED
@@ -109,7 +109,6 @@ class WPvivid_Admin {
|
|
109 |
'wpvivid_page_wpvivid-website' == get_current_screen()->id ||
|
110 |
'wpvivid_page_wpvivid-log' == get_current_screen()->id) {
|
111 |
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvivid-admin.js', array('jquery'), $this->version, false);
|
112 |
-
wp_enqueue_script($this->plugin_name.'jquerymin', includes_url() . 'js/jquery/jquery.js', array('jquery'), $this->version, false);
|
113 |
wp_localize_script($this->plugin_name, 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php')));
|
114 |
}
|
115 |
}
|
@@ -186,7 +185,7 @@ class WPvivid_Admin {
|
|
186 |
return array_merge( $settings_link, $links );
|
187 |
}
|
188 |
|
189 |
-
public function wpvivid_get_siteurl(){
|
190 |
$wpvivid_siteurl = array();
|
191 |
$wpvivid_siteurl['home_url'] = home_url();
|
192 |
$wpvivid_siteurl['plug_url'] = plugins_url();
|
@@ -317,16 +316,15 @@ class WPvivid_Admin {
|
|
317 |
public static function wpvivid_check_extensions(){
|
318 |
$need_php_extensions = array();
|
319 |
$need_extensions_count = 0;
|
320 |
-
|
321 |
-
|
322 |
-
$need_php_extensions[$need_extensions_count] = 'PDO';
|
323 |
$need_extensions_count++;
|
324 |
}
|
325 |
-
if(!
|
326 |
-
$need_php_extensions[$need_extensions_count] = '
|
327 |
$need_extensions_count++;
|
328 |
}
|
329 |
-
if(!
|
330 |
$need_php_extensions[$need_extensions_count] = 'zlib';
|
331 |
$need_extensions_count++;
|
332 |
}
|
109 |
'wpvivid_page_wpvivid-website' == get_current_screen()->id ||
|
110 |
'wpvivid_page_wpvivid-log' == get_current_screen()->id) {
|
111 |
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvivid-admin.js', array('jquery'), $this->version, false);
|
|
|
112 |
wp_localize_script($this->plugin_name, 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php')));
|
113 |
}
|
114 |
}
|
185 |
return array_merge( $settings_link, $links );
|
186 |
}
|
187 |
|
188 |
+
public static function wpvivid_get_siteurl(){
|
189 |
$wpvivid_siteurl = array();
|
190 |
$wpvivid_siteurl['home_url'] = home_url();
|
191 |
$wpvivid_siteurl['plug_url'] = plugins_url();
|
316 |
public static function wpvivid_check_extensions(){
|
317 |
$need_php_extensions = array();
|
318 |
$need_extensions_count = 0;
|
319 |
+
if(!function_exists("curl_init")){
|
320 |
+
$need_php_extensions[$need_extensions_count] = 'curl';
|
|
|
321 |
$need_extensions_count++;
|
322 |
}
|
323 |
+
if(!class_exists('PDO')){
|
324 |
+
$need_php_extensions[$need_extensions_count] = 'PDO';
|
325 |
$need_extensions_count++;
|
326 |
}
|
327 |
+
if(!function_exists("gzopen")){
|
328 |
$need_php_extensions[$need_extensions_count] = 'zlib';
|
329 |
$need_extensions_count++;
|
330 |
}
|
admin/css/wpvivid-admin.css
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
.list-top-block{height:40px; line-height:40px; display:block; float:left; position:relative; width:100%;}
|
6 |
.list-top-chip{float:left;display:block; vertical-align:middle; }
|
7 |
.list-top-chip::after{content:" "}
|
8 |
-
.backup-basic-info{min-width:
|
9 |
.list-top-chip-button{position:absolute; top:8px; right:10px;}
|
10 |
.quickbackup{width:calc(100% - 290px);float:left; box-sizing:border-box;margin-right:10px; padding:10px;}
|
11 |
.quickbackup label{display:inline-block;margin-bottom:10px;}
|
@@ -77,6 +77,7 @@
|
|
77 |
.remote-storage-amazons3-encryption input, span{display:line-block; margin-top:10px; margin-bottom:10px;margin-right:10px;}
|
78 |
.backup-list-head{}
|
79 |
.download-website-info{float:left;}
|
|
|
80 |
|
81 |
@media screen and (max-width:1650px) {
|
82 |
.qucikbackup-schedule{
|
5 |
.list-top-block{height:40px; line-height:40px; display:block; float:left; position:relative; width:100%;}
|
6 |
.list-top-chip{float:left;display:block; vertical-align:middle; }
|
7 |
.list-top-chip::after{content:" "}
|
8 |
+
.backup-basic-info{min-width:100px; margin:10px; float:left;}
|
9 |
.list-top-chip-button{position:absolute; top:8px; right:10px;}
|
10 |
.quickbackup{width:calc(100% - 290px);float:left; box-sizing:border-box;margin-right:10px; padding:10px;}
|
11 |
.quickbackup label{display:inline-block;margin-bottom:10px;}
|
77 |
.remote-storage-amazons3-encryption input, span{display:line-block; margin-top:10px; margin-bottom:10px;margin-right:10px;}
|
78 |
.backup-list-head{}
|
79 |
.download-website-info{float:left;}
|
80 |
+
.storage-account-form {padding-top: 1px; padding-bottom: 1px;}
|
81 |
|
82 |
@media screen and (max-width:1650px) {
|
83 |
.qucikbackup-schedule{
|
admin/js/wpvivid-admin.js
CHANGED
@@ -14,6 +14,9 @@ var wpvivid_restoring=false;
|
|
14 |
var wpvivid_location_href=false;
|
15 |
var wpvivid_editing_storage_id = '';
|
16 |
var wpvivid_editing_storage_type = '';
|
|
|
|
|
|
|
17 |
|
18 |
(function ($) {
|
19 |
'use strict';
|
@@ -233,6 +236,20 @@ function wpvivid_check_runningtask(){
|
|
233 |
}, 3000);
|
234 |
try {
|
235 |
var jsonarray = jQuery.parseJSON(data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
var b_has_data = false;
|
237 |
if (jsonarray.backup.data.length !== 0) {
|
238 |
b_has_data = true;
|
@@ -259,7 +276,6 @@ function wpvivid_check_runningtask(){
|
|
259 |
wpvivid_resume_backup(index, value.data.next_resume_time);
|
260 |
}
|
261 |
else {
|
262 |
-
wpvivid_add_notice('Backup', 'Error', value.data.next_resume_time);
|
263 |
wpvivid_delete_backup_task(index);
|
264 |
}
|
265 |
}
|
@@ -272,33 +288,27 @@ function wpvivid_check_runningtask(){
|
|
272 |
}
|
273 |
else if (value.status.str === 'completed') {
|
274 |
jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
|
275 |
-
var info = 'Task ' + index + ' completed.';
|
276 |
-
wpvivid_add_notice('Backup', 'Success', info);
|
277 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
278 |
jQuery('#wpvivid_postbox_backup_percent').hide();
|
279 |
-
jQuery('#wpvivid_backuplist').html('');
|
280 |
-
jQuery('#wpvivid_backuplist').append(value.backuplist_html);
|
281 |
jQuery('#wpvivid_last_backup_msg').html(jsonarray.last_msg_html);
|
282 |
jQuery('#wpvivid_loglist').html("");
|
283 |
jQuery('#wpvivid_loglist').append(jsonarray.log_html);
|
284 |
wpvivid_log_count = jsonarray.log_count;
|
285 |
wpvivid_display_log_page();
|
286 |
-
|
287 |
-
|
|
|
288 |
}
|
289 |
else if (value.status.str === 'error') {
|
290 |
jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
|
291 |
-
var info = 'Backup error: ' + value.status.error + ', task id: ' + index;
|
292 |
-
wpvivid_add_notice('Backup', 'Error', info);
|
293 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
294 |
jQuery('#wpvivid_postbox_backup_percent').hide();
|
295 |
-
jQuery('#wpvivid_backuplist').html('');
|
296 |
-
jQuery('#wpvivid_backuplist').append(value.backuplist_html);
|
297 |
jQuery('#wpvivid_last_backup_msg').html(jsonarray.last_msg_html);
|
298 |
jQuery('#wpvivid_loglist').html("");
|
299 |
jQuery('#wpvivid_loglist').append(jsonarray.log_html);
|
300 |
-
|
301 |
-
|
|
|
302 |
}
|
303 |
});
|
304 |
}
|
@@ -548,8 +558,8 @@ function wpvivid_start_backup(){
|
|
548 |
jQuery('#wpvivid_current_doing').html('Ready to backup. Progress: 0%, running time: 0second.');
|
549 |
var percent = '0%';
|
550 |
jQuery('#wpvivid_action_progress_bar_percent').css('width', percent);
|
551 |
-
jQuery('#wpvivid_backup_database_size').html('');
|
552 |
-
jQuery('#wpvivid_backup_file_size').html('');
|
553 |
jQuery('#wpvivid_current_doing').html('');
|
554 |
wpvivid_completed_backup = 1;
|
555 |
wpvivid_prepare_backup = true;
|
@@ -626,109 +636,6 @@ function wpvivid_delete_ready_task(error){
|
|
626 |
});
|
627 |
}
|
628 |
|
629 |
-
/**
|
630 |
-
* Delete the selected backup from the list
|
631 |
-
*
|
632 |
-
* @param backup_id - A unique ID for a backup
|
633 |
-
*/
|
634 |
-
/*function wpvivid_delete_selected_backup(backup_id){
|
635 |
-
var name = '';
|
636 |
-
jQuery('#wpvivid_backuplist tr').each(function(i){
|
637 |
-
jQuery(this).children('td').each(function (j) {
|
638 |
-
if (j == 0) {
|
639 |
-
var id = jQuery(this).parent().children('th').find("input[type=checkbox]").attr("id");
|
640 |
-
if(id === backup_id){
|
641 |
-
name = jQuery(this).parent().children('td').eq(0).find('img').attr('name');
|
642 |
-
}
|
643 |
-
}
|
644 |
-
});
|
645 |
-
});
|
646 |
-
var descript = '';
|
647 |
-
var force_del = 0;
|
648 |
-
var bdownloading = false;
|
649 |
-
if(name === 'lock') {
|
650 |
-
descript = 'This backup is locked, are you sure to remove it? This backup will be deleted permanently from your hosting (localhost) and remote storages.';
|
651 |
-
force_del = 1;
|
652 |
-
}
|
653 |
-
else{
|
654 |
-
descript = 'Are you sure to remove this backup? This backup will be deleted permanently from your hosting (localhost) and remote storages.';
|
655 |
-
force_del = 0;
|
656 |
-
}
|
657 |
-
if(m_downloading_id === backup_id){
|
658 |
-
bdownloading = true;
|
659 |
-
descript = 'This request will delete the backup being downloaded, are you sure you want to continue?';
|
660 |
-
force_del = 1;
|
661 |
-
}
|
662 |
-
var ret = confirm(descript);
|
663 |
-
if(ret === true){
|
664 |
-
var ajax_data={
|
665 |
-
'action': 'wpvivid_delete_backup',
|
666 |
-
'backup_id': backup_id,
|
667 |
-
'force': force_del
|
668 |
-
};
|
669 |
-
wpvivid_post_request(ajax_data, function(data){
|
670 |
-
wpvivid_handle_backup_data(data);
|
671 |
-
if(bdownloading){
|
672 |
-
m_downloading_id = '';
|
673 |
-
}
|
674 |
-
}, function(XMLHttpRequest, textStatus, errorThrown) {
|
675 |
-
var error_message = wpvivid_output_ajaxerror('deleting the backup', textStatus, errorThrown);
|
676 |
-
alert(error_message);
|
677 |
-
});
|
678 |
-
}
|
679 |
-
}*/
|
680 |
-
|
681 |
-
/**
|
682 |
-
* Delete multiple backups in one operation
|
683 |
-
*/
|
684 |
-
/*function wpvivid_delete_backups_inbatches(){
|
685 |
-
var delete_backup_array = new Array();
|
686 |
-
var count = 0;
|
687 |
-
var bdownloading = false;
|
688 |
-
jQuery('#wpvivid_backuplist tr').each(function (i) {
|
689 |
-
jQuery(this).children('th').each(function (j) {
|
690 |
-
if (j == 0) {
|
691 |
-
if(jQuery(this).find('input[type=checkbox]').prop('checked')){
|
692 |
-
delete_backup_array[count] = jQuery(this).find('input[type=checkbox]').attr('id');
|
693 |
-
if(m_downloading_id === jQuery(this).find('input[type=checkbox]').attr('id')){
|
694 |
-
bdownloading = true;
|
695 |
-
}
|
696 |
-
count++;
|
697 |
-
}
|
698 |
-
}
|
699 |
-
});
|
700 |
-
});
|
701 |
-
if( count === 0 ){
|
702 |
-
alert('Please select at least one item.');
|
703 |
-
}
|
704 |
-
else {
|
705 |
-
var descript = '';
|
706 |
-
if(bdownloading) {
|
707 |
-
descript = 'This request might delete the backup being downloaded, are you sure you want to continue?';
|
708 |
-
}
|
709 |
-
else{
|
710 |
-
descript = 'Are you sure to remove the selected backups? These backups will be deleted permanently from your hosting (localhost).';
|
711 |
-
}
|
712 |
-
var ret = confirm(descript);
|
713 |
-
if (ret === true) {
|
714 |
-
var ajax_data = {
|
715 |
-
'action': 'wpvivid_delete_backup_array',
|
716 |
-
'backup_id': delete_backup_array
|
717 |
-
};
|
718 |
-
wpvivid_post_request(ajax_data, function (data) {
|
719 |
-
wpvivid_handle_backup_data(data);
|
720 |
-
jQuery('#backup_list_all_check').prop('checked', false);
|
721 |
-
if(bdownloading){
|
722 |
-
m_downloading_id = '';
|
723 |
-
}
|
724 |
-
}, function (XMLHttpRequest, textStatus, errorThrown) {
|
725 |
-
var error_message = wpvivid_output_ajaxerror('deleting the backup', textStatus, errorThrown);
|
726 |
-
alert(error_message);
|
727 |
-
});
|
728 |
-
}
|
729 |
-
}
|
730 |
-
}*/
|
731 |
-
|
732 |
/**
|
733 |
* Resume the backup task automatically in 1 minute in a timeout situation
|
734 |
*
|
@@ -799,7 +706,6 @@ function wpvivid_add_remote_storage(storage_type)
|
|
799 |
jQuery(this).val('');
|
800 |
});
|
801 |
wpvivid_handle_remote_storage_data(data);
|
802 |
-
jQuery('#wpvivid_schedule_backup_local_remote').html(jsonarray.local_remote);
|
803 |
}
|
804 |
else if (jsonarray.result === 'failed')
|
805 |
{
|
@@ -815,15 +721,7 @@ function wpvivid_add_remote_storage(storage_type)
|
|
815 |
|
816 |
}, function (XMLHttpRequest, textStatus, errorThrown)
|
817 |
{
|
818 |
-
|
819 |
-
if (action === 'wpvivid_test_remote_connection')
|
820 |
-
{
|
821 |
-
var error_message = wpvivid_output_ajaxerror('testing the remote storage connection', textStatus, errorThrown);
|
822 |
-
}
|
823 |
-
else if (action === 'wpvivid_add_remote')
|
824 |
-
{
|
825 |
-
var error_message = wpvivid_output_ajaxerror('adding the remote storage', textStatus, errorThrown);
|
826 |
-
}
|
827 |
alert(error_message);
|
828 |
});
|
829 |
}
|
@@ -838,6 +736,8 @@ function wpvivid_handle_remote_storage_data(data){
|
|
838 |
jQuery('#upload_storage').html(jsonarray.pic);
|
839 |
jQuery('#schedule_upload_storage').html(jsonarray.pic);
|
840 |
jQuery('#wpvivid_out_of_date_remote_path').html(jsonarray.dir);
|
|
|
|
|
841 |
wpvivid_interface_flow_control();
|
842 |
}
|
843 |
else if(jsonarray.result === 'failed'){
|
@@ -849,6 +749,14 @@ function wpvivid_handle_remote_storage_data(data){
|
|
849 |
}
|
850 |
}
|
851 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
function click_retrieve_remote_storage(id,type,name)
|
853 |
{
|
854 |
wpvivid_editing_storage_id = id;
|
@@ -889,6 +797,14 @@ function click_retrieve_remote_storage(id,type,name)
|
|
889 |
}
|
890 |
jQuery(this).prop('checked', value);
|
891 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
892 |
}
|
893 |
else
|
894 |
{
|
@@ -1269,11 +1185,7 @@ function wpvivid_add_notice(notice_action, notice_type, notice_msg){
|
|
1269 |
"</div>";
|
1270 |
}
|
1271 |
else if(notice_type === "Error"){
|
1272 |
-
div = "<div class=\"notice notice-error inline\"><p>Error: " + notice_msg + "</p>"
|
1273 |
-
"<button type='button' class='notice-dismiss' onclick='click_dismiss_notice(this);'>" +
|
1274 |
-
"<span class='screen-reader-text'>Dismiss this notice.</span>" +
|
1275 |
-
"</button>" +
|
1276 |
-
"</div>";
|
1277 |
}
|
1278 |
else if(notice_type === "Success"){
|
1279 |
wpvivid_clear_notice('wpvivid_backup_notice');
|
@@ -1781,6 +1693,7 @@ function wpvivid_init_restore_data(){
|
|
1781 |
* This function will start the process of restoring a backup
|
1782 |
*/
|
1783 |
function wpvivid_start_restore(){
|
|
|
1784 |
wpvivid_prepare_restore();
|
1785 |
}
|
1786 |
|
@@ -1807,62 +1720,89 @@ function wpvivid_prepare_restore(){
|
|
1807 |
jQuery('#wpvivid_clean_part').hide();
|
1808 |
jQuery('#wpvivid_rollback_part').hide();
|
1809 |
wpvivid_restoring = true;
|
1810 |
-
wpvivid_post_request(ajax_data, function(data)
|
1811 |
-
|
|
|
|
|
1812 |
var jsonarray = jQuery.parseJSON(data);
|
1813 |
-
if (jsonarray.result === "success")
|
|
|
1814 |
wpvivid_display_restore_msg("Prepare to start restoring.");
|
1815 |
wpvivid_restore_lock();
|
1816 |
wpvivid_monitor_restore_task();
|
1817 |
wpvivid_restore();
|
1818 |
}
|
1819 |
-
else if (jsonarray.result === "need_download")
|
|
|
1820 |
wpvivid_restore_lock();
|
1821 |
-
|
1822 |
var download_num = 0;
|
1823 |
-
var start_download_num = 0;
|
1824 |
wpvivid_display_restore_msg("Backup is not found on web server. Prepare to download it from remote storage.");
|
1825 |
-
jQuery.each(jsonarray.files, function (index, value)
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
|
|
|
|
1831 |
download_num++;
|
1832 |
}
|
1833 |
});
|
1834 |
-
|
|
|
1835 |
}
|
1836 |
-
else if (jsonarray.result === "file_not_found")
|
|
|
1837 |
wpvivid_display_restore_msg("Backup doesn't exist in both web server and remote storage. Restore failed.");
|
1838 |
}
|
1839 |
}
|
1840 |
-
catch(err)
|
|
|
1841 |
alert(err);
|
1842 |
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1843 |
}
|
1844 |
-
}, function(XMLHttpRequest, textStatus, errorThrown)
|
|
|
1845 |
var error_message = wpvivid_output_ajaxerror('preparing to restore', textStatus, errorThrown);
|
1846 |
wpvivid_display_restore_msg(error_message);
|
1847 |
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1848 |
});
|
1849 |
}
|
1850 |
|
1851 |
-
function wpvivid_download_restore_file(
|
1852 |
-
|
1853 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1854 |
var ajax_data = {
|
1855 |
'action': 'wpvivid_download_restore',
|
1856 |
'backup_id': m_restore_backup_id,
|
1857 |
-
'file_name':
|
1858 |
-
'
|
1859 |
-
'md5':
|
1860 |
}
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
|
|
|
|
1866 |
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1867 |
jQuery('#wpvivid_clean_restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1868 |
jQuery('#wpvivid_rollback_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
@@ -1872,13 +1812,140 @@ function wpvivid_download_restore_file(download_array, download_num, start_downl
|
|
1872 |
var error_message = wpvivid_output_ajaxerror('downloading backups', textStatus, errorThrown);
|
1873 |
wpvivid_display_restore_msg(error_message);
|
1874 |
wpvivid_restore_unlock();
|
1875 |
-
});
|
1876 |
-
}
|
1877 |
-
else{
|
1878 |
-
wpvivid_prepare_restore();
|
1879 |
}
|
1880 |
}
|
1881 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1882 |
/**
|
1883 |
* Monitor restore task.
|
1884 |
*/
|
@@ -2000,9 +2067,27 @@ function wpvivid_restore(){
|
|
2000 |
});
|
2001 |
}
|
2002 |
|
2003 |
-
function wpvivid_display_restore_msg(msg){
|
2004 |
-
|
2005 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006 |
}
|
2007 |
|
2008 |
/**
|
@@ -2160,6 +2245,8 @@ function wpvivid_restore_lock(){
|
|
2160 |
jQuery('#wpvivid_postbox_backup').css({'pointer-events': 'none', 'opacity': '1'});
|
2161 |
jQuery('#wpvivid_postbox_backup_schedule').css({'pointer-events': 'none', 'opacity': '1'});
|
2162 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '1'});
|
|
|
|
|
2163 |
jQuery('#wpvivid_tab_restore').css({'pointer-events': 'none', 'opacity': '1'});
|
2164 |
jQuery('#page-backups').css({'pointer-events': 'none', 'opacity': '1'});
|
2165 |
jQuery('#storage-page').css({'pointer-events': 'none', 'opacity': '1'});
|
@@ -2176,6 +2263,8 @@ function wpvivid_restore_unlock(){
|
|
2176 |
jQuery('#wpvivid_postbox_backup').css({'pointer-events': 'auto', 'opacity': '1'});
|
2177 |
jQuery('#wpvivid_postbox_backup_schedule').css({'pointer-events': 'auto', 'opacity': '1'});
|
2178 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
|
|
|
|
2179 |
jQuery('#wpvivid_tab_restore').css({'pointer-events': 'auto', 'opacity': '1'});
|
2180 |
jQuery('#page-backups').css({'pointer-events': 'auto', 'opacity': '1'});
|
2181 |
jQuery('#storage-page').css({'pointer-events': 'auto', 'opacity': '1'});
|
@@ -2301,6 +2390,31 @@ function wpvivid_download_website_info(){
|
|
2301 |
location.href =ajaxurl+'?action=wpvivid_create_debug_package';
|
2302 |
}
|
2303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2304 |
/**
|
2305 |
* Output ajax error in a standard format.
|
2306 |
*
|
14 |
var wpvivid_location_href=false;
|
15 |
var wpvivid_editing_storage_id = '';
|
16 |
var wpvivid_editing_storage_type = '';
|
17 |
+
var wpvivid_restore_download_array;
|
18 |
+
var wpvivid_restore_download_index = 0;
|
19 |
+
var wpvivid_get_download_restore_progress_retry = 0;
|
20 |
|
21 |
(function ($) {
|
22 |
'use strict';
|
236 |
}, 3000);
|
237 |
try {
|
238 |
var jsonarray = jQuery.parseJSON(data);
|
239 |
+
if (jsonarray.success_notice_html != false) {
|
240 |
+
jQuery('#wpvivid_backup_notice').show();
|
241 |
+
jQuery('#wpvivid_backup_notice').append(jsonarray.success_notice_html);
|
242 |
+
}
|
243 |
+
if(jsonarray.error_notice_html != false){
|
244 |
+
jQuery('#wpvivid_backup_notice').show();
|
245 |
+
jQuery.each(jsonarray.error_notice_html, function (index, value) {
|
246 |
+
jQuery('#wpvivid_backup_notice').append(value.error_msg);
|
247 |
+
});
|
248 |
+
}
|
249 |
+
if(jsonarray.backuplist_html != false) {
|
250 |
+
jQuery('#wpvivid_backuplist').html('');
|
251 |
+
jQuery('#wpvivid_backuplist').append(jsonarray.backuplist_html);
|
252 |
+
}
|
253 |
var b_has_data = false;
|
254 |
if (jsonarray.backup.data.length !== 0) {
|
255 |
b_has_data = true;
|
276 |
wpvivid_resume_backup(index, value.data.next_resume_time);
|
277 |
}
|
278 |
else {
|
|
|
279 |
wpvivid_delete_backup_task(index);
|
280 |
}
|
281 |
}
|
288 |
}
|
289 |
else if (value.status.str === 'completed') {
|
290 |
jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
|
|
|
|
|
291 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
292 |
jQuery('#wpvivid_postbox_backup_percent').hide();
|
|
|
|
|
293 |
jQuery('#wpvivid_last_backup_msg').html(jsonarray.last_msg_html);
|
294 |
jQuery('#wpvivid_loglist').html("");
|
295 |
jQuery('#wpvivid_loglist').append(jsonarray.log_html);
|
296 |
wpvivid_log_count = jsonarray.log_count;
|
297 |
wpvivid_display_log_page();
|
298 |
+
running_backup_taskid = '';
|
299 |
+
m_backup_task_id = '';
|
300 |
+
m_need_update = true;
|
301 |
}
|
302 |
else if (value.status.str === 'error') {
|
303 |
jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
|
|
|
|
|
304 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
305 |
jQuery('#wpvivid_postbox_backup_percent').hide();
|
|
|
|
|
306 |
jQuery('#wpvivid_last_backup_msg').html(jsonarray.last_msg_html);
|
307 |
jQuery('#wpvivid_loglist').html("");
|
308 |
jQuery('#wpvivid_loglist').append(jsonarray.log_html);
|
309 |
+
running_backup_taskid = '';
|
310 |
+
m_backup_task_id = '';
|
311 |
+
m_need_update = true;
|
312 |
}
|
313 |
});
|
314 |
}
|
558 |
jQuery('#wpvivid_current_doing').html('Ready to backup. Progress: 0%, running time: 0second.');
|
559 |
var percent = '0%';
|
560 |
jQuery('#wpvivid_action_progress_bar_percent').css('width', percent);
|
561 |
+
jQuery('#wpvivid_backup_database_size').html('N/A');
|
562 |
+
jQuery('#wpvivid_backup_file_size').html('N/A');
|
563 |
jQuery('#wpvivid_current_doing').html('');
|
564 |
wpvivid_completed_backup = 1;
|
565 |
wpvivid_prepare_backup = true;
|
636 |
});
|
637 |
}
|
638 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
639 |
/**
|
640 |
* Resume the backup task automatically in 1 minute in a timeout situation
|
641 |
*
|
706 |
jQuery(this).val('');
|
707 |
});
|
708 |
wpvivid_handle_remote_storage_data(data);
|
|
|
709 |
}
|
710 |
else if (jsonarray.result === 'failed')
|
711 |
{
|
721 |
|
722 |
}, function (XMLHttpRequest, textStatus, errorThrown)
|
723 |
{
|
724 |
+
var error_message = wpvivid_output_ajaxerror('adding the remote storage', textStatus, errorThrown);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
725 |
alert(error_message);
|
726 |
});
|
727 |
}
|
736 |
jQuery('#upload_storage').html(jsonarray.pic);
|
737 |
jQuery('#schedule_upload_storage').html(jsonarray.pic);
|
738 |
jQuery('#wpvivid_out_of_date_remote_path').html(jsonarray.dir);
|
739 |
+
jQuery('#wpvivid_schedule_backup_local_remote').html(jsonarray.local_remote);
|
740 |
+
wpvivid_control_remote_storage(jsonarray.remote_storage);
|
741 |
wpvivid_interface_flow_control();
|
742 |
}
|
743 |
else if(jsonarray.result === 'failed'){
|
749 |
}
|
750 |
}
|
751 |
|
752 |
+
function wpvivid_control_remote_storage(has_remote){
|
753 |
+
jQuery("input:radio[name='save_local_remote'][value='remote']").click(function(){
|
754 |
+
if(!has_remote){
|
755 |
+
alert("There is no default remote storage configured. Please set it up first.");
|
756 |
+
}
|
757 |
+
});
|
758 |
+
}
|
759 |
+
|
760 |
function click_retrieve_remote_storage(id,type,name)
|
761 |
{
|
762 |
wpvivid_editing_storage_id = id;
|
797 |
}
|
798 |
jQuery(this).prop('checked', value);
|
799 |
});
|
800 |
+
if(jsonarray.type == 's3compat'){
|
801 |
+
var dos_edit_value = jQuery('input:text[option=edit-'+jsonarray.type+'][name=s3directory]').val();
|
802 |
+
if(dos_edit_value == ''){
|
803 |
+
dos_edit_value = '*';
|
804 |
+
}
|
805 |
+
dos_edit_value = dos_edit_value + '/wpvivid_backup';
|
806 |
+
jQuery('#wpvivid_edit_dos_root_path').html(dos_edit_value);
|
807 |
+
}
|
808 |
}
|
809 |
else
|
810 |
{
|
1185 |
"</div>";
|
1186 |
}
|
1187 |
else if(notice_type === "Error"){
|
1188 |
+
div = "<div class=\"notice notice-error inline\"><p>Error: " + notice_msg + "</p></div>";
|
|
|
|
|
|
|
|
|
1189 |
}
|
1190 |
else if(notice_type === "Success"){
|
1191 |
wpvivid_clear_notice('wpvivid_backup_notice');
|
1693 |
* This function will start the process of restoring a backup
|
1694 |
*/
|
1695 |
function wpvivid_start_restore(){
|
1696 |
+
jQuery('#wpvivid_restore_log').html("");
|
1697 |
wpvivid_prepare_restore();
|
1698 |
}
|
1699 |
|
1720 |
jQuery('#wpvivid_clean_part').hide();
|
1721 |
jQuery('#wpvivid_rollback_part').hide();
|
1722 |
wpvivid_restoring = true;
|
1723 |
+
wpvivid_post_request(ajax_data, function(data)
|
1724 |
+
{
|
1725 |
+
try
|
1726 |
+
{
|
1727 |
var jsonarray = jQuery.parseJSON(data);
|
1728 |
+
if (jsonarray.result === "success")
|
1729 |
+
{
|
1730 |
wpvivid_display_restore_msg("Prepare to start restoring.");
|
1731 |
wpvivid_restore_lock();
|
1732 |
wpvivid_monitor_restore_task();
|
1733 |
wpvivid_restore();
|
1734 |
}
|
1735 |
+
else if (jsonarray.result === "need_download")
|
1736 |
+
{
|
1737 |
wpvivid_restore_lock();
|
1738 |
+
wpvivid_restore_download_array = new Array();
|
1739 |
var download_num = 0;
|
|
|
1740 |
wpvivid_display_restore_msg("Backup is not found on web server. Prepare to download it from remote storage.");
|
1741 |
+
jQuery.each(jsonarray.files, function (index, value)
|
1742 |
+
{
|
1743 |
+
if (value.status === "need_download")
|
1744 |
+
{
|
1745 |
+
wpvivid_restore_download_array[download_num] = new Array('file_name', 'size', 'md5');
|
1746 |
+
wpvivid_restore_download_array[download_num]['file_name'] = index;
|
1747 |
+
wpvivid_restore_download_array[download_num]['size'] = value.size;
|
1748 |
+
wpvivid_restore_download_array[download_num]['md5'] = value.md5;
|
1749 |
download_num++;
|
1750 |
}
|
1751 |
});
|
1752 |
+
wpvivid_restore_download_index=0;
|
1753 |
+
wpvivid_download_restore_file();
|
1754 |
}
|
1755 |
+
else if (jsonarray.result === "file_not_found")
|
1756 |
+
{
|
1757 |
wpvivid_display_restore_msg("Backup doesn't exist in both web server and remote storage. Restore failed.");
|
1758 |
}
|
1759 |
}
|
1760 |
+
catch(err)
|
1761 |
+
{
|
1762 |
alert(err);
|
1763 |
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1764 |
}
|
1765 |
+
}, function(XMLHttpRequest, textStatus, errorThrown)
|
1766 |
+
{
|
1767 |
var error_message = wpvivid_output_ajaxerror('preparing to restore', textStatus, errorThrown);
|
1768 |
wpvivid_display_restore_msg(error_message);
|
1769 |
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1770 |
});
|
1771 |
}
|
1772 |
|
1773 |
+
function wpvivid_download_restore_file()
|
1774 |
+
{
|
1775 |
+
if(wpvivid_restore_download_array.length===0)
|
1776 |
+
{
|
1777 |
+
wpvivid_display_restore_msg("Downloading backup file failed. Backup file might be deleted or network doesn't work properly. Please verify the file and confirm the network connection and try again later.");
|
1778 |
+
wpvivid_restore_unlock();
|
1779 |
+
return false;
|
1780 |
+
}
|
1781 |
+
|
1782 |
+
if(wpvivid_restore_download_index+1>wpvivid_restore_download_array.length)
|
1783 |
+
{
|
1784 |
+
wpvivid_display_restore_msg("Download succeeded.");
|
1785 |
+
//return true;
|
1786 |
+
wpvivid_prepare_restore();
|
1787 |
+
}
|
1788 |
+
else
|
1789 |
+
{
|
1790 |
+
wpvivid_display_restore_msg("Downloading backup file " + wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name']);
|
1791 |
+
wpvivid_display_restore_msg('', wpvivid_restore_download_index);
|
1792 |
var ajax_data = {
|
1793 |
'action': 'wpvivid_download_restore',
|
1794 |
'backup_id': m_restore_backup_id,
|
1795 |
+
'file_name': wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'],
|
1796 |
+
'size': wpvivid_restore_download_array[wpvivid_restore_download_index]['size'],
|
1797 |
+
'md5': wpvivid_restore_download_array[wpvivid_restore_download_index]['md5']
|
1798 |
}
|
1799 |
+
wpvivid_get_download_restore_progress_retry=0;
|
1800 |
+
wpvivid_monitor_download_restore_task();
|
1801 |
+
wpvivid_post_request(ajax_data, function (data)
|
1802 |
+
{
|
1803 |
+
//wpvivid_monitor_download_restore_task();
|
1804 |
+
}, function (XMLHttpRequest, textStatus, errorThrown)
|
1805 |
+
{
|
1806 |
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1807 |
jQuery('#wpvivid_clean_restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1808 |
jQuery('#wpvivid_rollback_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1812 |
var error_message = wpvivid_output_ajaxerror('downloading backups', textStatus, errorThrown);
|
1813 |
wpvivid_display_restore_msg(error_message);
|
1814 |
wpvivid_restore_unlock();
|
1815 |
+
}, 0);
|
|
|
|
|
|
|
1816 |
}
|
1817 |
}
|
1818 |
|
1819 |
+
function wpvivid_monitor_download_restore_task()
|
1820 |
+
{
|
1821 |
+
var ajax_data={
|
1822 |
+
'action':'wpvivid_get_download_restore_progress',
|
1823 |
+
'file_name': wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'],
|
1824 |
+
'size': wpvivid_restore_download_array[wpvivid_restore_download_index]['size'],
|
1825 |
+
'md5': wpvivid_restore_download_array[wpvivid_restore_download_index]['md5']
|
1826 |
+
};
|
1827 |
+
|
1828 |
+
wpvivid_post_request(ajax_data, function(data)
|
1829 |
+
{
|
1830 |
+
try
|
1831 |
+
{
|
1832 |
+
var jsonarray = jQuery.parseJSON(data);
|
1833 |
+
if(typeof jsonarray ==='object')
|
1834 |
+
{
|
1835 |
+
if(jsonarray.result === "success")
|
1836 |
+
{
|
1837 |
+
if(jsonarray.status==='completed')
|
1838 |
+
{
|
1839 |
+
wpvivid_display_restore_msg(wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'] + ' download succeeded.', wpvivid_restore_download_index, false);
|
1840 |
+
//wpvivid_display_restore_msg(wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'] + ' download succeeded.');
|
1841 |
+
wpvivid_restore_download_index++;
|
1842 |
+
wpvivid_download_restore_file();
|
1843 |
+
}
|
1844 |
+
else if(jsonarray.status==='error')
|
1845 |
+
{
|
1846 |
+
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1847 |
+
jQuery('#wpvivid_clean_restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1848 |
+
jQuery('#wpvivid_rollback_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1849 |
+
jQuery('#wpvivid_restore_part').show();
|
1850 |
+
jQuery('#wpvivid_clean_part').hide();
|
1851 |
+
jQuery('#wpvivid_rollback_part').hide();
|
1852 |
+
var error_message = jsonarray.error;
|
1853 |
+
wpvivid_display_restore_msg(error_message,wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'],false);
|
1854 |
+
wpvivid_restore_unlock();
|
1855 |
+
}
|
1856 |
+
else if(jsonarray.status==='running')
|
1857 |
+
{
|
1858 |
+
wpvivid_display_restore_msg(jsonarray.log, wpvivid_restore_download_index, false);
|
1859 |
+
//wpvivid_display_restore_msg(jsonarray.log);
|
1860 |
+
setTimeout(function()
|
1861 |
+
{
|
1862 |
+
wpvivid_monitor_download_restore_task();
|
1863 |
+
}, 3000);
|
1864 |
+
}
|
1865 |
+
else if(jsonarray.status==='timeout')
|
1866 |
+
{
|
1867 |
+
wpvivid_get_download_restore_progress_retry++;
|
1868 |
+
if(wpvivid_get_download_restore_progress_retry>10)
|
1869 |
+
{
|
1870 |
+
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1871 |
+
jQuery('#wpvivid_clean_restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1872 |
+
jQuery('#wpvivid_rollback_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1873 |
+
jQuery('#wpvivid_restore_part').show();
|
1874 |
+
jQuery('#wpvivid_clean_part').hide();
|
1875 |
+
jQuery('#wpvivid_rollback_part').hide();
|
1876 |
+
var error_message = jsonarray.error;
|
1877 |
+
wpvivid_display_restore_msg(error_message);
|
1878 |
+
wpvivid_restore_unlock();
|
1879 |
+
}
|
1880 |
+
else
|
1881 |
+
{
|
1882 |
+
setTimeout(function()
|
1883 |
+
{
|
1884 |
+
wpvivid_monitor_download_restore_task();
|
1885 |
+
}, 3000);
|
1886 |
+
}
|
1887 |
+
}
|
1888 |
+
else
|
1889 |
+
{
|
1890 |
+
setTimeout(function()
|
1891 |
+
{
|
1892 |
+
wpvivid_monitor_download_restore_task();
|
1893 |
+
}, 3000);
|
1894 |
+
}
|
1895 |
+
}
|
1896 |
+
else
|
1897 |
+
{
|
1898 |
+
wpvivid_get_download_restore_progress_retry++;
|
1899 |
+
if(wpvivid_get_download_restore_progress_retry>10)
|
1900 |
+
{
|
1901 |
+
jQuery('#wpvivid_restore_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1902 |
+
jQuery('#wpvivid_clean_restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1903 |
+
jQuery('#wpvivid_rollback_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1904 |
+
jQuery('#wpvivid_restore_part').show();
|
1905 |
+
jQuery('#wpvivid_clean_part').hide();
|
1906 |
+
jQuery('#wpvivid_rollback_part').hide();
|
1907 |
+
var error_message = jsonarray.error;
|
1908 |
+
wpvivid_display_restore_msg(error_message);
|
1909 |
+
wpvivid_restore_unlock();
|
1910 |
+
}
|
1911 |
+
else
|
1912 |
+
{
|
1913 |
+
setTimeout(function()
|
1914 |
+
{
|
1915 |
+
wpvivid_monitor_download_restore_task();
|
1916 |
+
}, 3000);
|
1917 |
+
}
|
1918 |
+
}
|
1919 |
+
}
|
1920 |
+
else
|
1921 |
+
{
|
1922 |
+
setTimeout(function()
|
1923 |
+
{
|
1924 |
+
wpvivid_monitor_download_restore_task();
|
1925 |
+
}, 3000);
|
1926 |
+
}
|
1927 |
+
}
|
1928 |
+
catch(err){
|
1929 |
+
setTimeout(function()
|
1930 |
+
{
|
1931 |
+
wpvivid_monitor_download_restore_task();
|
1932 |
+
}, 3000);
|
1933 |
+
}
|
1934 |
+
}, function(XMLHttpRequest, textStatus, errorThrown)
|
1935 |
+
{
|
1936 |
+
setTimeout(function()
|
1937 |
+
{
|
1938 |
+
wpvivid_monitor_download_restore_task();
|
1939 |
+
}, 1000);
|
1940 |
+
});
|
1941 |
+
}
|
1942 |
+
|
1943 |
+
function wpvivid_update_restore_msg(msg)
|
1944 |
+
{
|
1945 |
+
//jQuery('#wpvivid_restore_log:last-child').html(msg);
|
1946 |
+
jQuery('#wpvivid_restore_log > div:last').append(msg);
|
1947 |
+
}
|
1948 |
+
|
1949 |
/**
|
1950 |
* Monitor restore task.
|
1951 |
*/
|
2067 |
});
|
2068 |
}
|
2069 |
|
2070 |
+
function wpvivid_display_restore_msg(msg, div_id, append = true){
|
2071 |
+
if(typeof div_id == 'undefined') {
|
2072 |
+
var restore_msg = "<div style=\"clear:both;\">" + msg + "</div>";
|
2073 |
+
}
|
2074 |
+
else{
|
2075 |
+
var restore_msg = "<div id=\"restore_file_"+div_id+"\" style=\"clear:both;\">" + msg + "</div>";
|
2076 |
+
}
|
2077 |
+
if(append == true) {
|
2078 |
+
jQuery('#wpvivid_restore_log').append(restore_msg);
|
2079 |
+
}
|
2080 |
+
else{
|
2081 |
+
if(jQuery('#restore_file_'+div_id).length )
|
2082 |
+
{
|
2083 |
+
jQuery('#restore_file_'+div_id).html(msg);
|
2084 |
+
}
|
2085 |
+
else
|
2086 |
+
{
|
2087 |
+
jQuery('#wpvivid_restore_log').append(restore_msg);
|
2088 |
+
}
|
2089 |
+
|
2090 |
+
}
|
2091 |
}
|
2092 |
|
2093 |
/**
|
2245 |
jQuery('#wpvivid_postbox_backup').css({'pointer-events': 'none', 'opacity': '1'});
|
2246 |
jQuery('#wpvivid_postbox_backup_schedule').css({'pointer-events': 'none', 'opacity': '1'});
|
2247 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '1'});
|
2248 |
+
jQuery('#wpvivid_tab_backup').css({'pointer-events': 'none', 'opacity': '1'});
|
2249 |
+
jQuery('#wpvivid_tab_backup_log').css({'pointer-events': 'none', 'opacity': '1'});
|
2250 |
jQuery('#wpvivid_tab_restore').css({'pointer-events': 'none', 'opacity': '1'});
|
2251 |
jQuery('#page-backups').css({'pointer-events': 'none', 'opacity': '1'});
|
2252 |
jQuery('#storage-page').css({'pointer-events': 'none', 'opacity': '1'});
|
2263 |
jQuery('#wpvivid_postbox_backup').css({'pointer-events': 'auto', 'opacity': '1'});
|
2264 |
jQuery('#wpvivid_postbox_backup_schedule').css({'pointer-events': 'auto', 'opacity': '1'});
|
2265 |
jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
2266 |
+
jQuery('#wpvivid_tab_backup').css({'pointer-events': 'auto', 'opacity': '1'});
|
2267 |
+
jQuery('#wpvivid_tab_backup_log').css({'pointer-events': 'auto', 'opacity': '1'});
|
2268 |
jQuery('#wpvivid_tab_restore').css({'pointer-events': 'auto', 'opacity': '1'});
|
2269 |
jQuery('#page-backups').css({'pointer-events': 'auto', 'opacity': '1'});
|
2270 |
jQuery('#storage-page').css({'pointer-events': 'auto', 'opacity': '1'});
|
2390 |
location.href =ajaxurl+'?action=wpvivid_create_debug_package';
|
2391 |
}
|
2392 |
|
2393 |
+
function wpvivid_click_send_debug_info(){
|
2394 |
+
var wpvivid_user_mail = jQuery('#wpvivid_user_mail').val();
|
2395 |
+
var ajax_data = {
|
2396 |
+
'action': 'wpvivid_send_debug_info',
|
2397 |
+
'user_mail': wpvivid_user_mail
|
2398 |
+
};
|
2399 |
+
wpvivid_post_request(ajax_data, function (data) {
|
2400 |
+
try {
|
2401 |
+
var jsonarray = jQuery.parseJSON(data);
|
2402 |
+
if (jsonarray.result === "success") {
|
2403 |
+
alert("Send succeeded.");
|
2404 |
+
}
|
2405 |
+
else {
|
2406 |
+
alert(jsonarray.error);
|
2407 |
+
}
|
2408 |
+
}
|
2409 |
+
catch (err) {
|
2410 |
+
alert(err);
|
2411 |
+
}
|
2412 |
+
}, function (XMLHttpRequest, textStatus, errorThrown) {
|
2413 |
+
var error_message = wpvivid_output_ajaxerror('sending debug information', textStatus, errorThrown);
|
2414 |
+
alert(error_message);
|
2415 |
+
});
|
2416 |
+
}
|
2417 |
+
|
2418 |
/**
|
2419 |
* Output ajax error in a standard format.
|
2420 |
*
|
admin/partials/images/storage-local(gray).png
ADDED
Binary file
|
admin/partials/images/storage-local.png
ADDED
Binary file
|
admin/partials/wpvivid-admin-display.php
CHANGED
@@ -10,13 +10,12 @@
|
|
10 |
* @package WPvivid
|
11 |
* @subpackage WPvivid/admin/partials
|
12 |
*/
|
|
|
13 |
if (!defined('WPVIVID_PLUGIN_DIR')){
|
14 |
die;
|
15 |
}
|
16 |
|
17 |
global $wpvivid_pulgin;
|
18 |
-
|
19 |
-
$last_backup_message=WPvivid_Setting::get_option('wpvivid_last_msg');
|
20 |
$backuplist=WPvivid_Backuplist::get_backuplist();
|
21 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
22 |
$schedule=WPvivid_Schedule::get_schedule();
|
@@ -71,24 +70,24 @@ do_action('show_notice');
|
|
71 |
<div id="poststuff">
|
72 |
<div id="post-body" class="metabox-holder columns-2">
|
73 |
<div id="post-body-content">
|
74 |
-
<div class="inside" style="margin-top:
|
75 |
<div id="general-page" class="wrap-tab-content wpvivid_tab_general" name="tab-backup" style="width:100%;">
|
76 |
-
<?php include_once
|
77 |
</div>
|
78 |
<div id="storage-page" class="wrap-tab-content wpvivid_tab_remote_storage" name="tab-storage" style="display:none;">
|
79 |
-
<?php include_once
|
80 |
</div>
|
81 |
<div id="settings-page" class="wrap-tab-content wpvivid_tab_setting" name="tab-setting" style="display:none;">
|
82 |
-
<?php include_once
|
83 |
</div>
|
84 |
<div id="debug-page" class="wrap-tab-content wpvivid_tab_debug" name="tab-debug" style="display:none;">
|
85 |
-
<?php include_once
|
86 |
</div>
|
87 |
<div id="logs-page" class="wrap-tab-content wpvivid_tab_log" name="tab-logs" style="display:none;">
|
88 |
-
<?php include_once
|
89 |
</div>
|
90 |
<div id="log-read-page" class="wrap-tab-content wpvivid_tab_read_log" style="display:none;">
|
91 |
-
<?php include_once
|
92 |
</div>
|
93 |
<?php do_action('wpvivid_backuprestore_add_page');?>
|
94 |
</div>
|
10 |
* @package WPvivid
|
11 |
* @subpackage WPvivid/admin/partials
|
12 |
*/
|
13 |
+
|
14 |
if (!defined('WPVIVID_PLUGIN_DIR')){
|
15 |
die;
|
16 |
}
|
17 |
|
18 |
global $wpvivid_pulgin;
|
|
|
|
|
19 |
$backuplist=WPvivid_Backuplist::get_backuplist();
|
20 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
21 |
$schedule=WPvivid_Schedule::get_schedule();
|
70 |
<div id="poststuff">
|
71 |
<div id="post-body" class="metabox-holder columns-2">
|
72 |
<div id="post-body-content">
|
73 |
+
<div class="inside" style="margin-top:0;">
|
74 |
<div id="general-page" class="wrap-tab-content wpvivid_tab_general" name="tab-backup" style="width:100%;">
|
75 |
+
<?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-backup-restore-page-display.php'; ?>
|
76 |
</div>
|
77 |
<div id="storage-page" class="wrap-tab-content wpvivid_tab_remote_storage" name="tab-storage" style="display:none;">
|
78 |
+
<?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-remote-storage-page-display.php'; ?>
|
79 |
</div>
|
80 |
<div id="settings-page" class="wrap-tab-content wpvivid_tab_setting" name="tab-setting" style="display:none;">
|
81 |
+
<?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-settings-page-display.php'; ?>
|
82 |
</div>
|
83 |
<div id="debug-page" class="wrap-tab-content wpvivid_tab_debug" name="tab-debug" style="display:none;">
|
84 |
+
<?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-website-info-page-display.php'; ?>
|
85 |
</div>
|
86 |
<div id="logs-page" class="wrap-tab-content wpvivid_tab_log" name="tab-logs" style="display:none;">
|
87 |
+
<?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-logs-page-display.php'; ?>
|
88 |
</div>
|
89 |
<div id="log-read-page" class="wrap-tab-content wpvivid_tab_read_log" style="display:none;">
|
90 |
+
<?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-log-read-page-display.php'; ?>
|
91 |
</div>
|
92 |
<?php do_action('wpvivid_backuprestore_add_page');?>
|
93 |
</div>
|
admin/partials/wpvivid-backup-restore-page-display.php
CHANGED
@@ -7,9 +7,14 @@ function wpvivid_backup_progress_rate(){
|
|
7 |
<div class="action-progress-bar" id="wpvivid_action_progress_bar">
|
8 |
<div class="action-progress-bar-percent" id="wpvivid_action_progress_bar_percent" style="height:24px;width:0"></div>
|
9 |
</div>
|
10 |
-
<div id="wpvivid_estimate_backup_info">
|
11 |
-
<div class="backup-basic-info"><span><?php _e('Database Size:', 'wpvivid'); ?></span><span id="wpvivid_backup_database_size"
|
12 |
-
<div class="backup-basic-info"><span><?php _e('File Size:', 'wpvivid'); ?></span><span id="wpvivid_backup_file_size"
|
|
|
|
|
|
|
|
|
|
|
13 |
</div>
|
14 |
<div style="clear:both;"></div>
|
15 |
<div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_current_doing"></p></div>
|
@@ -354,6 +359,13 @@ function wpvivid_backup_do_js(){
|
|
354 |
<?php
|
355 |
if($value['is_canceled'] == false){
|
356 |
$descript=$value['data']['descript'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
$backup_running_time=$value['data']['running_time'];
|
358 |
$output = '';
|
359 |
foreach (array(86400 => 'day', 3600 => 'hour', 60 => 'min', 1 => 'second') as $key => $value) {
|
7 |
<div class="action-progress-bar" id="wpvivid_action_progress_bar">
|
8 |
<div class="action-progress-bar-percent" id="wpvivid_action_progress_bar_percent" style="height:24px;width:0"></div>
|
9 |
</div>
|
10 |
+
<div id="wpvivid_estimate_backup_info" style="float: left;">
|
11 |
+
<div class="backup-basic-info"><span><?php _e('Database Size:', 'wpvivid'); ?></span><span id="wpvivid_backup_database_size">N/A</span></div>
|
12 |
+
<div class="backup-basic-info"><span><?php _e('File Size:', 'wpvivid'); ?></span><span id="wpvivid_backup_file_size">N/A</span></div>
|
13 |
+
</div>
|
14 |
+
<div id="wpvivid_estimate_upload_info" style="float: left;">
|
15 |
+
<div class="backup-basic-info"><span><?php _e('Total Size:', 'wpvivid'); ?></span><span>N/A</span></div>
|
16 |
+
<div class="backup-basic-info"><span><?php _e('Uploaded:', 'wpvivid'); ?></span><span>N/A</span></div>
|
17 |
+
<div class="backup-basic-info"><span><?php _e('Speed:', 'wpvivid'); ?></span><span>N/A</span></div>
|
18 |
</div>
|
19 |
<div style="clear:both;"></div>
|
20 |
<div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_current_doing"></p></div>
|
359 |
<?php
|
360 |
if($value['is_canceled'] == false){
|
361 |
$descript=$value['data']['descript'];
|
362 |
+
if($value['data']['type']){
|
363 |
+
$find_str = 'Total size: ';
|
364 |
+
if(stripos($descript, $find_str) != false) {
|
365 |
+
$pos = stripos($descript, $find_str);
|
366 |
+
$descript = substr($descript, 0, $pos);
|
367 |
+
}
|
368 |
+
}
|
369 |
$backup_running_time=$value['data']['running_time'];
|
370 |
$output = '';
|
371 |
foreach (array(86400 => 'day', 3600 => 'hour', 60 => 'min', 1 => 'second') as $key => $value) {
|
admin/partials/wpvivid-settings-page-display.php
CHANGED
@@ -410,6 +410,20 @@ function wpvivid_schedule_do_js()
|
|
410 |
?>
|
411 |
jQuery("input:radio[value='<?php echo $schedule['recurrence']?>']").prop('checked', true);
|
412 |
jQuery("input:radio[value='<?php echo $schedule['backup']['backup_files']?>']").prop('checked', true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
<?php
|
414 |
}
|
415 |
|
410 |
?>
|
411 |
jQuery("input:radio[value='<?php echo $schedule['recurrence']?>']").prop('checked', true);
|
412 |
jQuery("input:radio[value='<?php echo $schedule['backup']['backup_files']?>']").prop('checked', true);
|
413 |
+
jQuery("input:radio[name='save_local_remote'][value='remote']").click(function(){
|
414 |
+
<?php
|
415 |
+
$remote_id_array = WPvivid_Setting::get_user_history('remote_selected');
|
416 |
+
$remote_id = '';
|
417 |
+
foreach ($remote_id_array as $value){
|
418 |
+
$remote_id = $value;
|
419 |
+
}
|
420 |
+
if(empty($remote_id)){
|
421 |
+
?>
|
422 |
+
alert("There is no default remote storage configured. Please set it up first.");
|
423 |
+
<?php
|
424 |
+
}
|
425 |
+
?>
|
426 |
+
});
|
427 |
<?php
|
428 |
}
|
429 |
|
admin/partials/wpvivid-website-info-page-display.php
CHANGED
@@ -1,6 +1,18 @@
|
|
1 |
<table class="widefat">
|
|
|
2 |
<div style="padding-left: 10px;">
|
3 |
-
<?php _e('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
</div>
|
5 |
<div class="schedule-tab-block">
|
6 |
<input class="button-primary" id="wpvivid_download_website_info" type="submit" name="download-website-info" value="<?php esc_attr_e( 'Download', 'wpvivid' ); ?>" />
|
1 |
<table class="widefat">
|
2 |
+
<div style="padding: 0 0 20px 10px;">There are two ways available to send us the debug information. The first one is recommended.</div>
|
3 |
<div style="padding-left: 10px;">
|
4 |
+
<?php _e('Method 1. If you have configured SMTP on your site, enter your email address and click the button below to send us the relevant information (website info and errors logs) when you are encountering errors. This will help us figure out what happened. Once the issue is resolved, we will inform you by your email address.', 'wpvivid'); ?>
|
5 |
+
</div>
|
6 |
+
<div style="padding:10px 10px 0">
|
7 |
+
<span>WPvivid support email:</span><input type="text" id="wpvivid_support_mail" value="support@wpvivid.com" readonly />
|
8 |
+
<span>Your email:</span><input type="text" id="wpvivid_user_mail" />
|
9 |
+
</div>
|
10 |
+
<div class="schedule-tab-block">
|
11 |
+
<input class="button-primary" type="submit" value="<?php esc_attr_e( 'Send Debug Information to Us', 'wpvivid' ); ?>" onclick="wpvivid_click_send_debug_info();" />
|
12 |
+
</div>
|
13 |
+
<div style="clear:both;"></div>
|
14 |
+
<div style="padding-left: 10px;">
|
15 |
+
<?php _e('Method 2. If you didn’t configure SMTP on your site, click the button below to download the relevant information (website info and error logs) to your PC when you are encountering some errors. Sending the files to us will help us diagnose what happened.', 'wpvivid'); ?>
|
16 |
</div>
|
17 |
<div class="schedule-tab-block">
|
18 |
<input class="button-primary" id="wpvivid_download_website_info" type="submit" name="download-website-info" value="<?php esc_attr_e( 'Download', 'wpvivid' ); ?>" />
|
includes/class-wpvivid-backup-database.php
CHANGED
@@ -3,6 +3,8 @@
|
|
3 |
if (!defined('WPVIVID_PLUGIN_DIR')){
|
4 |
die;
|
5 |
}
|
|
|
|
|
6 |
class WPvivid_Backup_Database
|
7 |
{
|
8 |
public $wpdb_obj;
|
@@ -18,6 +20,31 @@ class WPvivid_Backup_Database
|
|
18 |
private $CharsetArray;
|
19 |
private $CollateArray;
|
20 |
private $task_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
public function __construct() {
|
23 |
$this->CharsetArray = array();
|
@@ -26,74 +53,120 @@ class WPvivid_Backup_Database
|
|
26 |
|
27 |
public function backup_database($data,$task_id = '')
|
28 |
{
|
29 |
-
$
|
30 |
-
|
31 |
-
if (is_multisite() && !defined('MULTISITE'))
|
32 |
{
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$pdo=new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
56 |
-
$result = $pdo -> query('Select @@Version;');
|
57 |
-
|
58 |
-
if($result && $result->rowCount()>0)
|
59 |
{
|
60 |
-
$
|
61 |
-
$
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
|
68 |
-
return array('result'=>'failed','error'=>'Your PHP version is too old. Please upgrade at least to PHP 5.3.0.');
|
69 |
-
}
|
70 |
-
if(version_compare('4.1.0',$version) > 0){
|
71 |
-
return array('result'=>'failed','error'=>'Your MySQL version is too old. Please upgrade at least to MySQL 4.1.0.');
|
72 |
-
}
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
|
90 |
-
|
91 |
$dump->log=$data['log'];
|
92 |
$dump->task_id=$task_id;
|
93 |
$dump->start($backup_file);
|
94 |
unset($pdo);
|
95 |
-
}catch (Exception $e)
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
$files = array();
|
@@ -101,6 +174,85 @@ class WPvivid_Backup_Database
|
|
101 |
return array('result'=>'succeed','files'=>$files);
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
public function check_big_db($pdo,$data)
|
105 |
{
|
106 |
$sth = $pdo->query('SHOW TABLE STATUS');
|
@@ -122,4 +274,30 @@ class WPvivid_Backup_Database
|
|
122 |
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_DB,0,$message);
|
123 |
}
|
124 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
3 |
if (!defined('WPVIVID_PLUGIN_DIR')){
|
4 |
die;
|
5 |
}
|
6 |
+
define('NECESSARY','1');
|
7 |
+
define('OPTION','0');
|
8 |
class WPvivid_Backup_Database
|
9 |
{
|
10 |
public $wpdb_obj;
|
20 |
private $CharsetArray;
|
21 |
private $CollateArray;
|
22 |
private $task_id;
|
23 |
+
public $must_privilege = array(
|
24 |
+
'backup' => array(
|
25 |
+
'SELECT' => NECESSARY,
|
26 |
+
'INSERT' => NECESSARY,
|
27 |
+
'UPDATE' => NECESSARY,
|
28 |
+
'SHOW VIEW' => OPTION,
|
29 |
+
'LOCK TABLES' => OPTION,
|
30 |
+
'EVENT' => OPTION,
|
31 |
+
'TRIGGER' => OPTION,
|
32 |
+
'CREATE ROUTINE' => OPTION,
|
33 |
+
),
|
34 |
+
'restore' => array(
|
35 |
+
'SELECT' => NECESSARY,
|
36 |
+
'INSERT' => NECESSARY,
|
37 |
+
'UPDATE' => NECESSARY,
|
38 |
+
'DROP' => NECESSARY,
|
39 |
+
'CREATE' => NECESSARY,
|
40 |
+
'SHOW VIEW' => OPTION,
|
41 |
+
'EVENT' => OPTION,
|
42 |
+
'TRIGGER' => OPTION,
|
43 |
+
'CREATE ROUTINE' => OPTION,
|
44 |
+
'CREATE VIEW' => OPTION,
|
45 |
+
'LOCK TABLES' => OPTION,
|
46 |
+
)
|
47 |
+
);
|
48 |
|
49 |
public function __construct() {
|
50 |
$this->CharsetArray = array();
|
53 |
|
54 |
public function backup_database($data,$task_id = '')
|
55 |
{
|
56 |
+
$dump=null;
|
57 |
+
try
|
|
|
58 |
{
|
59 |
+
$this->task_id=$task_id;
|
60 |
+
global $wpdb, $wp_version, $required_php_version, $required_mysql_version;
|
61 |
+
if (is_multisite() && !defined('MULTISITE'))
|
62 |
+
{
|
63 |
+
$prefix = $wpdb->base_prefix;
|
64 |
+
} else {
|
65 |
+
$prefix = $wpdb->get_blog_prefix(0);
|
66 |
+
}
|
67 |
|
68 |
+
$this->blogversion = $wp_version;
|
69 |
+
$this->wpdb_obj = $wpdb;
|
70 |
+
$this->requiredmysql = $required_mysql_version;
|
71 |
+
$this->requiredphp = $required_php_version;
|
72 |
+
$this->UserName = DB_USER;
|
73 |
+
$this->Password = DB_PASSWORD;
|
74 |
+
$this->DBName = DB_NAME;
|
75 |
+
$this->HOST = DB_HOST;
|
76 |
+
$this->DOMAIN = filter_input(INPUT_SERVER, 'HTTP_HOST');
|
77 |
|
78 |
+
$basename = basename($data['path'],$data['compress']['compress_type']).'sql';
|
79 |
|
80 |
+
$backup_file = dirname($data['path']).DIRECTORY_SEPARATOR.$basename;
|
81 |
|
82 |
+
$privileges = array();
|
83 |
+
require_once 'class-wpvivid-mysqldump.php';
|
84 |
+
if(class_exists('PDO'))
|
|
|
|
|
|
|
|
|
85 |
{
|
86 |
+
$res = explode(':',DB_HOST);
|
87 |
+
$db_host = $res[0];
|
88 |
+
$db_port = empty($res[1])?'':$res[1];
|
89 |
+
if(!empty($db_port))
|
90 |
+
$db_host = $db_host.':'.$db_port;
|
91 |
+
try{
|
92 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
93 |
+
}catch (Exception $e)
|
94 |
+
{
|
95 |
+
if(!empty($db_port)){
|
96 |
+
$db_host = $res[0];
|
97 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
98 |
+
if(empty($pdo) || !$pdo){
|
99 |
+
return array('result' => 'WPVIVID_FAILED','error' =>'The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.');
|
100 |
+
}
|
101 |
+
}else{
|
102 |
+
return array('result' => 'WPVIVID_FAILED','error' =>'The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.');
|
103 |
+
}
|
104 |
+
}
|
105 |
|
106 |
+
$result = $pdo -> query('Select @@Version;');
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
+
if($result && $result->rowCount()>0)
|
109 |
+
{
|
110 |
+
$datas = $result -> fetchAll();
|
111 |
+
$version = $datas[0][0];
|
112 |
+
}
|
113 |
+
else{
|
114 |
+
return array('result'=>'failed','error'=>'MySQL version is not obtained. Please check if MySQL is installed or not.');
|
115 |
+
}
|
116 |
|
117 |
+
if(version_compare('5.3.0',phpversion()) > 0){
|
118 |
+
return array('result'=>'failed','error'=>'Your PHP version is too old. Please upgrade at least to PHP 5.3.0.');
|
119 |
+
}
|
120 |
+
if(version_compare('4.1.0',$version) > 0){
|
121 |
+
return array('result'=>'failed','error'=>'Your MySQL version is too old. Please upgrade at least to MySQL 4.1.0.');
|
122 |
+
}
|
123 |
|
124 |
+
$result = $this -> check_privilege('backup',$pdo);
|
125 |
+
if($result['result'] === WPVIVID_FAILED){
|
126 |
+
return $result;
|
127 |
+
}else{
|
128 |
+
$privileges = $result['data'];
|
129 |
+
}
|
130 |
+
|
131 |
+
$this->check_big_db($pdo,$data);
|
132 |
+
$this->check_max_allowed_packet($pdo);
|
133 |
+
|
134 |
+
unset($pdo);
|
135 |
+
}else{
|
136 |
+
return array('result'=>'failed','error'=>'PDO extension not found. Please check if PDO extension is installed or not.');
|
137 |
+
}
|
138 |
+
|
139 |
+
$exclude = array('/^(?!'.$prefix.')/');
|
140 |
+
$dsn = 'mysql:host=' . $db_host . ';dbname=' . DB_NAME;
|
141 |
+
if(!empty($data['meta']))
|
142 |
+
{
|
143 |
+
$dump = new WPvivid_Mysqldump($dsn, DB_USER, DB_PASSWORD , array('include-tables'=>$data['meta'],'exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
|
144 |
+
$dump -> set_privilege($privileges);
|
145 |
+
}else{
|
146 |
+
$dump = new WPvivid_Mysqldump($dsn, DB_USER, DB_PASSWORD , array('exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
|
147 |
+
$dump -> set_privilege($privileges);
|
148 |
+
}
|
149 |
|
150 |
+
if(file_exists($backup_file))
|
151 |
+
@unlink($backup_file);
|
152 |
$dump->log=$data['log'];
|
153 |
$dump->task_id=$task_id;
|
154 |
$dump->start($backup_file);
|
155 |
unset($pdo);
|
156 |
+
}catch (Exception $e)
|
157 |
+
{
|
158 |
+
global $wpvivid_pulgin;
|
159 |
+
$str_last_query_string='';
|
160 |
+
if(!is_null($dump))
|
161 |
+
{
|
162 |
+
$str_last_query_string=$dump->last_query_string;
|
163 |
+
}
|
164 |
+
if(!empty($str_last_query_string))
|
165 |
+
{
|
166 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('last query string:'.$str_last_query_string,'error');
|
167 |
+
}
|
168 |
+
$message = 'A exception ('.get_class($e).') occurred '.$e->getMessage().' (Code: '.$e->getCode().', line '.$e->getLine().' in '.$e->getFile().')';
|
169 |
+
return array('result'=>'failed','error'=>$message);
|
170 |
}
|
171 |
|
172 |
$files = array();
|
174 |
return array('result'=>'succeed','files'=>$files);
|
175 |
}
|
176 |
|
177 |
+
public function check_privilege($type,$pdo){
|
178 |
+
global $wpvivid_pulgin;
|
179 |
+
$temp_privileges = array();
|
180 |
+
foreach ($this -> must_privilege[$type] as $key => $value){
|
181 |
+
$temp_privileges[$key] = 0;
|
182 |
+
}
|
183 |
+
|
184 |
+
$res = explode(':',DB_HOST);
|
185 |
+
$db_host = $res[0];
|
186 |
+
$db_port = empty($res[1])?'':$res[1];
|
187 |
+
if(!empty($db_port))
|
188 |
+
$db_host = $db_host.':'.$db_port;
|
189 |
+
$result = $pdo -> query('show grants for `'.DB_USER.'`@`'.$db_host.'`;');
|
190 |
+
if(!$result && !empty($db_port))
|
191 |
+
{
|
192 |
+
$db_host = $res[0];
|
193 |
+
$result = $pdo -> query('show grants for `'.DB_USER.'`@`'.$db_host.'`;');
|
194 |
+
}
|
195 |
+
|
196 |
+
if($result && $result->rowCount()>0)
|
197 |
+
{
|
198 |
+
$datas = $result -> fetchAll();
|
199 |
+
foreach ($datas as $data){
|
200 |
+
$sql = $data[0];
|
201 |
+
if(stristr($sql,'USAGE'))
|
202 |
+
continue;
|
203 |
+
$result = array();
|
204 |
+
$pattern = "#^GRANT (.*?) TO '".DB_USER."'@'".$db_host."'#";
|
205 |
+
preg_match_all($pattern,$sql,$result);
|
206 |
+
$results = explode(' ON ',$result[1][0]);
|
207 |
+
$tables = explode('.',$results[1]);
|
208 |
+
|
209 |
+
if(trim($tables[0],'`') == '*' || trim($tables[0],'`') == DB_NAME){
|
210 |
+
$privileges = trim($results[0]);
|
211 |
+
$privileges = strtoupper($privileges);
|
212 |
+
if($privileges == 'ALL PRIVILEGES'){
|
213 |
+
foreach ($temp_privileges as $key => $value){
|
214 |
+
$temp_privileges[$key] = 1;
|
215 |
+
}
|
216 |
+
}else{
|
217 |
+
$privileges = explode(',',$privileges);
|
218 |
+
foreach ($privileges as $privilege){
|
219 |
+
$privilege = trim($privilege);
|
220 |
+
if(array_key_exists($privilege,$temp_privileges)){
|
221 |
+
$temp_privileges[$privilege] = 1;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}else{
|
228 |
+
foreach ($temp_privileges as $key => $value){
|
229 |
+
$temp_privileges[$key] = 1;
|
230 |
+
}
|
231 |
+
|
232 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('When performing database check, an anomaly is encountered.','notice');
|
233 |
+
}
|
234 |
+
$options = array();
|
235 |
+
$necessary = array();
|
236 |
+
foreach ($temp_privileges as $key => $value){
|
237 |
+
if($value == 0){
|
238 |
+
if($this -> must_privilege[$type][$key] === NECESSARY){
|
239 |
+
$necessary[] = $key;
|
240 |
+
}
|
241 |
+
if($this -> must_privilege[$type][$key] === OPTION){
|
242 |
+
$options[] = $key;
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
if(!empty($necessary)){
|
247 |
+
return array('result' => WPVIVID_FAILED,'error' => 'Please grant the following database privileges: '.implode(',',$necessary));
|
248 |
+
}
|
249 |
+
if(!empty($options)){
|
250 |
+
global $wpvivid_pulgin;
|
251 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('The lack of optional database privileges including '.implode(',',$options),'notice');
|
252 |
+
}
|
253 |
+
return array('result' => WPVIVID_SUCCESS,'data' => $temp_privileges);
|
254 |
+
}
|
255 |
+
|
256 |
public function check_big_db($pdo,$data)
|
257 |
{
|
258 |
$sth = $pdo->query('SHOW TABLE STATUS');
|
274 |
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_DB,0,$message);
|
275 |
}
|
276 |
}
|
277 |
+
|
278 |
+
public function check_max_allowed_packet($pdo)
|
279 |
+
{
|
280 |
+
global $wpvivid_pulgin;
|
281 |
+
|
282 |
+
$max_allowed_packet = $pdo->query("SELECT @@session.max_allowed_packet;");
|
283 |
+
if($max_allowed_packet)
|
284 |
+
{
|
285 |
+
$max_allowed_packet = $max_allowed_packet -> fetchAll();
|
286 |
+
if(is_array($max_allowed_packet)&&isset($max_allowed_packet[0])&&isset($max_allowed_packet[0][0]))
|
287 |
+
{
|
288 |
+
if($max_allowed_packet[0][0]<1048576)
|
289 |
+
{
|
290 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('warning: max_allowed_packet less than 1M :'.size_format($max_allowed_packet[0][0],2),'notice');
|
291 |
+
}
|
292 |
+
else if($max_allowed_packet[0][0]<33554432)
|
293 |
+
{
|
294 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('max_allowed_packet less than 32M :'.size_format($max_allowed_packet[0][0],2),'notice');
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
else
|
299 |
+
{
|
300 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('get max_allowed_packet failed ','notice');
|
301 |
+
}
|
302 |
+
}
|
303 |
}
|
includes/class-wpvivid-backup-site.php
CHANGED
@@ -39,9 +39,10 @@ class WPvivid_Backup_Site
|
|
39 |
//$type,$path,$size,$no_compress,$use_temp_file,$use_temp_size
|
40 |
require_once 'class-wpvivid-zipclass.php';
|
41 |
$zipclass = new WPvivid_ZipClass();
|
42 |
-
|
|
|
43 |
{
|
44 |
-
return array('result'=>'failed','error'=>$
|
45 |
}
|
46 |
switch ($data['type'])
|
47 |
{
|
39 |
//$type,$path,$size,$no_compress,$use_temp_file,$use_temp_size
|
40 |
require_once 'class-wpvivid-zipclass.php';
|
41 |
$zipclass = new WPvivid_ZipClass();
|
42 |
+
$error=$zipclass->getLastError();
|
43 |
+
if(!empty($error))
|
44 |
{
|
45 |
+
return array('result'=>'failed','error'=>$error);
|
46 |
}
|
47 |
switch ($data['type'])
|
48 |
{
|
includes/class-wpvivid-backup.php
CHANGED
@@ -13,7 +13,7 @@ define('WPVIVID_BACKUP_TYPE_CORE','backup_core');
|
|
13 |
define('WPVIVID_BACKUP_TYPE_OTHERS','backup_others');
|
14 |
define('WPVIVID_BACKUP_TYPE_MERGE','backup_merge');
|
15 |
|
16 |
-
include_once
|
17 |
class WPvivid_Backup{
|
18 |
private $i_progress;
|
19 |
private $i_step;
|
@@ -21,7 +21,7 @@ class WPvivid_Backup{
|
|
21 |
public $log;
|
22 |
public $task_id;
|
23 |
|
24 |
-
|
25 |
{
|
26 |
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
27 |
if(!isset($options['log_save_location']))
|
@@ -29,40 +29,42 @@ class WPvivid_Backup{
|
|
29 |
WPvivid_Setting::set_default_common_option();
|
30 |
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
31 |
}
|
32 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'updraft', '/').'#'; // Updraft Plus backup directory
|
33 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS).DIRECTORY_SEPARATOR.'backwpup', '/').'#'; // BackWPup backup directory
|
34 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS).DIRECTORY_SEPARATOR.'backup-guard', '/').'#'; // Wordpress Backup and Migrate Plugin backup directory
|
35 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'ai1wm-backups', '/').'#'; // All-in-one WP migration backup directory
|
36 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'backups', '/').'#'; // Xcloner backup directory
|
37 |
-
|
38 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'upgrade', '/').'#';
|
39 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.
|
40 |
-
$regex[]='#^'.preg_quote(
|
41 |
-
$regex[]='#^'.preg_quote(
|
|
|
42 |
switch ($type_name)
|
43 |
{
|
44 |
case WPVIVID_BACKUP_TYPE_CONTENT:
|
45 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_PLUGIN), '/').'#';
|
46 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_THEMES), '/').'#';
|
47 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS), '/').'#';
|
48 |
break;
|
49 |
case WPVIVID_BACKUP_TYPE_CORE:
|
50 |
$abs_path = $this ->get_default_directory(WPVIVID_BACKUP_TYPE_CORE).DIRECTORY_SEPARATOR;
|
51 |
-
$regex[]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT), '/').'#';
|
52 |
-
$regex[]='#^'.preg_quote($abs_path.'wp-snapshots', '/').'#'; // Duplicator backup directory
|
53 |
-
$regex[]='#^'.preg_quote($abs_path.'.maintenance', '/').'#';
|
54 |
break;
|
55 |
}
|
56 |
return $regex;
|
57 |
}
|
58 |
|
59 |
public function get_default_directory($type_name = ''){
|
|
|
60 |
$paths = array(
|
61 |
WPVIVID_BACKUP_TYPE_CORE => $this -> transfer_path(dirname(WP_CONTENT_DIR)),
|
62 |
WPVIVID_BACKUP_TYPE_CONTENT => $this -> transfer_path(WP_CONTENT_DIR),
|
63 |
WPVIVID_BACKUP_TYPE_PLUGIN => $this -> transfer_path(WP_PLUGIN_DIR),
|
64 |
WPVIVID_BACKUP_TYPE_THEMES => $this -> transfer_path(get_theme_root()),
|
65 |
-
WPVIVID_BACKUP_TYPE_UPLOADS => $this -> transfer_path(
|
66 |
);
|
67 |
|
68 |
if(empty($type_name) || empty($paths[$type_name])){
|
@@ -116,12 +118,14 @@ class WPvivid_Backup{
|
|
116 |
$backup_job=WPvivid_taskmanager::get_backup_sub_task_progress($this->task_id,'backup',$type_name);
|
117 |
if($backup_job&&$backup_job['finished']==1)
|
118 |
{
|
|
|
119 |
$result =$backup_job['job_data'];
|
120 |
}
|
121 |
else
|
122 |
{
|
123 |
global $wpvivid_pulgin;
|
124 |
$wpvivid_pulgin->set_time_limit($this->task_id);
|
|
|
125 |
$data=$this->get_backup_needed_data($type_name,$extra_data);
|
126 |
$result = $this->backup_loop_ex($data);
|
127 |
}
|
@@ -136,6 +140,7 @@ class WPvivid_Backup{
|
|
136 |
'files' => $result['files'],
|
137 |
);
|
138 |
}else{
|
|
|
139 |
$flag = false;
|
140 |
$error =$result['error'];
|
141 |
break;
|
@@ -159,14 +164,17 @@ class WPvivid_Backup{
|
|
159 |
global $wpvivid_pulgin;
|
160 |
$wpvivid_pulgin->set_time_limit($this->task_id);
|
161 |
|
|
|
162 |
$res =$this->Merge_backup($type);
|
163 |
|
164 |
if($res['result'] == 'succeed')
|
165 |
{
|
|
|
166 |
$zip_result['data']['meta']=array('type_name' => WPVIVID_BACKUP_TYPE_MERGE , 'files' => $res['files']);
|
167 |
}
|
168 |
else
|
169 |
{
|
|
|
170 |
$zip_result =array(
|
171 |
'result' => 'failed',
|
172 |
'error' => $error,
|
@@ -227,7 +235,10 @@ class WPvivid_Backup{
|
|
227 |
if($result['result']=='succeed')
|
228 |
{
|
229 |
$files=$result['files'];
|
|
|
|
|
230 |
$result = $backup_site -> backup_files($data,$files,$this->task_id);
|
|
|
231 |
foreach ($files as $sql_file)
|
232 |
{
|
233 |
@unlink($sql_file);
|
@@ -238,7 +249,10 @@ class WPvivid_Backup{
|
|
238 |
{
|
239 |
$files=array();
|
240 |
$files=apply_filters('wpvivid_backup_get_files_list',$files,$data);
|
|
|
|
|
241 |
$result = $backup_site -> backup_files($data,$files,$this->task_id);
|
|
|
242 |
}
|
243 |
$res = array();
|
244 |
|
@@ -270,14 +284,17 @@ class WPvivid_Backup{
|
|
270 |
$data['compress']=$this->options['backup_options']['compress'];
|
271 |
$data['log'] = $this->log;
|
272 |
|
|
|
273 |
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,0,'Start compressing backup packages for a complete backup.');
|
274 |
$result = $backup_site -> backup_files($data,$file_list,$this->task_id);
|
275 |
$res = array();
|
276 |
if(!is_array($result))
|
277 |
{
|
|
|
278 |
$res['result'] = 'failed';
|
279 |
$res['error'] = $result['error'];
|
280 |
}else{
|
|
|
281 |
$res['result'] = 'succeed';
|
282 |
$res['files'] = $result['meta'];
|
283 |
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,1,'File compression finished.',$res);
|
@@ -286,6 +303,7 @@ class WPvivid_Backup{
|
|
286 |
{
|
287 |
foreach ($item['files'] as $file)
|
288 |
{
|
|
|
289 |
@unlink(WP_CONTENT_DIR.'/'. $this->options['backup_options']['dir'].DIRECTORY_SEPARATOR.$file['file_name']);
|
290 |
}
|
291 |
}
|
@@ -333,7 +351,7 @@ class WPvivid_Backup{
|
|
333 |
global $wpvivid_pulgin;
|
334 |
$wpvivid_pulgin->check_cancel_backup($this->task_id);
|
335 |
|
336 |
-
$message='Uploading '.$current_name.' Total size: '.size_format($current_size,2).'
|
337 |
|
338 |
$progress=intval(($offset/$current_size)*100);
|
339 |
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',$progress,0);
|
@@ -381,38 +399,41 @@ class WPvivid_Backup{
|
|
381 |
return $files;
|
382 |
}
|
383 |
private function getFileLoop(&$files,$path,$exclude_regex,$include_regex,$exclude_file_size,$include_dir = true){
|
384 |
-
|
|
|
385 |
$handler = opendir($path);
|
386 |
-
$count = 0;
|
387 |
while (($filename = readdir($handler)) !== false) {
|
388 |
if ($filename != "." && $filename != "..") {
|
389 |
$count++;
|
390 |
|
391 |
if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) {
|
392 |
-
if ($this->regex_match($exclude_regex, $path . DIRECTORY_SEPARATOR . $filename, 0)) {
|
393 |
if ($this->regex_match($include_regex, $path . DIRECTORY_SEPARATOR . $filename, 1)) {
|
394 |
$this->getFileLoop($files, $path . DIRECTORY_SEPARATOR . $filename, $exclude_regex, $include_regex, $include_dir);
|
395 |
}
|
396 |
}
|
397 |
} else {
|
398 |
-
if
|
399 |
-
|
400 |
-
} else {
|
401 |
-
if (filesize($path . DIRECTORY_SEPARATOR . $filename) < $exclude_file_size * 1024 * 1024) {
|
402 |
$files[] = $path . DIRECTORY_SEPARATOR . $filename;
|
|
|
|
|
|
|
|
|
403 |
}
|
404 |
}
|
405 |
}
|
406 |
}
|
407 |
}
|
|
|
|
|
408 |
}
|
409 |
-
|
410 |
$files[] = $path;
|
411 |
}
|
412 |
-
if($handler)
|
413 |
-
@closedir($handler);
|
414 |
}
|
415 |
|
|
|
416 |
private function regex_match($regex_array,$string,$mode)
|
417 |
{
|
418 |
if(empty($regex_array))
|
@@ -519,4 +540,151 @@ class WPvivid_Backup{
|
|
519 |
|
520 |
return $files;
|
521 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
}
|
13 |
define('WPVIVID_BACKUP_TYPE_OTHERS','backup_others');
|
14 |
define('WPVIVID_BACKUP_TYPE_MERGE','backup_merge');
|
15 |
|
16 |
+
include_once WPVIVID_PLUGIN_DIR .'/includes/class-wpvivid-rollback.php';
|
17 |
class WPvivid_Backup{
|
18 |
private $i_progress;
|
19 |
private $i_step;
|
21 |
public $log;
|
22 |
public $task_id;
|
23 |
|
24 |
+
public function get_default_exclude_regex($type_name = '')
|
25 |
{
|
26 |
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
27 |
if(!isset($options['log_save_location']))
|
29 |
WPvivid_Setting::set_default_common_option();
|
30 |
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
31 |
}
|
32 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'updraft', '/').'#'; // Updraft Plus backup directory
|
33 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS).DIRECTORY_SEPARATOR.'backwpup', '/').'#'; // BackWPup backup directory
|
34 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS).DIRECTORY_SEPARATOR.'backup-guard', '/').'#'; // Wordpress Backup and Migrate Plugin backup directory
|
35 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'ai1wm-backups', '/').'#'; // All-in-one WP migration backup directory
|
36 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'backups', '/').'#'; // Xcloner backup directory
|
37 |
+
|
38 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'upgrade', '/').'#';
|
39 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'wpvivid', '/').'#';
|
40 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir(), '/').'#';
|
41 |
+
$regex['directory'][]='#^'.preg_quote(WPVIVID_PLUGIN_DIR, '/').'#';
|
42 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.$options['log_save_location'], '/').'#';
|
43 |
switch ($type_name)
|
44 |
{
|
45 |
case WPVIVID_BACKUP_TYPE_CONTENT:
|
46 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_PLUGIN), '/').'#';
|
47 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_THEMES), '/').'#';
|
48 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS), '/').'#';
|
49 |
break;
|
50 |
case WPVIVID_BACKUP_TYPE_CORE:
|
51 |
$abs_path = $this ->get_default_directory(WPVIVID_BACKUP_TYPE_CORE).DIRECTORY_SEPARATOR;
|
52 |
+
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT), '/').'#';
|
53 |
+
$regex['directory'][]='#^'.preg_quote($abs_path.'wp-snapshots', '/').'#'; // Duplicator backup directory
|
54 |
+
$regex['file'][]='#^'.preg_quote($abs_path.'.maintenance', '/').'#';
|
55 |
break;
|
56 |
}
|
57 |
return $regex;
|
58 |
}
|
59 |
|
60 |
public function get_default_directory($type_name = ''){
|
61 |
+
$upload_dir = wp_upload_dir();
|
62 |
$paths = array(
|
63 |
WPVIVID_BACKUP_TYPE_CORE => $this -> transfer_path(dirname(WP_CONTENT_DIR)),
|
64 |
WPVIVID_BACKUP_TYPE_CONTENT => $this -> transfer_path(WP_CONTENT_DIR),
|
65 |
WPVIVID_BACKUP_TYPE_PLUGIN => $this -> transfer_path(WP_PLUGIN_DIR),
|
66 |
WPVIVID_BACKUP_TYPE_THEMES => $this -> transfer_path(get_theme_root()),
|
67 |
+
WPVIVID_BACKUP_TYPE_UPLOADS => $this -> transfer_path($upload_dir['basedir']),
|
68 |
);
|
69 |
|
70 |
if(empty($type_name) || empty($paths[$type_name])){
|
118 |
$backup_job=WPvivid_taskmanager::get_backup_sub_task_progress($this->task_id,'backup',$type_name);
|
119 |
if($backup_job&&$backup_job['finished']==1)
|
120 |
{
|
121 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Compressing '.$type_name.' completed','notice');
|
122 |
$result =$backup_job['job_data'];
|
123 |
}
|
124 |
else
|
125 |
{
|
126 |
global $wpvivid_pulgin;
|
127 |
$wpvivid_pulgin->set_time_limit($this->task_id);
|
128 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Getting '.$type_name.' data.','notice');
|
129 |
$data=$this->get_backup_needed_data($type_name,$extra_data);
|
130 |
$result = $this->backup_loop_ex($data);
|
131 |
}
|
140 |
'files' => $result['files'],
|
141 |
);
|
142 |
}else{
|
143 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Failed to backup '.$type_name.', error: '.$result['error'],'notice');
|
144 |
$flag = false;
|
145 |
$error =$result['error'];
|
146 |
break;
|
164 |
global $wpvivid_pulgin;
|
165 |
$wpvivid_pulgin->set_time_limit($this->task_id);
|
166 |
|
167 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Prepare to compress backup_merge.','notice');
|
168 |
$res =$this->Merge_backup($type);
|
169 |
|
170 |
if($res['result'] == 'succeed')
|
171 |
{
|
172 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Compressing '.WPVIVID_BACKUP_TYPE_MERGE.' succeeded.','notice');
|
173 |
$zip_result['data']['meta']=array('type_name' => WPVIVID_BACKUP_TYPE_MERGE , 'files' => $res['files']);
|
174 |
}
|
175 |
else
|
176 |
{
|
177 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Compressing '.WPVIVID_BACKUP_TYPE_MERGE.' failed, error: '.$error,'notice');
|
178 |
$zip_result =array(
|
179 |
'result' => 'failed',
|
180 |
'error' => $error,
|
235 |
if($result['result']=='succeed')
|
236 |
{
|
237 |
$files=$result['files'];
|
238 |
+
//$files[]=$this->create_backup_json('db');
|
239 |
+
$this->log->WriteLog('Prepare to backup '.$data['type'].' files.','notice');
|
240 |
$result = $backup_site -> backup_files($data,$files,$this->task_id);
|
241 |
+
$this->log->WriteLog('Backing up '.$data['type'].' completed.','notice');
|
242 |
foreach ($files as $sql_file)
|
243 |
{
|
244 |
@unlink($sql_file);
|
249 |
{
|
250 |
$files=array();
|
251 |
$files=apply_filters('wpvivid_backup_get_files_list',$files,$data);
|
252 |
+
//$files[]=$this->create_backup_json('file');
|
253 |
+
$this->log->WriteLog('Prepare to backup '.$data['type'].' files.','notice');
|
254 |
$result = $backup_site -> backup_files($data,$files,$this->task_id);
|
255 |
+
$this->log->WriteLog('Backing up '.$data['type'].' completed.','notice');
|
256 |
}
|
257 |
$res = array();
|
258 |
|
284 |
$data['compress']=$this->options['backup_options']['compress'];
|
285 |
$data['log'] = $this->log;
|
286 |
|
287 |
+
$this->log->WriteLog('Start compressing backup packages for a complete backup.','notice');
|
288 |
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,0,'Start compressing backup packages for a complete backup.');
|
289 |
$result = $backup_site -> backup_files($data,$file_list,$this->task_id);
|
290 |
$res = array();
|
291 |
if(!is_array($result))
|
292 |
{
|
293 |
+
$this->log->WriteLog('File compression failed, error: '.$result['error'],'notice');
|
294 |
$res['result'] = 'failed';
|
295 |
$res['error'] = $result['error'];
|
296 |
}else{
|
297 |
+
$this->log->WriteLog('File compression finished.','notice');
|
298 |
$res['result'] = 'succeed';
|
299 |
$res['files'] = $result['meta'];
|
300 |
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,1,'File compression finished.',$res);
|
303 |
{
|
304 |
foreach ($item['files'] as $file)
|
305 |
{
|
306 |
+
$this->log->WriteLog('Cleaned up file, filename: '.WP_CONTENT_DIR.'/'. $this->options['backup_options']['dir'].DIRECTORY_SEPARATOR.$file['file_name'],'notice');
|
307 |
@unlink(WP_CONTENT_DIR.'/'. $this->options['backup_options']['dir'].DIRECTORY_SEPARATOR.$file['file_name']);
|
308 |
}
|
309 |
}
|
351 |
global $wpvivid_pulgin;
|
352 |
$wpvivid_pulgin->check_cancel_backup($this->task_id);
|
353 |
|
354 |
+
$message='Uploading '.$current_name.' Total size: '.size_format($current_size,2).' Uploaded: '.size_format($offset,2).' speed:'.$v.'kb/s';
|
355 |
|
356 |
$progress=intval(($offset/$current_size)*100);
|
357 |
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',$progress,0);
|
399 |
return $files;
|
400 |
}
|
401 |
private function getFileLoop(&$files,$path,$exclude_regex,$include_regex,$exclude_file_size,$include_dir = true){
|
402 |
+
$count = 0;
|
403 |
+
if(is_dir($path)) {
|
404 |
$handler = opendir($path);
|
|
|
405 |
while (($filename = readdir($handler)) !== false) {
|
406 |
if ($filename != "." && $filename != "..") {
|
407 |
$count++;
|
408 |
|
409 |
if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) {
|
410 |
+
if ($this->regex_match($exclude_regex['directory'], $path . DIRECTORY_SEPARATOR . $filename, 0)) {
|
411 |
if ($this->regex_match($include_regex, $path . DIRECTORY_SEPARATOR . $filename, 1)) {
|
412 |
$this->getFileLoop($files, $path . DIRECTORY_SEPARATOR . $filename, $exclude_regex, $include_regex, $include_dir);
|
413 |
}
|
414 |
}
|
415 |
} else {
|
416 |
+
if($this->regex_match($exclude_regex['file'], $path . DIRECTORY_SEPARATOR . $filename, 0)){
|
417 |
+
if ($exclude_file_size == 0) {
|
|
|
|
|
418 |
$files[] = $path . DIRECTORY_SEPARATOR . $filename;
|
419 |
+
} else {
|
420 |
+
if (filesize($path . DIRECTORY_SEPARATOR . $filename) < $exclude_file_size * 1024 * 1024) {
|
421 |
+
$files[] = $path . DIRECTORY_SEPARATOR . $filename;
|
422 |
+
}
|
423 |
}
|
424 |
}
|
425 |
}
|
426 |
}
|
427 |
}
|
428 |
+
if($handler)
|
429 |
+
@closedir($handler);
|
430 |
}
|
431 |
+
if($include_dir && $count == 0){
|
432 |
$files[] = $path;
|
433 |
}
|
|
|
|
|
434 |
}
|
435 |
|
436 |
+
|
437 |
private function regex_match($regex_array,$string,$mode)
|
438 |
{
|
439 |
if(empty($regex_array))
|
540 |
|
541 |
return $files;
|
542 |
}
|
543 |
+
|
544 |
+
public function create_backup_json($type,$file_info=array(),$db_info=array())
|
545 |
+
{
|
546 |
+
$json['plugin_name']=WPVIVID_PLUGIN_SLUG;
|
547 |
+
$json['plugin_version']=WPVIVID_PLUGIN_VERSION;
|
548 |
+
$json['wordpress_version']=get_bloginfo( 'version' );;
|
549 |
+
$json['type']=$type;
|
550 |
+
|
551 |
+
$path=WP_CONTENT_DIR.'/'. $this->options['backup_options']['dir'].DIRECTORY_SEPARATOR.'wpvivid_backup.json';
|
552 |
+
file_put_contents($path,json_encode($json));
|
553 |
+
return $path;
|
554 |
+
//$path.DIRECTORY_SEPARATOR.$file_prefix.'_'.$type.'.'.$compress_type
|
555 |
+
}
|
556 |
+
|
557 |
+
public static function check_backup_options($backup_options)
|
558 |
+
{
|
559 |
+
$ret['result']=WPVIVID_FAILED;
|
560 |
+
|
561 |
+
if(isset($backup_options['backup_files']))
|
562 |
+
{
|
563 |
+
$backup_options['backup_files']=sanitize_text_field($backup_options['backup_files']);
|
564 |
+
|
565 |
+
if(empty($backup_options['backup_files']))
|
566 |
+
{
|
567 |
+
$ret['error']=__('A backup type is required.', 'wpvivid');
|
568 |
+
return $ret;
|
569 |
+
}
|
570 |
+
|
571 |
+
if($backup_options['backup_files']=='files+db')
|
572 |
+
{
|
573 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_DB]=0;
|
574 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_THEMES]=0;
|
575 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_PLUGIN]=0;
|
576 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_UPLOADS]=0;
|
577 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_CONTENT]=0;
|
578 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_CORE]=0;
|
579 |
+
}
|
580 |
+
else if($backup_options['backup_files']=='files')
|
581 |
+
{
|
582 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_THEMES]=0;
|
583 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_PLUGIN]=0;
|
584 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_UPLOADS]=0;
|
585 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_CONTENT]=0;
|
586 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_CORE]=0;
|
587 |
+
}
|
588 |
+
else if($backup_options['backup_files']=='db')
|
589 |
+
{
|
590 |
+
$task_options['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_DB]=0;
|
591 |
+
}
|
592 |
+
else
|
593 |
+
{
|
594 |
+
$ret['error']=__('A backup type is required.', 'wpvivid');
|
595 |
+
return $ret;
|
596 |
+
}
|
597 |
+
}
|
598 |
+
else
|
599 |
+
{
|
600 |
+
if(isset($backup_options['backup_type'])&&is_array($backup_options['backup_type'])&&!empty($backup_options['backup_type']))
|
601 |
+
{
|
602 |
+
foreach ($backup_options['backup_type'] as $type=>$check)
|
603 |
+
{
|
604 |
+
if($check)
|
605 |
+
$task_options['backup_options']['backup']['backup_type'][$type]=0;
|
606 |
+
}
|
607 |
+
}
|
608 |
+
else
|
609 |
+
{
|
610 |
+
$ret['error']=__('A backup type is required.', 'wpvivid');
|
611 |
+
return $ret;
|
612 |
+
}
|
613 |
+
}
|
614 |
+
$task_options['backup_options']['compress']=WPvivid_Setting::get_option('wpvivid_compress_setting');
|
615 |
+
$task_options['backup_options']['dir']=WPvivid_Setting::get_backupdir();
|
616 |
+
|
617 |
+
if(isset($backup_options['local']) || isset($backup_options['remote']))
|
618 |
+
{
|
619 |
+
$backup_options['local']=sanitize_text_field($backup_options['local']);
|
620 |
+
$backup_options['remote']=sanitize_text_field($backup_options['remote']);
|
621 |
+
|
622 |
+
if(isset($backup_options['remote']))
|
623 |
+
{
|
624 |
+
if($backup_options['remote'] === '1')
|
625 |
+
{
|
626 |
+
$task_options['remote_options']=WPvivid_Setting::get_remote_options();
|
627 |
+
if( $task_options['remote_options'] == false)
|
628 |
+
{
|
629 |
+
$ret['error']=__('There is no default remote storage configured. Please set it up first.', 'wpvivid');
|
630 |
+
return $ret;
|
631 |
+
}
|
632 |
+
}
|
633 |
+
else
|
634 |
+
{
|
635 |
+
$task_options['remote_options']=false;
|
636 |
+
}
|
637 |
+
}
|
638 |
+
else
|
639 |
+
{
|
640 |
+
$task_options['remote_options']=false;
|
641 |
+
}
|
642 |
+
|
643 |
+
if(isset($backup_options['local']))
|
644 |
+
{
|
645 |
+
if($backup_options['local']=='1')
|
646 |
+
{
|
647 |
+
$task_options['save_local']=1;
|
648 |
+
}
|
649 |
+
else
|
650 |
+
{
|
651 |
+
$task_options['save_local']=0;
|
652 |
+
}
|
653 |
+
}
|
654 |
+
else
|
655 |
+
{
|
656 |
+
$task_options['save_local']=0;
|
657 |
+
}
|
658 |
+
}
|
659 |
+
else
|
660 |
+
{
|
661 |
+
$ret['error']=__('Choose at least one storage location for backups.', 'wpvivid');
|
662 |
+
return $ret;
|
663 |
+
}
|
664 |
+
|
665 |
+
if($backup_options['ismerge']=='1')
|
666 |
+
{
|
667 |
+
$task_options['ismerge']=1;
|
668 |
+
}
|
669 |
+
else
|
670 |
+
{
|
671 |
+
$task_options['ismerge']=0;
|
672 |
+
}
|
673 |
+
|
674 |
+
$options=WPvivid_Setting::get_option('wpvivid_common_setting');
|
675 |
+
if(isset($options['max_execution_time']))
|
676 |
+
{
|
677 |
+
$task_options['max_execution_time']=$options['max_execution_time'];
|
678 |
+
}
|
679 |
+
else
|
680 |
+
{
|
681 |
+
$task_options['max_execution_time']=WPVIVID_MAX_EXECUTION_TIME;
|
682 |
+
}
|
683 |
+
|
684 |
+
$task_options['lock']=$backup_options['lock'];
|
685 |
+
|
686 |
+
$ret['result']=WPVIVID_SUCCESS;
|
687 |
+
$ret['options']=$task_options;
|
688 |
+
return $ret;
|
689 |
+
}
|
690 |
}
|
includes/class-wpvivid-backuplist.php
CHANGED
@@ -27,13 +27,33 @@ class WPvivid_Backuplist
|
|
27 |
return false;
|
28 |
}
|
29 |
|
30 |
-
public static function add_new_backup($
|
31 |
{
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
public static function update_backup($id,$key,$data)
|
27 |
return false;
|
28 |
}
|
29 |
|
30 |
+
public static function add_new_backup($task_id,$backup_ret)
|
31 |
{
|
32 |
+
$task=WPvivid_taskmanager::get_task($task_id);
|
33 |
+
if($task!=false)
|
34 |
+
{
|
35 |
+
$backup_data=array();
|
36 |
+
$backup_data['type']=$task['type'];
|
37 |
+
$status=WPvivid_taskmanager::get_backup_task_status($task_id);
|
38 |
+
$backup_data['create_time']=$status['start_time'];
|
39 |
+
$backup_data['manual_delete']=0;
|
40 |
+
$backup_options=WPvivid_taskmanager::get_task_options($task_id,'backup_options');
|
41 |
+
$lock=WPvivid_taskmanager::get_task_options($task_id,'lock');
|
42 |
+
$backup_data['local']['path']=$backup_options['dir'];
|
43 |
+
$backup_data['compress']['compress_type']=$backup_options['compress']['compress_type'];
|
44 |
+
$backup_data['save_local']=$task['options']['save_local'];
|
45 |
+
|
46 |
+
global $wpvivid_pulgin;
|
47 |
+
$backup_data['log']=$wpvivid_pulgin->wpvivid_log->log_file;
|
48 |
+
|
49 |
+
$backup_data['backup']=$backup_ret;
|
50 |
+
$backup_data['remote']=array();
|
51 |
+
if($lock==1)
|
52 |
+
$backup_data['lock']=1;
|
53 |
+
$list = WPvivid_Setting::get_option('wpvivid_backup_list');
|
54 |
+
$list[$task_id]=$backup_data;
|
55 |
+
WPvivid_Setting::update_option('wpvivid_backup_list',$list);
|
56 |
+
}
|
57 |
}
|
58 |
|
59 |
public static function update_backup($id,$key,$data)
|
includes/class-wpvivid-downloader.php
CHANGED
@@ -31,14 +31,14 @@ class WPvivid_downloader
|
|
31 |
{
|
32 |
$progress=100;
|
33 |
WPvivid_taskmanager::update_download_task( $task,$progress,$file['file_name'],'completed');
|
34 |
-
return
|
35 |
}
|
36 |
else
|
37 |
{
|
38 |
$progress=0;
|
39 |
$message=$ret['error'];
|
40 |
WPvivid_taskmanager::update_download_task($task,$progress,$file['file_name'],'error',$message);
|
41 |
-
return
|
42 |
}
|
43 |
}
|
44 |
|
@@ -141,7 +141,8 @@ class WPvivid_downloader
|
|
141 |
|
142 |
foreach ($need_download_files as $file)
|
143 |
{
|
144 |
-
|
|
|
145 |
{
|
146 |
return false;
|
147 |
}
|
@@ -150,22 +151,96 @@ class WPvivid_downloader
|
|
150 |
return true;
|
151 |
}
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
public static function download_restore_file($file,$local_path,$remotes)
|
156 |
{
|
157 |
-
$
|
158 |
-
|
159 |
-
if(
|
160 |
{
|
161 |
-
return array('result' => WPVIVID_FAILED ,'error'=>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
}
|
163 |
|
164 |
-
|
|
|
165 |
|
166 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
-
|
|
|
169 |
}
|
170 |
|
171 |
public static function delete($remote , $files)
|
@@ -371,6 +446,7 @@ class WPvivid_downloader
|
|
371 |
{
|
372 |
if($remote)
|
373 |
{
|
|
|
374 |
$ret['files'][$file['file_name']]['status']='need_download';
|
375 |
$ret['files'][$file['file_name']]['size']=$file['size'];
|
376 |
$ret['files'][$file['file_name']]['md5']=$file['md5'];
|
@@ -421,4 +497,65 @@ class WPvivid_downloader
|
|
421 |
return $ret;
|
422 |
}
|
423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
}
|
31 |
{
|
32 |
$progress=100;
|
33 |
WPvivid_taskmanager::update_download_task( $task,$progress,$file['file_name'],'completed');
|
34 |
+
return $ret;
|
35 |
}
|
36 |
else
|
37 |
{
|
38 |
$progress=0;
|
39 |
$message=$ret['error'];
|
40 |
WPvivid_taskmanager::update_download_task($task,$progress,$file['file_name'],'error',$message);
|
41 |
+
return $ret;
|
42 |
}
|
43 |
}
|
44 |
|
141 |
|
142 |
foreach ($need_download_files as $file)
|
143 |
{
|
144 |
+
$ret=$this->download_ex($task,$backup['remote'],$file,$local_path);
|
145 |
+
if($ret['result']==WPVIVID_FAILED)
|
146 |
{
|
147 |
return false;
|
148 |
}
|
151 |
return true;
|
152 |
}
|
153 |
|
154 |
+
public function download_restore_file($backup_id,$file_name)
|
|
|
|
|
155 |
{
|
156 |
+
$files=array();
|
157 |
+
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
158 |
+
if(!$backup)
|
159 |
{
|
160 |
+
return array('result' => WPVIVID_FAILED ,'error'=>'backup not found');
|
161 |
+
}
|
162 |
+
$download_option='';
|
163 |
+
if($backup['backup']['ismerge']==1)
|
164 |
+
{
|
165 |
+
$backup_files=$backup['backup']['data']['meta']['files'];
|
166 |
+
foreach ($backup_files as $file)
|
167 |
+
{
|
168 |
+
if($file['file_name']==$file_name)
|
169 |
+
{
|
170 |
+
$download_option='all';
|
171 |
+
$files[]=$file;
|
172 |
+
break;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
else
|
177 |
+
{
|
178 |
+
foreach ($backup['backup']['data']['type'] as $type)
|
179 |
+
{
|
180 |
+
$backup_files=$type['files'];
|
181 |
+
foreach ($backup_files as $file)
|
182 |
+
{
|
183 |
+
if($file['file_name']==$file_name)
|
184 |
+
{
|
185 |
+
$download_option=$type['type_name'];
|
186 |
+
$files[]=$file;
|
187 |
+
break;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
}
|
192 |
|
193 |
+
if(empty($files))
|
194 |
+
return array('result' => WPVIVID_FAILED ,'error'=>'file not found');
|
195 |
|
196 |
+
$local_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backup['local']['path'].DIRECTORY_SEPARATOR;
|
197 |
+
$need_download_files=array();
|
198 |
+
foreach ($files as $file)
|
199 |
+
{
|
200 |
+
$local_file=$local_path.$file['file_name'];
|
201 |
+
if(file_exists($local_file))
|
202 |
+
{
|
203 |
+
if(filesize($local_file)==$file['size'])
|
204 |
+
{
|
205 |
+
$new_md5=md5_file($local_file);
|
206 |
+
if($file['md5']!=$new_md5)
|
207 |
+
{
|
208 |
+
$need_download_files[$file['file_name']]=$file;
|
209 |
+
unlink($local_file);
|
210 |
+
}
|
211 |
+
}
|
212 |
+
else
|
213 |
+
{
|
214 |
+
if(filesize($local_file)>$file['size'])
|
215 |
+
{
|
216 |
+
unlink($local_file);
|
217 |
+
}
|
218 |
+
$need_download_files[$file['file_name']]=$file;
|
219 |
+
}
|
220 |
+
}
|
221 |
+
else
|
222 |
+
{
|
223 |
+
$need_download_files[$file['file_name']]=$file;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
if(empty($need_download_files))
|
228 |
+
{
|
229 |
+
return array('result' => WPVIVID_FAILED ,'error'=>'backup not found');
|
230 |
+
}
|
231 |
+
else
|
232 |
+
{
|
233 |
+
if(WPvivid_taskmanager::is_download_task_running($backup_id,$download_option,$file_name))
|
234 |
+
{
|
235 |
+
return array('result' => WPVIVID_FAILED ,'error'=>'download already started');
|
236 |
+
}
|
237 |
+
else
|
238 |
+
{
|
239 |
+
$task=WPvivid_taskmanager::new_download_task($backup_id,$download_option,$need_download_files);
|
240 |
+
}
|
241 |
|
242 |
+
return $this->download_ex($task,$backup['remote'],$need_download_files[$file_name],$local_path);
|
243 |
+
}
|
244 |
}
|
245 |
|
246 |
public static function delete($remote , $files)
|
446 |
{
|
447 |
if($remote)
|
448 |
{
|
449 |
+
WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
|
450 |
$ret['files'][$file['file_name']]['status']='need_download';
|
451 |
$ret['files'][$file['file_name']]['size']=$file['size'];
|
452 |
$ret['files'][$file['file_name']]['md5']=$file['md5'];
|
497 |
return $ret;
|
498 |
}
|
499 |
|
500 |
+
public function download($file,$path,$remote_option)
|
501 |
+
{
|
502 |
+
$local_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR;
|
503 |
+
|
504 |
+
$local_file=$local_path.$file['file_name'];
|
505 |
+
|
506 |
+
if(WPvivid_taskmanager::is_download_task_running_v2($file['file_name']))
|
507 |
+
{
|
508 |
+
return array('result' => WPVIVID_FAILED ,'error'=>'download already started');
|
509 |
+
}
|
510 |
+
|
511 |
+
if(file_exists($local_file))
|
512 |
+
{
|
513 |
+
if(filesize($local_file)==$file['size'])
|
514 |
+
{
|
515 |
+
$new_md5=md5_file($local_file);
|
516 |
+
if($file['md5']!=$new_md5)
|
517 |
+
{
|
518 |
+
@unlink($local_file);
|
519 |
+
}
|
520 |
+
else
|
521 |
+
{
|
522 |
+
return array('result' => WPVIVID_SUCCESS);
|
523 |
+
}
|
524 |
+
}
|
525 |
+
else
|
526 |
+
{
|
527 |
+
@unlink($local_file);
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
$task=WPvivid_taskmanager::new_download_task_v2($file['file_name']);
|
532 |
+
$this->task=$task;
|
533 |
+
|
534 |
+
global $wpvivid_pulgin;
|
535 |
+
|
536 |
+
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote_option);
|
537 |
+
|
538 |
+
$ret=$remote->download($file,$local_path,array($this,'download_callback_v2'));
|
539 |
+
|
540 |
+
if($ret['result']==WPVIVID_SUCCESS)
|
541 |
+
{
|
542 |
+
$progress=100;
|
543 |
+
WPvivid_taskmanager::update_download_task_v2( $task,$progress,'completed');
|
544 |
+
return $ret;
|
545 |
+
}
|
546 |
+
else
|
547 |
+
{
|
548 |
+
$progress=0;
|
549 |
+
$message=$ret['error'];
|
550 |
+
WPvivid_taskmanager::update_download_task_v2($task,$progress,'error',$message);
|
551 |
+
return $ret;
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
public function download_callback_v2($offset,$current_name,$current_size,$last_time,$last_size)
|
556 |
+
{
|
557 |
+
$progress= floor(($offset/$current_size)* 100) ;
|
558 |
+
$text='Total size:'.size_format($current_size,2).' downloaded:'.size_format($offset,2);
|
559 |
+
WPvivid_taskmanager::update_download_task_v2( $this->task,$text,'running');
|
560 |
+
}
|
561 |
}
|
includes/class-wpvivid-log.php
CHANGED
@@ -100,4 +100,56 @@ class WPvivid_Log
|
|
100 |
|
101 |
return WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$options['log_save_location'].DIRECTORY_SEPARATOR;
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
100 |
|
101 |
return WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$options['log_save_location'].DIRECTORY_SEPARATOR;
|
102 |
}
|
103 |
+
|
104 |
+
public function WriteLogHander()
|
105 |
+
{
|
106 |
+
if ($this->log_file_handle)
|
107 |
+
{
|
108 |
+
global $wp_version;
|
109 |
+
global $wpdb;
|
110 |
+
|
111 |
+
$log='server info wp version:'.$wp_version.' php version:'.phpversion().' db version:'.$wpdb->db_version().' php ini:safe_mode:'.ini_get('safe_mode').' ';
|
112 |
+
$log.='memory_limit:'.ini_get('memory_limit').' memory_get_usage:'.size_format(memory_get_usage(),2).' memory_get_peak_usage:'.size_format(memory_get_peak_usage(),2);
|
113 |
+
$log.=' extensions:';
|
114 |
+
$loaded_extensions = get_loaded_extensions();
|
115 |
+
if(!in_array('PDO', $loaded_extensions))
|
116 |
+
{
|
117 |
+
$log.='PDO not enabled ';
|
118 |
+
}
|
119 |
+
else
|
120 |
+
{
|
121 |
+
$log.='PDO enabled ';
|
122 |
+
}
|
123 |
+
if(!in_array('curl', $loaded_extensions))
|
124 |
+
{
|
125 |
+
$log.='curl not enabled ';
|
126 |
+
}
|
127 |
+
else
|
128 |
+
{
|
129 |
+
$log.='curl enabled ';
|
130 |
+
}
|
131 |
+
|
132 |
+
if(!in_array('zlib', $loaded_extensions)) {
|
133 |
+
$log .= 'zlib not enabled ';
|
134 |
+
}
|
135 |
+
else
|
136 |
+
{
|
137 |
+
$log.='zlib enabled ';
|
138 |
+
}
|
139 |
+
|
140 |
+
$log.=' ';
|
141 |
+
if(is_multisite())
|
142 |
+
{
|
143 |
+
$log.=' is_multisite:1';
|
144 |
+
}
|
145 |
+
else
|
146 |
+
{
|
147 |
+
$log.=' is_multisite:0';
|
148 |
+
}
|
149 |
+
|
150 |
+
$time =date("Y-m-d H:i:s",time());
|
151 |
+
$text='['.$time.']'.'[notice]'.$log."\n";
|
152 |
+
fwrite($this->log_file_handle,$text );
|
153 |
+
}
|
154 |
+
}
|
155 |
}
|
includes/class-wpvivid-mail-report.php
CHANGED
@@ -5,7 +5,7 @@ if (!defined('WPVIVID_PLUGIN_DIR')){
|
|
5 |
}
|
6 |
class WPvivid_mail_report
|
7 |
{
|
8 |
-
public static function send_report_mail($
|
9 |
{
|
10 |
$option=WPvivid_Setting::get_option('wpvivid_email_setting');
|
11 |
if(empty($option))
|
@@ -13,23 +13,26 @@ class WPvivid_mail_report
|
|
13 |
return true;
|
14 |
}
|
15 |
|
|
|
|
|
|
|
|
|
16 |
if(empty($option['send_to']))
|
17 |
{
|
18 |
return true;
|
19 |
}
|
20 |
|
21 |
-
$status
|
22 |
-
|
23 |
-
if($status['str']=='completed'&&$option['always']==false)
|
24 |
{
|
25 |
return true;
|
26 |
}
|
27 |
|
28 |
$headers = array('Content-Type: text/html; charset=UTF-8');
|
29 |
-
$subject=self::create_subject($
|
30 |
-
$body=self::create_body($
|
|
|
|
|
31 |
|
32 |
-
$task_log=WPvivid_taskmanager::get_task_options($task_id,'log_file_name');
|
33 |
$wpvivid_log=new WPvivid_Log();
|
34 |
$log_file_name= $wpvivid_log->GetSaveLogFolder().$task_log.'_log.txt';
|
35 |
$attachments[] = $log_file_name;
|
@@ -44,12 +47,12 @@ class WPvivid_mail_report
|
|
44 |
}
|
45 |
}
|
46 |
}
|
|
|
47 |
return true;
|
48 |
}
|
49 |
|
50 |
-
public static function create_subject($
|
51 |
{
|
52 |
-
$task=WPvivid_taskmanager::get_task($task_id);
|
53 |
$status=$task['status']['str'];
|
54 |
if($status=='completed')
|
55 |
{
|
@@ -63,10 +66,8 @@ class WPvivid_mail_report
|
|
63 |
return $header;
|
64 |
}
|
65 |
|
66 |
-
public static function create_body($
|
67 |
{
|
68 |
-
$task=WPvivid_taskmanager::get_task($task_id);
|
69 |
-
|
70 |
$status=$task['status']['str'];
|
71 |
if($status=='completed')
|
72 |
{
|
@@ -80,10 +81,11 @@ class WPvivid_mail_report
|
|
80 |
$start_time=date("m-d-Y H:i:s",$task['status']['start_time']);
|
81 |
$end_time=date("m-d-Y H:i:s",time());
|
82 |
$running_time=($task['status']['run_time']-$task['status']['start_time']).'s';
|
83 |
-
$remote_options=
|
84 |
if($remote_options!==false)
|
85 |
{
|
86 |
-
$
|
|
|
87 |
}
|
88 |
else
|
89 |
{
|
@@ -91,17 +93,26 @@ class WPvivid_mail_report
|
|
91 |
}
|
92 |
$content='';
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
}
|
98 |
-
else if(isset($task['options']['backup_options']['backup']['backup_type'][WPVIVID_BACKUP_TYPE_DB]))
|
99 |
{
|
100 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
-
else
|
103 |
{
|
104 |
-
$content
|
105 |
}
|
106 |
|
107 |
$body='<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#F5F7F8">
|
@@ -436,15 +447,68 @@ class WPvivid_mail_report
|
|
436 |
</td>
|
437 |
</tr>
|
438 |
</tbody></table> ';
|
439 |
-
|
440 |
-
//$body='<h1>'.get_bloginfo('name').': '.'Backup report</h1>';
|
441 |
-
//$body.='<p>site url:'.site_url().'</p>';
|
442 |
-
//$body.='<p>status:'.$task['status']['str'].'</p>';
|
443 |
-
//if($task['status']['str']=='error')
|
444 |
-
//{
|
445 |
-
// $body.='<p>error:'.$task['status']['error'].'</p>';
|
446 |
-
//}
|
447 |
-
//$body.='<p>time spend:'.($task['status']['run_time']-$task['status']['start_time']).'</p>';
|
448 |
return $body;
|
449 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
}
|
5 |
}
|
6 |
class WPvivid_mail_report
|
7 |
{
|
8 |
+
public static function send_report_mail($task,$log=false)
|
9 |
{
|
10 |
$option=WPvivid_Setting::get_option('wpvivid_email_setting');
|
11 |
if(empty($option))
|
13 |
return true;
|
14 |
}
|
15 |
|
16 |
+
if($option['email_enable'] == 0){
|
17 |
+
return true;
|
18 |
+
}
|
19 |
+
|
20 |
if(empty($option['send_to']))
|
21 |
{
|
22 |
return true;
|
23 |
}
|
24 |
|
25 |
+
if($task['status']['str']['str']=='completed'&&$option['always']==false)
|
|
|
|
|
26 |
{
|
27 |
return true;
|
28 |
}
|
29 |
|
30 |
$headers = array('Content-Type: text/html; charset=UTF-8');
|
31 |
+
$subject=self::create_subject($task);
|
32 |
+
$body=self::create_body($task);
|
33 |
+
|
34 |
+
$task_log=$task['options']['log_file_name'];
|
35 |
|
|
|
36 |
$wpvivid_log=new WPvivid_Log();
|
37 |
$log_file_name= $wpvivid_log->GetSaveLogFolder().$task_log.'_log.txt';
|
38 |
$attachments[] = $log_file_name;
|
47 |
}
|
48 |
}
|
49 |
}
|
50 |
+
|
51 |
return true;
|
52 |
}
|
53 |
|
54 |
+
public static function create_subject($task)
|
55 |
{
|
|
|
56 |
$status=$task['status']['str'];
|
57 |
if($status=='completed')
|
58 |
{
|
66 |
return $header;
|
67 |
}
|
68 |
|
69 |
+
public static function create_body($task)
|
70 |
{
|
|
|
|
|
71 |
$status=$task['status']['str'];
|
72 |
if($status=='completed')
|
73 |
{
|
81 |
$start_time=date("m-d-Y H:i:s",$task['status']['start_time']);
|
82 |
$end_time=date("m-d-Y H:i:s",time());
|
83 |
$running_time=($task['status']['run_time']-$task['status']['start_time']).'s';
|
84 |
+
$remote_options= $task['options']['remote_options'];
|
85 |
if($remote_options!==false)
|
86 |
{
|
87 |
+
$remote_option=array_shift($remote_options);
|
88 |
+
$remote=apply_filters('wpvivid_storage_provider_tran', $remote_option['type']);
|
89 |
}
|
90 |
else
|
91 |
{
|
93 |
}
|
94 |
$content='';
|
95 |
|
96 |
+
$backup_options=$task['options']['backup_options'];
|
97 |
+
|
98 |
+
if($backup_options!==false)
|
|
|
|
|
99 |
{
|
100 |
+
if(isset($backup_options['backup']['backup_type'][WPVIVID_BACKUP_TYPE_DB])&&isset($backup_options['backup']['backup_type'][WPVIVID_BACKUP_TYPE_THEMES]))
|
101 |
+
{
|
102 |
+
$content.='Entire Website';
|
103 |
+
}
|
104 |
+
else if(isset($backup_options['backup']['backup_type'][WPVIVID_BACKUP_TYPE_DB]))
|
105 |
+
{
|
106 |
+
$content.='Database';
|
107 |
+
}
|
108 |
+
else if(isset($backup_options['backup']['backup_type'][WPVIVID_BACKUP_TYPE_THEMES]))
|
109 |
+
{
|
110 |
+
$content.='All Files (Exclude Database)';
|
111 |
+
}
|
112 |
}
|
113 |
+
else
|
114 |
{
|
115 |
+
$content='Upload';
|
116 |
}
|
117 |
|
118 |
$body='<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#F5F7F8">
|
447 |
</td>
|
448 |
</tr>
|
449 |
</tbody></table> ';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
return $body;
|
451 |
}
|
452 |
+
|
453 |
+
public static function wpvivid_send_debug_info($user_email){
|
454 |
+
$send_to = 'support@wpvivid.com';
|
455 |
+
$subject = 'Debug Information';
|
456 |
+
$body = 'User\'s email is '.$user_email;
|
457 |
+
$headers = array('Content-Type: text/html; charset=UTF-8');
|
458 |
+
|
459 |
+
$files=WPvivid_error_log::get_error_log();
|
460 |
+
|
461 |
+
if (!class_exists('PclZip'))
|
462 |
+
include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
|
463 |
+
|
464 |
+
$backup_path=WPvivid_Setting::get_backupdir();
|
465 |
+
$path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backup_path.DIRECTORY_SEPARATOR.'wpvivid_debug.zip';
|
466 |
+
|
467 |
+
if(file_exists($path))
|
468 |
+
{
|
469 |
+
@unlink( $path);
|
470 |
+
}
|
471 |
+
$archive = new PclZip($path);
|
472 |
+
|
473 |
+
if(!empty($files))
|
474 |
+
{
|
475 |
+
if(!$archive->add($files,PCLZIP_OPT_REMOVE_ALL_PATH))
|
476 |
+
{
|
477 |
+
echo __($archive->errorInfo(true).' <a href="'.admin_url().'admin.php?page=WPvivid">retry</a>.');
|
478 |
+
exit;
|
479 |
+
}
|
480 |
+
}
|
481 |
+
|
482 |
+
global $wpvivid_pulgin;
|
483 |
+
$server_info=json_encode($wpvivid_pulgin->get_website_info());
|
484 |
+
$server_file_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backup_path.DIRECTORY_SEPARATOR.'wpvivid_server_info.json';
|
485 |
+
if(file_exists($server_file_path))
|
486 |
+
{
|
487 |
+
@unlink( $server_file_path);
|
488 |
+
}
|
489 |
+
$server_file = fopen($server_file_path, 'x');
|
490 |
+
fclose($server_file);
|
491 |
+
file_put_contents($server_file_path,$server_info);
|
492 |
+
if(!$archive->add($server_file_path,PCLZIP_OPT_REMOVE_ALL_PATH))
|
493 |
+
{
|
494 |
+
echo __($archive->errorInfo(true).' <a href="'.admin_url().'admin.php?page=WPvivid">retry</a>.');
|
495 |
+
exit;
|
496 |
+
}
|
497 |
+
@unlink( $server_file_path);
|
498 |
+
|
499 |
+
$attachments[] = $path;
|
500 |
+
|
501 |
+
if(wp_mail( $send_to, $subject, $body,$headers,$attachments)===false)
|
502 |
+
{
|
503 |
+
$ret['result']='failed';
|
504 |
+
$ret['error']=__('Unable to send email. Please check the configuration of email server.', 'wpvivid');
|
505 |
+
}
|
506 |
+
else
|
507 |
+
{
|
508 |
+
$ret['result']='success';
|
509 |
+
}
|
510 |
+
|
511 |
+
@unlink($path);
|
512 |
+
return $ret;
|
513 |
+
}
|
514 |
}
|
includes/class-wpvivid-mysqldump.php
CHANGED
@@ -97,6 +97,9 @@ class WPvivid_Mysqldump
|
|
97 |
* @var array
|
98 |
*/
|
99 |
private $dsnArray = array();
|
|
|
|
|
|
|
100 |
|
101 |
/**
|
102 |
* Constructor of Mysqldump. Note that in the case of an SQLite database
|
@@ -182,6 +185,9 @@ class WPvivid_Mysqldump
|
|
182 |
// Create a new compressManager to manage compressed output
|
183 |
$this->compressManager = CompressManagerFactory::create($this->dumpSettings['compress']);
|
184 |
}
|
|
|
|
|
|
|
185 |
|
186 |
/**
|
187 |
* Destructor of Mysqldump. Unsets dbHandlers and database objects.
|
@@ -366,11 +372,32 @@ class WPvivid_Mysqldump
|
|
366 |
throw new Exception("Table (" . $name . ") not found in database");
|
367 |
}
|
368 |
|
|
|
|
|
369 |
$this->exportTables();
|
370 |
-
$this->
|
371 |
-
|
372 |
-
|
373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
|
375 |
// Restore saved parameters
|
376 |
$this->compressManager->write(
|
@@ -438,12 +465,13 @@ class WPvivid_Mysqldump
|
|
438 |
// Listing all tables from database
|
439 |
if (empty($this->dumpSettings['include-tables'])) {
|
440 |
// include all tables for now, blacklisting happens later
|
441 |
-
|
|
|
442 |
array_push($this->tables, current($row));
|
443 |
}
|
444 |
} else {
|
445 |
// include only the tables mentioned in include-tables
|
446 |
-
foreach ($this->
|
447 |
if (in_array(current($row), $this->dumpSettings['include-tables'], true)) {
|
448 |
array_push($this->tables, current($row));
|
449 |
$elem = array_search(
|
@@ -458,12 +486,12 @@ class WPvivid_Mysqldump
|
|
458 |
// Listing all views from database
|
459 |
if (empty($this->dumpSettings['include-views'])) {
|
460 |
// include all views for now, blacklisting happens later
|
461 |
-
foreach ($this->
|
462 |
array_push($this->views, current($row));
|
463 |
}
|
464 |
} else {
|
465 |
// include only the tables mentioned in include-tables
|
466 |
-
foreach ($this->
|
467 |
if (in_array(current($row), $this->dumpSettings['include-views'], true)) {
|
468 |
array_push($this->views, current($row));
|
469 |
$elem = array_search(
|
@@ -477,21 +505,21 @@ class WPvivid_Mysqldump
|
|
477 |
|
478 |
// Listing all triggers from database
|
479 |
if (false === $this->dumpSettings['skip-triggers']) {
|
480 |
-
foreach ($this->
|
481 |
array_push($this->triggers, $row['Trigger']);
|
482 |
}
|
483 |
}
|
484 |
|
485 |
// Listing all procedures from database
|
486 |
if ($this->dumpSettings['routines']) {
|
487 |
-
foreach ($this->
|
488 |
array_push($this->procedures, $row['procedure_name']);
|
489 |
}
|
490 |
}
|
491 |
|
492 |
// Listing all events from database
|
493 |
if ($this->dumpSettings['events']) {
|
494 |
-
foreach ($this->
|
495 |
array_push($this->events, $row['event_name']);
|
496 |
}
|
497 |
}
|
@@ -659,7 +687,7 @@ class WPvivid_Mysqldump
|
|
659 |
}
|
660 |
$stmt = $this->typeAdapter->show_create_table($tableName);
|
661 |
|
662 |
-
foreach ($this->
|
663 |
|
664 |
$this->compressManager->write($ret);
|
665 |
if ($this->dumpSettings['add-drop-table']) {
|
@@ -686,7 +714,7 @@ class WPvivid_Mysqldump
|
|
686 |
|
687 |
private function getTableColumnTypes($tableName) {
|
688 |
$columnTypes = array();
|
689 |
-
$columns = $this->
|
690 |
$this->typeAdapter->show_columns($tableName)
|
691 |
);
|
692 |
$columns->setFetchMode(PDO::FETCH_ASSOC);
|
@@ -723,7 +751,7 @@ class WPvivid_Mysqldump
|
|
723 |
$stmt = $this->typeAdapter->show_create_view($viewName);
|
724 |
|
725 |
// create views as tables, to resolve dependencies
|
726 |
-
foreach ($this->
|
727 |
if ($this->dumpSettings['add-drop-table']) {
|
728 |
$this->compressManager->write(
|
729 |
$this->typeAdapter->drop_view($viewName)
|
@@ -777,7 +805,7 @@ class WPvivid_Mysqldump
|
|
777 |
|
778 |
// create views, to resolve dependencies
|
779 |
// replacing tables with views
|
780 |
-
foreach ($this->
|
781 |
// because we must replace table with view, we should delete it
|
782 |
$this->compressManager->write(
|
783 |
$this->typeAdapter->drop_view($viewName)
|
@@ -798,7 +826,7 @@ class WPvivid_Mysqldump
|
|
798 |
private function getTriggerStructure($triggerName)
|
799 |
{
|
800 |
$stmt = $this->typeAdapter->show_create_trigger($triggerName);
|
801 |
-
foreach ($this->
|
802 |
if ($this->dumpSettings['add-drop-trigger']) {
|
803 |
$this->compressManager->write(
|
804 |
$this->typeAdapter->add_drop_trigger($triggerName)
|
@@ -826,7 +854,7 @@ class WPvivid_Mysqldump
|
|
826 |
$this->compressManager->write($ret);
|
827 |
}
|
828 |
$stmt = $this->typeAdapter->show_create_procedure($procedureName);
|
829 |
-
foreach ($this->
|
830 |
$this->compressManager->write(
|
831 |
$this->typeAdapter->create_procedure($r, $this->dumpSettings)
|
832 |
);
|
@@ -849,7 +877,7 @@ class WPvivid_Mysqldump
|
|
849 |
$this->compressManager->write($ret);
|
850 |
}
|
851 |
$stmt = $this->typeAdapter->show_create_event($eventName);
|
852 |
-
foreach ($this->
|
853 |
$this->compressManager->write(
|
854 |
$this->typeAdapter->create_event($r, $this->dumpSettings)
|
855 |
);
|
@@ -908,7 +936,8 @@ class WPvivid_Mysqldump
|
|
908 |
if ($this->dumpSettings['where']) {
|
909 |
$stmt .= " WHERE {$this->dumpSettings['where']}";
|
910 |
}
|
911 |
-
|
|
|
912 |
$resultSet->setFetchMode(PDO::FETCH_ASSOC);
|
913 |
|
914 |
if($this->task_id!=='')
|
@@ -1006,7 +1035,12 @@ class WPvivid_Mysqldump
|
|
1006 |
}
|
1007 |
|
1008 |
if ($this->dumpSettings['lock-tables']) {
|
1009 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
1010 |
}
|
1011 |
|
1012 |
if ($this->dumpSettings['add-locks']) {
|
@@ -1097,6 +1131,12 @@ class WPvivid_Mysqldump
|
|
1097 |
|
1098 |
return $colStmt;
|
1099 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1100 |
}
|
1101 |
|
1102 |
/**
|
@@ -1553,11 +1593,11 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1553 |
$args = func_get_args();
|
1554 |
$databaseName = $args[0];
|
1555 |
|
1556 |
-
$resultSet = $this->
|
1557 |
$characterSet = $resultSet->fetchColumn(1);
|
1558 |
$resultSet->closeCursor();
|
1559 |
|
1560 |
-
$resultSet = $this->
|
1561 |
$collationDb = $resultSet->fetchColumn(1);
|
1562 |
$resultSet->closeCursor();
|
1563 |
$ret = "";
|
97 |
* @var array
|
98 |
*/
|
99 |
private $dsnArray = array();
|
100 |
+
private $privileges = array();
|
101 |
+
|
102 |
+
public $last_query_string='';
|
103 |
|
104 |
/**
|
105 |
* Constructor of Mysqldump. Note that in the case of an SQLite database
|
185 |
// Create a new compressManager to manage compressed output
|
186 |
$this->compressManager = CompressManagerFactory::create($this->dumpSettings['compress']);
|
187 |
}
|
188 |
+
public function set_privilege($privileges){
|
189 |
+
$this -> privileges = $privileges;
|
190 |
+
}
|
191 |
|
192 |
/**
|
193 |
* Destructor of Mysqldump. Unsets dbHandlers and database objects.
|
372 |
throw new Exception("Table (" . $name . ") not found in database");
|
373 |
}
|
374 |
|
375 |
+
global $wpvivid_pulgin;
|
376 |
+
|
377 |
$this->exportTables();
|
378 |
+
if($this -> privileges['SHOW VIEW'] == 0){
|
379 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('The lack of SHOW VIEW privilege, the backup will skip exportViews() to continue.','notice');
|
380 |
+
}else{
|
381 |
+
$this->exportViews();
|
382 |
+
}
|
383 |
+
|
384 |
+
if($this -> privileges['TRIGGER'] == 0){
|
385 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('The lack of TRIGGER privilege, the backup will skip exportTriggers() to continue.','notice');
|
386 |
+
}else{
|
387 |
+
$this->exportTriggers();
|
388 |
+
}
|
389 |
+
|
390 |
+
if($this -> privileges['CREATE ROUTINE'] == 0){
|
391 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('The lack of CREATE ROUTINE privilege, the backup will skip exportProcedures() to continue.','notice');
|
392 |
+
}else{
|
393 |
+
$this->exportProcedures();
|
394 |
+
}
|
395 |
+
|
396 |
+
if($this -> privileges['EVENT'] == 0){
|
397 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('The lack of EVENT privilege, the backup will skip exportEvents() to continue.','notice');
|
398 |
+
}else{
|
399 |
+
$this->exportEvents();
|
400 |
+
}
|
401 |
|
402 |
// Restore saved parameters
|
403 |
$this->compressManager->write(
|
465 |
// Listing all tables from database
|
466 |
if (empty($this->dumpSettings['include-tables'])) {
|
467 |
// include all tables for now, blacklisting happens later
|
468 |
+
|
469 |
+
foreach ( $this->query($this->typeAdapter->show_tables($this->dbName)) as $row) {
|
470 |
array_push($this->tables, current($row));
|
471 |
}
|
472 |
} else {
|
473 |
// include only the tables mentioned in include-tables
|
474 |
+
foreach ($this->query($this->typeAdapter->show_tables($this->dbName)) as $row) {
|
475 |
if (in_array(current($row), $this->dumpSettings['include-tables'], true)) {
|
476 |
array_push($this->tables, current($row));
|
477 |
$elem = array_search(
|
486 |
// Listing all views from database
|
487 |
if (empty($this->dumpSettings['include-views'])) {
|
488 |
// include all views for now, blacklisting happens later
|
489 |
+
foreach ($this->query($this->typeAdapter->show_views($this->dbName)) as $row) {
|
490 |
array_push($this->views, current($row));
|
491 |
}
|
492 |
} else {
|
493 |
// include only the tables mentioned in include-tables
|
494 |
+
foreach ($this->query($this->typeAdapter->show_views($this->dbName)) as $row) {
|
495 |
if (in_array(current($row), $this->dumpSettings['include-views'], true)) {
|
496 |
array_push($this->views, current($row));
|
497 |
$elem = array_search(
|
505 |
|
506 |
// Listing all triggers from database
|
507 |
if (false === $this->dumpSettings['skip-triggers']) {
|
508 |
+
foreach ($this->query($this->typeAdapter->show_triggers($this->dbName)) as $row) {
|
509 |
array_push($this->triggers, $row['Trigger']);
|
510 |
}
|
511 |
}
|
512 |
|
513 |
// Listing all procedures from database
|
514 |
if ($this->dumpSettings['routines']) {
|
515 |
+
foreach ($this->query($this->typeAdapter->show_procedures($this->dbName)) as $row) {
|
516 |
array_push($this->procedures, $row['procedure_name']);
|
517 |
}
|
518 |
}
|
519 |
|
520 |
// Listing all events from database
|
521 |
if ($this->dumpSettings['events']) {
|
522 |
+
foreach ($this->query($this->typeAdapter->show_events($this->dbName)) as $row) {
|
523 |
array_push($this->events, $row['event_name']);
|
524 |
}
|
525 |
}
|
687 |
}
|
688 |
$stmt = $this->typeAdapter->show_create_table($tableName);
|
689 |
|
690 |
+
foreach ($this->query($stmt) as $r) {
|
691 |
|
692 |
$this->compressManager->write($ret);
|
693 |
if ($this->dumpSettings['add-drop-table']) {
|
714 |
|
715 |
private function getTableColumnTypes($tableName) {
|
716 |
$columnTypes = array();
|
717 |
+
$columns = $this->query(
|
718 |
$this->typeAdapter->show_columns($tableName)
|
719 |
);
|
720 |
$columns->setFetchMode(PDO::FETCH_ASSOC);
|
751 |
$stmt = $this->typeAdapter->show_create_view($viewName);
|
752 |
|
753 |
// create views as tables, to resolve dependencies
|
754 |
+
foreach ($this->query($stmt) as $r) {
|
755 |
if ($this->dumpSettings['add-drop-table']) {
|
756 |
$this->compressManager->write(
|
757 |
$this->typeAdapter->drop_view($viewName)
|
805 |
|
806 |
// create views, to resolve dependencies
|
807 |
// replacing tables with views
|
808 |
+
foreach ($this->query($stmt) as $r) {
|
809 |
// because we must replace table with view, we should delete it
|
810 |
$this->compressManager->write(
|
811 |
$this->typeAdapter->drop_view($viewName)
|
826 |
private function getTriggerStructure($triggerName)
|
827 |
{
|
828 |
$stmt = $this->typeAdapter->show_create_trigger($triggerName);
|
829 |
+
foreach ($this->query($stmt) as $r) {
|
830 |
if ($this->dumpSettings['add-drop-trigger']) {
|
831 |
$this->compressManager->write(
|
832 |
$this->typeAdapter->add_drop_trigger($triggerName)
|
854 |
$this->compressManager->write($ret);
|
855 |
}
|
856 |
$stmt = $this->typeAdapter->show_create_procedure($procedureName);
|
857 |
+
foreach ($this->query($stmt) as $r) {
|
858 |
$this->compressManager->write(
|
859 |
$this->typeAdapter->create_procedure($r, $this->dumpSettings)
|
860 |
);
|
877 |
$this->compressManager->write($ret);
|
878 |
}
|
879 |
$stmt = $this->typeAdapter->show_create_event($eventName);
|
880 |
+
foreach ($this->query($stmt) as $r) {
|
881 |
$this->compressManager->write(
|
882 |
$this->typeAdapter->create_event($r, $this->dumpSettings)
|
883 |
);
|
936 |
if ($this->dumpSettings['where']) {
|
937 |
$stmt .= " WHERE {$this->dumpSettings['where']}";
|
938 |
}
|
939 |
+
|
940 |
+
$resultSet = $this->query($stmt);
|
941 |
$resultSet->setFetchMode(PDO::FETCH_ASSOC);
|
942 |
|
943 |
if($this->task_id!=='')
|
1035 |
}
|
1036 |
|
1037 |
if ($this->dumpSettings['lock-tables']) {
|
1038 |
+
if($this -> privileges['LOCK TABLES'] == 0){
|
1039 |
+
global $wpvivid_pulgin;
|
1040 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('The lack of LOCK TABLES privilege, the backup will skip lock_tables() to continue.','notice');
|
1041 |
+
}else{
|
1042 |
+
$this->typeAdapter->lock_table($tableName);
|
1043 |
+
}
|
1044 |
}
|
1045 |
|
1046 |
if ($this->dumpSettings['add-locks']) {
|
1131 |
|
1132 |
return $colStmt;
|
1133 |
}
|
1134 |
+
|
1135 |
+
public function query($query_string)
|
1136 |
+
{
|
1137 |
+
$this->last_query_string=$query_string;
|
1138 |
+
return $this->dbHandler->query($query_string);
|
1139 |
+
}
|
1140 |
}
|
1141 |
|
1142 |
/**
|
1593 |
$args = func_get_args();
|
1594 |
$databaseName = $args[0];
|
1595 |
|
1596 |
+
$resultSet = $this->query("SHOW VARIABLES LIKE 'character_set_database';");
|
1597 |
$characterSet = $resultSet->fetchColumn(1);
|
1598 |
$resultSet->closeCursor();
|
1599 |
|
1600 |
+
$resultSet = $this->query("SHOW VARIABLES LIKE 'collation_database';");
|
1601 |
$collationDb = $resultSet->fetchColumn(1);
|
1602 |
$resultSet->closeCursor();
|
1603 |
$ret = "";
|
includes/class-wpvivid-remote-collection.php
CHANGED
@@ -62,11 +62,13 @@ class WPvivid_Remote_collection
|
|
62 |
$remote_ids[]=$id;
|
63 |
WPvivid_Setting::update_user_history('remote_selected',$remote_ids);
|
64 |
$schedule_data = WPvivid_Setting::get_option('wpvivid_schedule_setting');
|
65 |
-
if($schedule_data['enable']
|
66 |
-
$schedule_data['
|
67 |
-
|
|
|
|
|
|
|
68 |
}
|
69 |
-
WPvivid_Setting::update_option('wpvivid_schedule_setting',$schedule_data);
|
70 |
}
|
71 |
$ret['result']=WPVIVID_SUCCESS;
|
72 |
}
|
62 |
$remote_ids[]=$id;
|
63 |
WPvivid_Setting::update_user_history('remote_selected',$remote_ids);
|
64 |
$schedule_data = WPvivid_Setting::get_option('wpvivid_schedule_setting');
|
65 |
+
if(!empty($schedule_data['enable'])) {
|
66 |
+
if ($schedule_data['enable'] == 1) {
|
67 |
+
$schedule_data['backup']['local'] = 0;
|
68 |
+
$schedule_data['backup']['remote'] = 1;
|
69 |
+
}
|
70 |
+
WPvivid_Setting::update_option('wpvivid_schedule_setting', $schedule_data);
|
71 |
}
|
|
|
72 |
}
|
73 |
$ret['result']=WPVIVID_SUCCESS;
|
74 |
}
|
includes/class-wpvivid-restore-database.php
CHANGED
@@ -11,6 +11,7 @@ class WPvivid_RestoreDB
|
|
11 |
{
|
12 |
private $restore_data;
|
13 |
private $type_name;
|
|
|
14 |
|
15 |
public function restore($type_name,$path,$files)
|
16 |
{
|
@@ -18,7 +19,8 @@ class WPvivid_RestoreDB
|
|
18 |
$this -> type_name = $type_name;
|
19 |
$zip = new WPvivid_ZipClass();
|
20 |
$basename = $zip -> getBasename($files[0]['file_name']);
|
21 |
-
$task_id = explode('_',$basename)
|
|
|
22 |
$expath = $path.DIRECTORY_SEPARATOR.'temp-'.$basename;
|
23 |
$databases = array();
|
24 |
|
@@ -38,6 +40,41 @@ class WPvivid_RestoreDB
|
|
38 |
$temp_sql_file = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_DEFAULT_ROLLBACK_DIR.DIRECTORY_SEPARATOR.$type_name.DIRECTORY_SEPARATOR.$basename.'.';
|
39 |
@mkdir(dirname($temp_sql_file));
|
40 |
$backup_database = new WPvivid_Backup_Database();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
$result = $backup_database ->backup_database(array('path'=>$temp_sql_file,'log'=>$this->restore_data->get_log_handle()));
|
42 |
if($result['result'] != 'succeed')
|
43 |
{
|
@@ -50,7 +87,6 @@ class WPvivid_RestoreDB
|
|
50 |
$data = array();
|
51 |
$data['data']['file'] = $file_path;
|
52 |
$str = $this ->restore_db($data);
|
53 |
-
|
54 |
if($str['result'] == 'succeed')
|
55 |
{
|
56 |
WPvivid_Setting::import_json_to_setting($temp_sql);
|
@@ -70,7 +106,25 @@ class WPvivid_RestoreDB
|
|
70 |
if(!file_exists($File)){
|
71 |
return array('result'=>'failed','error'=>'Database\'s .sql file not found. Please try again.');
|
72 |
}
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
$pdo -> query('SET NAMES utf8');
|
75 |
$result = $this->restore_db_file($pdo,$File);
|
76 |
unset($pdo);
|
@@ -125,15 +179,19 @@ class WPvivid_RestoreDB
|
|
125 |
|
126 |
$query = $query . $line;
|
127 |
if ($endWith == ';') {
|
128 |
-
if(
|
129 |
-
$
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
135 |
}
|
136 |
-
$success_num ++;
|
137 |
$query= '';
|
138 |
}
|
139 |
}
|
11 |
{
|
12 |
private $restore_data;
|
13 |
private $type_name;
|
14 |
+
private $privileges;
|
15 |
|
16 |
public function restore($type_name,$path,$files)
|
17 |
{
|
19 |
$this -> type_name = $type_name;
|
20 |
$zip = new WPvivid_ZipClass();
|
21 |
$basename = $zip -> getBasename($files[0]['file_name']);
|
22 |
+
$task_id = explode('_',$basename);
|
23 |
+
$task_id = $task_id[0];
|
24 |
$expath = $path.DIRECTORY_SEPARATOR.'temp-'.$basename;
|
25 |
$databases = array();
|
26 |
|
40 |
$temp_sql_file = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_DEFAULT_ROLLBACK_DIR.DIRECTORY_SEPARATOR.$type_name.DIRECTORY_SEPARATOR.$basename.'.';
|
41 |
@mkdir(dirname($temp_sql_file));
|
42 |
$backup_database = new WPvivid_Backup_Database();
|
43 |
+
|
44 |
+
$res = explode(':',DB_HOST);
|
45 |
+
$db_host = $res[0];
|
46 |
+
$db_port = empty($res[1])?'':$res[1];
|
47 |
+
if(!empty($db_port))
|
48 |
+
$db_host = $db_host.':'.$db_port;
|
49 |
+
try{
|
50 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
51 |
+
}catch (Exception $e)
|
52 |
+
{
|
53 |
+
if(!empty($db_port)){
|
54 |
+
$db_host = $res[0];
|
55 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
56 |
+
}
|
57 |
+
if(empty($pdo) || !$pdo){
|
58 |
+
return array('result' => 'WPVIVID_FAILED','error' =>'The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.');
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
$privileges = $backup_database -> check_privilege('restore',$pdo);
|
63 |
+
if($privileges['result'] == WPVIVID_FAILED){
|
64 |
+
return $privileges;
|
65 |
+
}else{
|
66 |
+
$privileges = $privileges['data'];
|
67 |
+
$this -> privileges = $privileges;
|
68 |
+
}
|
69 |
+
$options = array();
|
70 |
+
foreach ($privileges as $key => $value){
|
71 |
+
if($value == 0){
|
72 |
+
$options[] = $key;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
if(!empty($options))
|
76 |
+
$this->restore_data->write_log('The lack of optional database privileges including '.implode(',',$options),'notice');
|
77 |
+
|
78 |
$result = $backup_database ->backup_database(array('path'=>$temp_sql_file,'log'=>$this->restore_data->get_log_handle()));
|
79 |
if($result['result'] != 'succeed')
|
80 |
{
|
87 |
$data = array();
|
88 |
$data['data']['file'] = $file_path;
|
89 |
$str = $this ->restore_db($data);
|
|
|
90 |
if($str['result'] == 'succeed')
|
91 |
{
|
92 |
WPvivid_Setting::import_json_to_setting($temp_sql);
|
106 |
if(!file_exists($File)){
|
107 |
return array('result'=>'failed','error'=>'Database\'s .sql file not found. Please try again.');
|
108 |
}
|
109 |
+
|
110 |
+
$res = explode(':',DB_HOST);
|
111 |
+
$db_host = $res[0];
|
112 |
+
$db_port = empty($res[1])?'':$res[1];
|
113 |
+
if(!empty($db_port))
|
114 |
+
$db_host = $db_host.':'.$db_port;
|
115 |
+
try{
|
116 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
117 |
+
}catch (Exception $e)
|
118 |
+
{
|
119 |
+
if(!empty($db_port)){
|
120 |
+
$db_host = $res[0];
|
121 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
122 |
+
}
|
123 |
+
if(empty($pdo) || !$pdo){
|
124 |
+
return array('result' => 'WPVIVID_FAILED','error' =>'The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.');
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
$pdo -> query('SET NAMES utf8');
|
129 |
$result = $this->restore_db_file($pdo,$File);
|
130 |
unset($pdo);
|
179 |
|
180 |
$query = $query . $line;
|
181 |
if ($endWith == ';') {
|
182 |
+
if(preg_match('#^\\s*LOCK TABLES#',$query) && $this -> privileges['LOCK TABLES'] == 0){
|
183 |
+
$this->restore_data->write_log('The lack of LOCK TABLES privilege, the backup will skip LOCK TABLES to continue.Notice at Line:'.$line_num,'notice');
|
184 |
+
}else{
|
185 |
+
if(!$result = $pdo -> query($query)){
|
186 |
+
$error_num ++;
|
187 |
+
$data = array('line'=>$line_num,'sql'=>$query,'error'=>$pdo->errorInfo());
|
188 |
+
$this->restore_data->write_log('Restore '.basename($File).' error at line '.$line_num.','.PHP_EOL.'errorinfo: ['.implode('][',$pdo->errorInfo()).']','Warning');
|
189 |
+
$error_info[] = $data;
|
190 |
+
$query= '';
|
191 |
+
continue;
|
192 |
+
}
|
193 |
+
$success_num ++;
|
194 |
}
|
|
|
195 |
$query= '';
|
196 |
}
|
197 |
}
|
includes/class-wpvivid-restore-site.php
CHANGED
@@ -14,7 +14,8 @@ class WPvivid_RestoreSite
|
|
14 |
$this->restore_data=new WPvivid_restore_data();
|
15 |
$zip = new WPvivid_ZipClass();
|
16 |
$basename = $zip -> getBasename($files[0]['file_name']);
|
17 |
-
$task_id = explode('_',$basename)
|
|
|
18 |
|
19 |
$temp_path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_DEFAULT_ROLLBACK_DIR.DIRECTORY_SEPARATOR.$type_name;
|
20 |
$backup = new WPvivid_Backup();
|
@@ -52,15 +53,18 @@ class WPvivid_RestoreSite
|
|
52 |
{
|
53 |
if($filename != "." && $filename != "..")
|
54 |
{
|
55 |
-
if(
|
56 |
continue;
|
|
|
57 |
if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
}else{
|
63 |
-
if(file_exists($path.DIRECTORY_SEPARATOR.$filename)){
|
64 |
if(!copy($path.DIRECTORY_SEPARATOR.$filename,str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename))){
|
65 |
$result = array('result'=>'failed','error'=>'Copying '.$path.DIRECTORY_SEPARATOR.$filename.' into '.$temp_path.DIRECTORY_SEPARATOR.$filename.' failed. Make sure the file isn\'t occupied, or the folder is writable.');
|
66 |
break;
|
@@ -74,6 +78,7 @@ class WPvivid_RestoreSite
|
|
74 |
return $result;
|
75 |
}
|
76 |
|
|
|
77 |
private function _restore($restorePath,$path , $files){
|
78 |
$zip = new WPvivid_ZipClass();
|
79 |
$allfiles = array();
|
14 |
$this->restore_data=new WPvivid_restore_data();
|
15 |
$zip = new WPvivid_ZipClass();
|
16 |
$basename = $zip -> getBasename($files[0]['file_name']);
|
17 |
+
$task_id = explode('_',$basename);
|
18 |
+
$task_id = $task_id[0];
|
19 |
|
20 |
$temp_path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_DEFAULT_ROLLBACK_DIR.DIRECTORY_SEPARATOR.$type_name;
|
21 |
$backup = new WPvivid_Backup();
|
53 |
{
|
54 |
if($filename != "." && $filename != "..")
|
55 |
{
|
56 |
+
if(empty($except_path))
|
57 |
continue;
|
58 |
+
|
59 |
if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
|
60 |
+
if(WPvivid_tools::regex_match($except_path['directory'],$path.DIRECTORY_SEPARATOR.$filename,0)){
|
61 |
+
@mkdir(str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename));
|
62 |
+
$result = $this->_pre_restore_loop($path.DIRECTORY_SEPARATOR.$filename,$temp_path,$except_path,$replace_path);
|
63 |
+
if($result['result'] != 'succeed')
|
64 |
+
break;
|
65 |
+
}
|
66 |
}else{
|
67 |
+
if(file_exists($path.DIRECTORY_SEPARATOR.$filename) && WPvivid_tools::regex_match($except_path['file'],$path.DIRECTORY_SEPARATOR.$filename,0)){
|
68 |
if(!copy($path.DIRECTORY_SEPARATOR.$filename,str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename))){
|
69 |
$result = array('result'=>'failed','error'=>'Copying '.$path.DIRECTORY_SEPARATOR.$filename.' into '.$temp_path.DIRECTORY_SEPARATOR.$filename.' failed. Make sure the file isn\'t occupied, or the folder is writable.');
|
70 |
break;
|
78 |
return $result;
|
79 |
}
|
80 |
|
81 |
+
|
82 |
private function _restore($restorePath,$path , $files){
|
83 |
$zip = new WPvivid_ZipClass();
|
84 |
$allfiles = array();
|
includes/class-wpvivid-rollback.php
CHANGED
@@ -69,7 +69,25 @@ class WPvivid_RollBack
|
|
69 |
if(!file_exists($File)){
|
70 |
return array('result'=>'failed','error'=>'The .sql file not found. Please try again later.');
|
71 |
}
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
$pdo -> query('SET NAMES utf8');
|
74 |
$result = $this->rollback_db_file($pdo,$File);
|
75 |
unset($pdo);
|
@@ -83,6 +101,22 @@ class WPvivid_RollBack
|
|
83 |
$errortables = array();
|
84 |
$sqlhandle = fopen($File,'r');
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
$success_num = 0;
|
88 |
$error_num = 0;
|
@@ -123,15 +157,19 @@ class WPvivid_RollBack
|
|
123 |
|
124 |
$query = $query . $line;
|
125 |
if ($endWith == ';') {
|
126 |
-
if(
|
127 |
-
$
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
-
$success_num ++;
|
135 |
$query= '';
|
136 |
}
|
137 |
}
|
69 |
if(!file_exists($File)){
|
70 |
return array('result'=>'failed','error'=>'The .sql file not found. Please try again later.');
|
71 |
}
|
72 |
+
|
73 |
+
$res = explode(':',DB_HOST);
|
74 |
+
$db_host = $res[0];
|
75 |
+
$db_port = empty($res[1])?'':$res[1];
|
76 |
+
if(!empty($db_port))
|
77 |
+
$db_host = $db_host.':'.$db_port;
|
78 |
+
try{
|
79 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
80 |
+
}catch (Exception $e)
|
81 |
+
{
|
82 |
+
if(!empty($db_port)){
|
83 |
+
$db_host = $res[0];
|
84 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
85 |
+
}
|
86 |
+
if(empty($pdo) || !$pdo){
|
87 |
+
return array('result' => 'WPVIVID_FAILED','error' =>'The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.');
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
$pdo -> query('SET NAMES utf8');
|
92 |
$result = $this->rollback_db_file($pdo,$File);
|
93 |
unset($pdo);
|
101 |
$errortables = array();
|
102 |
$sqlhandle = fopen($File,'r');
|
103 |
|
104 |
+
$backup_database = new WPvivid_Backup_Database();
|
105 |
+
$privileges = $backup_database -> check_privilege('restore',$pdo);
|
106 |
+
if($privileges['result'] == WPVIVID_FAILED){
|
107 |
+
return $privileges;
|
108 |
+
}else{
|
109 |
+
$privileges = $privileges['data'];
|
110 |
+
}
|
111 |
+
$options = array();
|
112 |
+
foreach ($privileges as $key => $value){
|
113 |
+
if($value == 0){
|
114 |
+
$options[] = $key;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
if(!empty($options))
|
119 |
+
$this->restore_data->write_rollback_log('The lack of optional database privileges including '.implode(',',$options),'Notice');
|
120 |
|
121 |
$success_num = 0;
|
122 |
$error_num = 0;
|
157 |
|
158 |
$query = $query . $line;
|
159 |
if ($endWith == ';') {
|
160 |
+
if(preg_match('#^\\s*LOCK TABLES#',$query) && $privileges['LOCK TABLES'] == 0){
|
161 |
+
$this->restore_data->write_rollback_log('The lack of LOCK TABLES privilege, the backup will skip LOCK TABLES to continue.Notice at Line:'.$line_num,'notice');
|
162 |
+
}else{
|
163 |
+
if(!$result = $pdo -> query($query)){
|
164 |
+
$error_num ++;
|
165 |
+
$data = array('line'=>$line_num,'sql'=>$query,'error'=>$pdo->errorInfo());
|
166 |
+
$this->restore_data->write_rollback_log('Restore '.basename($File).' error at line '.$line_num.','.PHP_EOL.'errorinfo: ['.implode('][',$pdo->errorInfo()).']','Warning');
|
167 |
+
$error_info[] = $data;
|
168 |
+
$query= '';
|
169 |
+
continue;
|
170 |
+
}
|
171 |
+
$success_num ++;
|
172 |
}
|
|
|
173 |
$query= '';
|
174 |
}
|
175 |
}
|
includes/class-wpvivid-setting.php
CHANGED
@@ -136,7 +136,7 @@ class WPvivid_Setting
|
|
136 |
}
|
137 |
|
138 |
public static function get_last_backup_message($option_name, $default = array()){
|
139 |
-
$message = get_option($option_name, $default);
|
140 |
$ret = array();
|
141 |
if(!empty($message['id'])) {
|
142 |
$ret['id'] = $message['id'];
|
@@ -144,7 +144,10 @@ class WPvivid_Setting
|
|
144 |
$ret['status']['start_time'] = date("M d, Y H:i", $ret['status']['start_time']);
|
145 |
$ret['status']['run_time'] = date("M d, Y H:i", $ret['status']['run_time']);
|
146 |
$ret['status']['timeout'] = date("M d, Y H:i", $ret['status']['timeout']);
|
147 |
-
$
|
|
|
|
|
|
|
148 |
}
|
149 |
return $ret;
|
150 |
}
|
136 |
}
|
137 |
|
138 |
public static function get_last_backup_message($option_name, $default = array()){
|
139 |
+
$message = self::get_option($option_name, $default);
|
140 |
$ret = array();
|
141 |
if(!empty($message['id'])) {
|
142 |
$ret['id'] = $message['id'];
|
144 |
$ret['status']['start_time'] = date("M d, Y H:i", $ret['status']['start_time']);
|
145 |
$ret['status']['run_time'] = date("M d, Y H:i", $ret['status']['run_time']);
|
146 |
$ret['status']['timeout'] = date("M d, Y H:i", $ret['status']['timeout']);
|
147 |
+
if(isset($message['options']['log_file_name']))
|
148 |
+
$ret['log_file_name'] = $message['options']['log_file_name'];
|
149 |
+
else
|
150 |
+
$ret['log_file_name'] ='';
|
151 |
}
|
152 |
return $ret;
|
153 |
}
|
includes/class-wpvivid-taskmanager.php
CHANGED
@@ -5,11 +5,11 @@ if (!defined('WPVIVID_PLUGIN_DIR')){
|
|
5 |
}
|
6 |
class WPvivid_taskmanager
|
7 |
{
|
8 |
-
public static function new_backup_task($option,$type)
|
9 |
{
|
10 |
$id=uniqid('wpvivid-');
|
11 |
$task['id']=$id;
|
12 |
-
$task['action']
|
13 |
$task['type']=$type;
|
14 |
|
15 |
$task['status']['start_time']=time();
|
@@ -44,6 +44,47 @@ class WPvivid_taskmanager
|
|
44 |
return $ret;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
public static function delete_ready_task()
|
48 |
{
|
49 |
$tasks=WPvivid_Setting::get_tasks();
|
@@ -206,6 +247,11 @@ class WPvivid_taskmanager
|
|
206 |
$task['status']['error']=$error;
|
207 |
}
|
208 |
WPvivid_Setting::update_task($task_id,$task);
|
|
|
|
|
|
|
|
|
|
|
209 |
}
|
210 |
}
|
211 |
public static function get_backup_task_error($task_id)
|
@@ -249,6 +295,23 @@ class WPvivid_taskmanager
|
|
249 |
}
|
250 |
}
|
251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
public static function update_backup_main_task_progress($task_id,$job_name,$progress,$finished,$job_data=array())
|
253 |
{
|
254 |
$task=self::get_task($task_id);
|
@@ -272,6 +335,10 @@ class WPvivid_taskmanager
|
|
272 |
$task['status']['run_time']=time();
|
273 |
$task['status']['str']='running';
|
274 |
$task['data']['doing']=$job_name;
|
|
|
|
|
|
|
|
|
275 |
$task['data'][$job_name]['doing']=$sub_job_name;
|
276 |
$task['data'][$job_name]['sub_job'][$sub_job_name]['finished']=$finished;
|
277 |
$task['data'][$job_name]['sub_job'][$sub_job_name]['progress']=$progress;
|
@@ -290,9 +357,16 @@ class WPvivid_taskmanager
|
|
290 |
}
|
291 |
}
|
292 |
|
293 |
-
public static function get_backup_main_task_progress($task_id,$job_name)
|
294 |
{
|
295 |
$task=self::get_task($task_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
if(array_key_exists($job_name,$task['data']))
|
297 |
{
|
298 |
return $task['data'][$job_name];
|
@@ -647,6 +721,66 @@ class WPvivid_taskmanager
|
|
647 |
WPvivid_Setting::delete_task($id);
|
648 |
}
|
649 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
public static function delete_all_task()
|
651 |
{
|
652 |
WPvivid_Setting::delete_option('wpvivid_task_list');
|
@@ -666,4 +800,115 @@ class WPvivid_taskmanager
|
|
666 |
return false;
|
667 |
}
|
668 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
669 |
}
|
5 |
}
|
6 |
class WPvivid_taskmanager
|
7 |
{
|
8 |
+
public static function new_backup_task($option,$type,$action='backup')
|
9 |
{
|
10 |
$id=uniqid('wpvivid-');
|
11 |
$task['id']=$id;
|
12 |
+
$task['action']=$action;
|
13 |
$task['type']=$type;
|
14 |
|
15 |
$task['status']['start_time']=time();
|
44 |
return $ret;
|
45 |
}
|
46 |
|
47 |
+
public static function new_upload_task($option,$type)
|
48 |
+
{
|
49 |
+
$id=uniqid('wpvivid-');
|
50 |
+
$task['id']=$id;
|
51 |
+
$task['action']='upload';
|
52 |
+
$task['type']='Manual';
|
53 |
+
$task['type']=$type;
|
54 |
+
|
55 |
+
$task['status']['start_time']=time();
|
56 |
+
$task['status']['run_time']=time();
|
57 |
+
$task['status']['timeout']=time();
|
58 |
+
$task['status']['str']='ready';
|
59 |
+
$task['status']['resume_count']=0;
|
60 |
+
|
61 |
+
$task['options']=$option;
|
62 |
+
$task['options']['file_prefix']=$task['id'].'_'.date('Y-m-d-H-i',$task['status']['start_time']);
|
63 |
+
$task['options']['log_file_name']=$id.'_backup';
|
64 |
+
$log=new WPvivid_Log();
|
65 |
+
$log->CreateLogFile($task['options']['log_file_name'],'no_folder','backup');
|
66 |
+
$log->CloseFile();
|
67 |
+
|
68 |
+
$task['data']['doing']='upload';
|
69 |
+
$task['data']['doing']='backup';
|
70 |
+
$task['data']['backup']['doing']='';
|
71 |
+
$task['data']['backup']['finished']=1;
|
72 |
+
$task['data']['backup']['progress']=100;
|
73 |
+
$task['data']['backup']['job_data']=array();
|
74 |
+
$task['data']['backup']['sub_job']=array();
|
75 |
+
$task['data']['backup']['db_size']='0';
|
76 |
+
$task['data']['backup']['files_size']['sum']='0';
|
77 |
+
$task['data']['upload']['doing']='';
|
78 |
+
$task['data']['upload']['finished']=0;
|
79 |
+
$task['data']['upload']['progress']=0;
|
80 |
+
$task['data']['upload']['job_data']=array();
|
81 |
+
$task['data']['upload']['sub_job']=array();
|
82 |
+
WPvivid_Setting::update_task($id,$task);
|
83 |
+
$ret['result']='success';
|
84 |
+
$ret['task_id']=$task['id'];
|
85 |
+
return $ret;
|
86 |
+
}
|
87 |
+
|
88 |
public static function delete_ready_task()
|
89 |
{
|
90 |
$tasks=WPvivid_Setting::get_tasks();
|
247 |
$task['status']['error']=$error;
|
248 |
}
|
249 |
WPvivid_Setting::update_task($task_id,$task);
|
250 |
+
return $task;
|
251 |
+
}
|
252 |
+
else
|
253 |
+
{
|
254 |
+
return false;
|
255 |
}
|
256 |
}
|
257 |
public static function get_backup_task_error($task_id)
|
295 |
}
|
296 |
}
|
297 |
|
298 |
+
public static function update_task_options($task_id,$option_name,$option)
|
299 |
+
{
|
300 |
+
$tasks=WPvivid_Setting::get_tasks();
|
301 |
+
if(array_key_exists ($task_id,$tasks))
|
302 |
+
{
|
303 |
+
$task=$tasks[$task_id];
|
304 |
+
$task['options'][$option_name]=$option;
|
305 |
+
|
306 |
+
WPvivid_Setting::update_task($task_id,$task);
|
307 |
+
return true;
|
308 |
+
}
|
309 |
+
else
|
310 |
+
{
|
311 |
+
return false;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
public static function update_backup_main_task_progress($task_id,$job_name,$progress,$finished,$job_data=array())
|
316 |
{
|
317 |
$task=self::get_task($task_id);
|
335 |
$task['status']['run_time']=time();
|
336 |
$task['status']['str']='running';
|
337 |
$task['data']['doing']=$job_name;
|
338 |
+
if(empty($sub_job_name))
|
339 |
+
{
|
340 |
+
$sub_job_name=$task['data'][$job_name]['doing'];
|
341 |
+
}
|
342 |
$task['data'][$job_name]['doing']=$sub_job_name;
|
343 |
$task['data'][$job_name]['sub_job'][$sub_job_name]['finished']=$finished;
|
344 |
$task['data'][$job_name]['sub_job'][$sub_job_name]['progress']=$progress;
|
357 |
}
|
358 |
}
|
359 |
|
360 |
+
public static function get_backup_main_task_progress($task_id,$job_name='')
|
361 |
{
|
362 |
$task=self::get_task($task_id);
|
363 |
+
|
364 |
+
if(empty($job_name))
|
365 |
+
{
|
366 |
+
$job_name=$task['data']['doing'];
|
367 |
+
return $job_name;
|
368 |
+
}
|
369 |
+
|
370 |
if(array_key_exists($job_name,$task['data']))
|
371 |
{
|
372 |
return $task['data'][$job_name];
|
721 |
WPvivid_Setting::delete_task($id);
|
722 |
}
|
723 |
|
724 |
+
public static function mark_task($id)
|
725 |
+
{
|
726 |
+
$tasks=WPvivid_Setting::get_tasks();
|
727 |
+
if(array_key_exists ($id,$tasks))
|
728 |
+
{
|
729 |
+
$task=$tasks[$id];
|
730 |
+
$task['marked']=1;
|
731 |
+
WPvivid_Setting::update_task($id,$task);
|
732 |
+
return true;
|
733 |
+
}
|
734 |
+
else
|
735 |
+
{
|
736 |
+
return false;
|
737 |
+
}
|
738 |
+
}
|
739 |
+
|
740 |
+
public static function delete_marked_task()
|
741 |
+
{
|
742 |
+
$has_marked = 0;
|
743 |
+
$tasks=WPvivid_Setting::get_tasks();
|
744 |
+
$delete_ids=array();
|
745 |
+
foreach ($tasks as $task)
|
746 |
+
{
|
747 |
+
if(isset($task['marked']))
|
748 |
+
{
|
749 |
+
$delete_ids[]=$task['id'];
|
750 |
+
}
|
751 |
+
}
|
752 |
+
foreach ($delete_ids as $id)
|
753 |
+
{
|
754 |
+
unset($tasks[$id]);
|
755 |
+
$has_marked = 1;
|
756 |
+
}
|
757 |
+
update_option('wpvivid_task_list',$tasks);
|
758 |
+
return $has_marked;
|
759 |
+
}
|
760 |
+
|
761 |
+
public static function delete_out_of_date_finished_task()
|
762 |
+
{
|
763 |
+
$tasks=WPvivid_Setting::get_tasks();
|
764 |
+
$delete_ids=array();
|
765 |
+
foreach ($tasks as $task)
|
766 |
+
{
|
767 |
+
if($task['status']['str']=='error'||$task['status']['str']=='completed')
|
768 |
+
{
|
769 |
+
if(time()-$task['status']['run_time']>60)
|
770 |
+
{
|
771 |
+
$delete_ids[]=$task['id'];
|
772 |
+
}
|
773 |
+
}
|
774 |
+
}
|
775 |
+
|
776 |
+
foreach ($delete_ids as $id)
|
777 |
+
{
|
778 |
+
unset($tasks[$id]);
|
779 |
+
}
|
780 |
+
|
781 |
+
update_option('wpvivid_task_list',$tasks);
|
782 |
+
}
|
783 |
+
|
784 |
public static function delete_all_task()
|
785 |
{
|
786 |
WPvivid_Setting::delete_option('wpvivid_task_list');
|
800 |
return false;
|
801 |
}
|
802 |
}
|
803 |
+
|
804 |
+
public static function new_download_task_v2($file_name)
|
805 |
+
{
|
806 |
+
$default = array();
|
807 |
+
wp_cache_delete('notoptions', 'options');
|
808 |
+
wp_cache_delete('alloptions', 'options');
|
809 |
+
wp_cache_delete('wpvivid_download_task_v2', 'options');
|
810 |
+
|
811 |
+
$options = get_option('wpvivid_download_task_v2', $default);
|
812 |
+
|
813 |
+
$task['file_name']=$file_name;
|
814 |
+
$task['start_time']=time();
|
815 |
+
$task['run_time']=time();
|
816 |
+
$task['progress_text']='start download file:'.$file_name;
|
817 |
+
$task['status']='running';
|
818 |
+
$task['error']='';
|
819 |
+
$options[$file_name]=$task;
|
820 |
+
|
821 |
+
update_option('wpvivid_download_task_v2',$options);
|
822 |
+
return $task;
|
823 |
+
}
|
824 |
+
|
825 |
+
public static function is_download_task_running_v2($file_name)
|
826 |
+
{
|
827 |
+
$default = array();
|
828 |
+
$options = get_option('wpvivid_download_task_v2', $default);
|
829 |
+
|
830 |
+
if(empty($options))
|
831 |
+
{
|
832 |
+
return false;
|
833 |
+
}
|
834 |
+
if(array_key_exists($file_name,$options))
|
835 |
+
{
|
836 |
+
$task=$options[$file_name];
|
837 |
+
|
838 |
+
if(time()-$task['run_time']>60)
|
839 |
+
{
|
840 |
+
return false;
|
841 |
+
}
|
842 |
+
else {
|
843 |
+
return true;
|
844 |
+
}
|
845 |
+
}
|
846 |
+
return false;
|
847 |
+
}
|
848 |
+
|
849 |
+
public static function update_download_task_v2(&$task,$progress_text,$status='',$error='')
|
850 |
+
{
|
851 |
+
$default = array();
|
852 |
+
wp_cache_delete('notoptions', 'options');
|
853 |
+
wp_cache_delete('alloptions', 'options');
|
854 |
+
wp_cache_delete('wpvivid_download_task_v2', 'options');
|
855 |
+
|
856 |
+
$options = get_option('wpvivid_download_task_v2', $default);
|
857 |
+
|
858 |
+
$file_name=$task['file_name'];
|
859 |
+
$task['run_time']=time();
|
860 |
+
$task['progress_text']=$progress_text;
|
861 |
+
if($status!='')
|
862 |
+
{
|
863 |
+
$task['status']=$status;
|
864 |
+
if($error!='')
|
865 |
+
{
|
866 |
+
$task['error']=$error;
|
867 |
+
}
|
868 |
+
}
|
869 |
+
|
870 |
+
$options[$file_name]=$task;
|
871 |
+
|
872 |
+
update_option('wpvivid_download_task_v2',$options);
|
873 |
+
}
|
874 |
+
|
875 |
+
public static function get_download_task_v2($file_name)
|
876 |
+
{
|
877 |
+
$default = array();
|
878 |
+
$options = get_option('wpvivid_download_task_v2', $default);
|
879 |
+
|
880 |
+
if(empty($options))
|
881 |
+
{
|
882 |
+
return false;
|
883 |
+
}
|
884 |
+
if(array_key_exists($file_name,$options))
|
885 |
+
{
|
886 |
+
if(time()-$options[$file_name]['run_time']>60)
|
887 |
+
{
|
888 |
+
$options[$file_name]['status']='timeout';
|
889 |
+
$options[$file_name]['error']='time out';
|
890 |
+
}
|
891 |
+
|
892 |
+
return $options[$file_name];
|
893 |
+
}
|
894 |
+
return false;
|
895 |
+
}
|
896 |
+
|
897 |
+
public static function delete_download_task_v2($file_name)
|
898 |
+
{
|
899 |
+
$default = array();
|
900 |
+
$options = get_option('wpvivid_download_task_v2', $default);
|
901 |
+
|
902 |
+
if(empty($options))
|
903 |
+
{
|
904 |
+
return false;
|
905 |
+
}
|
906 |
+
if(array_key_exists($file_name,$options))
|
907 |
+
{
|
908 |
+
unset($options[$file_name]);
|
909 |
+
update_option('wpvivid_download_task_v2',$options);
|
910 |
+
return true;
|
911 |
+
}
|
912 |
+
return false;
|
913 |
+
}
|
914 |
}
|
includes/class-wpvivid-tools.php
CHANGED
@@ -46,7 +46,12 @@ class WPvivid_tools
|
|
46 |
@closedir($handler);
|
47 |
}
|
48 |
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
$handler=opendir($path);
|
51 |
if(empty($handler))
|
52 |
return ;
|
@@ -54,14 +59,15 @@ class WPvivid_tools
|
|
54 |
{
|
55 |
if($filename != "." && $filename != "..")
|
56 |
{
|
57 |
-
if(!empty($exclude) && !WPvivid_tools::regex_match($exclude,$path.DIRECTORY_SEPARATOR.$filename ,0)) {
|
58 |
-
continue;
|
59 |
-
}
|
60 |
if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
}else{
|
64 |
-
|
|
|
|
|
65 |
}
|
66 |
}
|
67 |
}
|
@@ -70,6 +76,7 @@ class WPvivid_tools
|
|
70 |
if($flag)
|
71 |
@rmdir($path);
|
72 |
}
|
|
|
73 |
public static function regex_match($regex_array,$string,$mode)
|
74 |
{
|
75 |
if(empty($regex_array))
|
46 |
@closedir($handler);
|
47 |
}
|
48 |
|
49 |
+
public static function deldir($path,$exclude='',$flag = false)
|
50 |
+
{
|
51 |
+
if(!is_dir($path))
|
52 |
+
{
|
53 |
+
return ;
|
54 |
+
}
|
55 |
$handler=opendir($path);
|
56 |
if(empty($handler))
|
57 |
return ;
|
59 |
{
|
60 |
if($filename != "." && $filename != "..")
|
61 |
{
|
|
|
|
|
|
|
62 |
if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
|
63 |
+
if(empty($exclude)||WPvivid_tools::regex_match($exclude['directory'],$path.DIRECTORY_SEPARATOR.$filename ,0)){
|
64 |
+
self::deldir( $path.DIRECTORY_SEPARATOR.$filename ,$exclude, $flag);
|
65 |
+
@rmdir( $path.DIRECTORY_SEPARATOR.$filename );
|
66 |
+
}
|
67 |
}else{
|
68 |
+
if(empty($exclude)||WPvivid_tools::regex_match($exclude['file'],$path.DIRECTORY_SEPARATOR.$filename ,0)){
|
69 |
+
@unlink($path.DIRECTORY_SEPARATOR.$filename);
|
70 |
+
}
|
71 |
}
|
72 |
}
|
73 |
}
|
76 |
if($flag)
|
77 |
@rmdir($path);
|
78 |
}
|
79 |
+
|
80 |
public static function regex_match($regex_array,$string,$mode)
|
81 |
{
|
82 |
if(empty($regex_array))
|
includes/class-wpvivid-upload.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WPVIVID_PLUGIN_DIR'))
|
4 |
+
{
|
5 |
+
die;
|
6 |
+
}
|
7 |
+
|
8 |
+
class WPvivid_Upload
|
9 |
+
{
|
10 |
+
public $task_id;
|
11 |
+
|
12 |
+
public function upload($task_id,$backup,$remote_option=null)
|
13 |
+
{
|
14 |
+
global $wpvivid_pulgin;
|
15 |
+
$this->task_id=$task_id;
|
16 |
+
$files=$this->get_backup_files($backup);
|
17 |
+
|
18 |
+
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',0,0);
|
19 |
+
|
20 |
+
if(is_null($remote_option))
|
21 |
+
{
|
22 |
+
$remote_options=WPvivid_taskmanager::get_task_options($this->task_id,'remote_options');
|
23 |
+
$remote_option=array_shift($remote_options);
|
24 |
+
|
25 |
+
if(is_null($remote_option))
|
26 |
+
{
|
27 |
+
return array('result' => WPVIVID_FAILED , 'error' => 'not select remote storage');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote_option);
|
32 |
+
|
33 |
+
$result=$remote->upload($this->task_id,$files,array($this,'upload_callback'));
|
34 |
+
|
35 |
+
if($result['result']==WPVIVID_SUCCESS)
|
36 |
+
{
|
37 |
+
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',100,1);
|
38 |
+
WPvivid_taskmanager::update_backup_task_status($task_id,false,'completed');
|
39 |
+
return array('result' => WPVIVID_SUCCESS);
|
40 |
+
}
|
41 |
+
else
|
42 |
+
{
|
43 |
+
$remote ->cleanup($files);
|
44 |
+
|
45 |
+
WPvivid_taskmanager::update_backup_task_status($this->task_id,false,'error',false,false,$result['error']);
|
46 |
+
return array('result' => WPVIVID_FAILED , 'error' => $result['error']);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
public function upload_callback($offset,$current_name,$current_size,$last_time,$last_size)
|
51 |
+
{
|
52 |
+
$v =( $offset - $last_size ) / (time() - $last_time);
|
53 |
+
$v /= 1000;
|
54 |
+
$v=round($v,2);
|
55 |
+
|
56 |
+
global $wpvivid_pulgin;
|
57 |
+
$wpvivid_pulgin->check_cancel_backup($this->task_id);
|
58 |
+
|
59 |
+
$message='Uploading '.$current_name.' Total size: '.size_format($current_size,2).' Uploaded: '.size_format($offset,2).' speed:'.$v.'kb/s';
|
60 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog($message,'notice');
|
61 |
+
$progress=intval(($offset/$current_size)*100);
|
62 |
+
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',$progress,0);
|
63 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'upload','','0',$message);
|
64 |
+
}
|
65 |
+
|
66 |
+
public function get_backup_files($backup)
|
67 |
+
{
|
68 |
+
$path=WP_CONTENT_DIR.'/'.$backup['local']['path'];
|
69 |
+
$files=array();
|
70 |
+
$files_list=array();
|
71 |
+
|
72 |
+
if($backup['backup']['ismerge']==1)
|
73 |
+
{
|
74 |
+
$files=$backup['backup']['data']['meta']['files'];
|
75 |
+
}
|
76 |
+
else
|
77 |
+
{
|
78 |
+
foreach ($backup['backup']['data']['type'] as $type)
|
79 |
+
{
|
80 |
+
foreach ($type['files'] as $file)
|
81 |
+
{
|
82 |
+
$files[]=$file;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
foreach ($files as $file)
|
88 |
+
{
|
89 |
+
$files_list[] = $path . DIRECTORY_SEPARATOR . $file['file_name'];
|
90 |
+
}
|
91 |
+
|
92 |
+
return $files_list;
|
93 |
+
}
|
94 |
+
}
|
includes/class-wpvivid-zipclass.php
CHANGED
@@ -200,16 +200,19 @@ class WPvivid_ZipClass {
|
|
200 |
{
|
201 |
define(PCLZIP_TEMPORARY_DIR,$temp_dir);
|
202 |
$files_meta=array();
|
|
|
203 |
foreach ($packages as $data)
|
204 |
{
|
205 |
if(!empty($data['files']))
|
206 |
{
|
207 |
-
|
|
|
208 |
$archive = new PclZip($data['path']);
|
209 |
}else{
|
210 |
continue;
|
211 |
}
|
212 |
|
|
|
213 |
if($no_compress)
|
214 |
{
|
215 |
if($use_temp_file==1)
|
@@ -249,18 +252,19 @@ class WPvivid_ZipClass {
|
|
249 |
|
250 |
if(!$str)
|
251 |
{
|
|
|
252 |
return array('result'=>'failed','error'=>$archive->errorInfo(true));
|
253 |
}
|
254 |
$file_data = array();
|
255 |
$file_data['file_name'] = basename($data['path']);
|
256 |
$file_data['size'] = filesize($data['path']);
|
257 |
$file_data['md5'] = md5_file($data['path']);
|
|
|
258 |
$files_meta[] = $file_data;
|
259 |
}
|
260 |
-
|
261 |
return array('result'=>'succeed','meta'=>$files_meta);
|
262 |
}
|
263 |
-
|
264 |
}
|
265 |
|
266 |
$wpvivid_old_time=0;
|
200 |
{
|
201 |
define(PCLZIP_TEMPORARY_DIR,$temp_dir);
|
202 |
$files_meta=array();
|
203 |
+
global $wpvivid_pulgin;
|
204 |
foreach ($packages as $data)
|
205 |
{
|
206 |
if(!empty($data['files']))
|
207 |
{
|
208 |
+
if(file_exists($data['path']))
|
209 |
+
@unlink($data['path']);
|
210 |
$archive = new PclZip($data['path']);
|
211 |
}else{
|
212 |
continue;
|
213 |
}
|
214 |
|
215 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Prepare to zip files. Is compress: '.$no_compress,'notice');
|
216 |
if($no_compress)
|
217 |
{
|
218 |
if($use_temp_file==1)
|
252 |
|
253 |
if(!$str)
|
254 |
{
|
255 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Failed to add zip files, error: '.$archive->errorInfo(true),'notice');
|
256 |
return array('result'=>'failed','error'=>$archive->errorInfo(true));
|
257 |
}
|
258 |
$file_data = array();
|
259 |
$file_data['file_name'] = basename($data['path']);
|
260 |
$file_data['size'] = filesize($data['path']);
|
261 |
$file_data['md5'] = md5_file($data['path']);
|
262 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Adding zip files, filename: '.$file_data['file_name'].', filesize: '.size_format($file_data['size'],2),'notice');
|
263 |
$files_meta[] = $file_data;
|
264 |
}
|
265 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Adding zip files completed.','notice');
|
266 |
return array('result'=>'succeed','meta'=>$files_meta);
|
267 |
}
|
|
|
268 |
}
|
269 |
|
270 |
$wpvivid_old_time=0;
|
includes/class-wpvivid.php
CHANGED
@@ -45,12 +45,16 @@ class WPvivid {
|
|
45 |
|
46 |
public $remote_collection;
|
47 |
|
|
|
|
|
48 |
public function __construct()
|
49 |
{
|
50 |
$this->version = WPVIVID_PLUGIN_VERSION;
|
51 |
|
52 |
$this->plugin_name = WPVIVID_PLUGIN_SLUG;
|
53 |
|
|
|
|
|
54 |
//Load dependent files
|
55 |
$this->load_dependencies();
|
56 |
|
@@ -88,6 +92,18 @@ class WPvivid {
|
|
88 |
add_filter('wpvivid_get_log_list', array( $this, 'wpvivid_get_log_list' ), 10);
|
89 |
add_filter('wpvivid_get_last_backup_message', array( $this, 'wpvivid_get_last_backup_message' ), 10);
|
90 |
add_filter('wpvivid_schedule_local_remote', array( $this, 'wpvivid_schedule_local_remote' ), 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
//Initialisation schedule hook
|
93 |
$this->init_cron();
|
@@ -110,24 +126,25 @@ class WPvivid {
|
|
110 |
|
111 |
private function load_dependencies()
|
112 |
{
|
113 |
-
include_once
|
114 |
|
115 |
-
require_once
|
116 |
-
require_once
|
117 |
|
118 |
-
include_once
|
119 |
-
include_once
|
120 |
-
include_once
|
121 |
-
include_once
|
122 |
-
include_once
|
123 |
-
include_once
|
124 |
|
125 |
-
include_once
|
126 |
-
include_once
|
127 |
-
include_once
|
128 |
-
include_once
|
129 |
|
130 |
-
include_once
|
|
|
131 |
$this->remote_collection=new WPvivid_Remote_collection();
|
132 |
}
|
133 |
|
@@ -259,6 +276,7 @@ class WPvivid {
|
|
259 |
add_action('wp_ajax_wpvivid_rollback',array( $this,'rollback'));
|
260 |
add_action('wp_ajax_wpvivid_get_restore_progress',array( $this,'get_restore_progress'));
|
261 |
add_action('wp_ajax_wpvivid_get_rollback_progress',array( $this,'get_rollback_progress'));
|
|
|
262 |
//When restoring the database use wp_ajax_nopriv_
|
263 |
add_action('wp_ajax_nopriv_wpvivid_init_restore_page',array( $this,'init_restore_page'));
|
264 |
add_action('wp_ajax_nopriv_wpvivid_delete_last_restore_data',array( $this,'delete_last_restore_data'));
|
@@ -274,6 +292,7 @@ class WPvivid {
|
|
274 |
//Get default remote storage when backing up
|
275 |
add_action('wp_ajax_wpvivid_get_default_remote_storage',array( $this,'get_default_remote_storage'));
|
276 |
add_action('wp_ajax_wpvivid_need_review',array( $this,'need_review'));
|
|
|
277 |
}
|
278 |
|
279 |
public function get_plugin_name()
|
@@ -341,7 +360,6 @@ class WPvivid {
|
|
341 |
echo json_encode($ret);
|
342 |
die();
|
343 |
}
|
344 |
-
|
345 |
add_filter('wpvivid_check_backup_options_valid',array($this,'check_backup_options_valid'),10);
|
346 |
$backup_options=apply_filters('wpvivid_check_backup_options_valid',$backup_options);
|
347 |
|
@@ -352,12 +370,16 @@ class WPvivid {
|
|
352 |
echo json_encode($ret);
|
353 |
die();
|
354 |
}
|
355 |
-
|
356 |
$ret=$this->pre_backup($backup_options,'Manual');
|
357 |
if($ret['result']=='success')
|
358 |
{
|
359 |
//Check the website data to be backed up
|
360 |
$ret['check']=$this->check_backup($ret['task_id'],$backup_options['backup_files']);
|
|
|
|
|
|
|
|
|
|
|
361 |
$html = '';
|
362 |
$html = apply_filters('wpvivid_add_backup_list', $html);
|
363 |
$ret['html'] = $html;
|
@@ -707,8 +729,18 @@ class WPvivid {
|
|
707 |
{
|
708 |
die();
|
709 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
710 |
//resume backup
|
711 |
-
|
712 |
die();
|
713 |
}
|
714 |
|
@@ -935,6 +967,7 @@ class WPvivid {
|
|
935 |
public function backup($task_id)
|
936 |
{
|
937 |
//register shutdown function to catch php fatal error such as script time out and memory limit
|
|
|
938 |
register_shutdown_function(array($this,'deal_shutdown_error'),$task_id);
|
939 |
@ignore_user_abort(true);
|
940 |
WPvivid_taskmanager::update_backup_task_status($task_id,true,'running');
|
@@ -945,55 +978,41 @@ class WPvivid {
|
|
945 |
$this->flush($task_id);
|
946 |
$this->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id,'log_file_name'));
|
947 |
$this->wpvivid_log->WriteLog('Start backing up.','notice');
|
|
|
948 |
//start backup
|
949 |
try
|
950 |
{
|
951 |
-
$backup_job=WPvivid_taskmanager::get_backup_main_task_progress($task_id,'backup');
|
952 |
$backup=new WPvivid_Backup();
|
953 |
|
954 |
-
|
|
|
|
|
|
|
|
|
955 |
{
|
956 |
-
$backup_ret
|
|
|
|
|
|
|
957 |
}
|
958 |
-
else
|
959 |
-
{
|
960 |
-
$backup_ret=$backup->backup($task_id);
|
961 |
-
WPvivid_tools::clearcache($task_id);
|
962 |
-
|
963 |
-
if($backup_ret['result'] != 'succeed')
|
964 |
-
{
|
965 |
-
$this->wpvivid_log->WriteLog('Backup ends with an error '. $backup_ret['error'], 'error');
|
966 |
-
}
|
967 |
-
else
|
968 |
-
{
|
969 |
-
$this->wpvivid_log->WriteLog('Backup completed.','notice');
|
970 |
-
}
|
971 |
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
else
|
977 |
-
{
|
978 |
-
$this->update_last_backup_task($task_id);
|
979 |
-
die();
|
980 |
-
}
|
981 |
}
|
982 |
-
|
983 |
if(WPvivid_taskmanager::get_task_options($task_id,'remote_options')!=false)
|
984 |
{
|
985 |
-
|
986 |
-
$this->upload_start($task_id,$backup_ret);
|
987 |
-
$this->finish_upload_task($task_id);
|
988 |
-
$this->update_last_backup_task($task_id);
|
989 |
}
|
990 |
-
$this->wpvivid_analysis_backup($task_id);
|
991 |
}
|
992 |
catch (Exception $e)
|
993 |
{
|
994 |
//catch error and stop task recording history
|
995 |
$this->deal_task_error($task_id,'exception',$e);
|
996 |
$this->wpvivid_log->CloseFile();
|
|
|
997 |
die();
|
998 |
}
|
999 |
catch (Error $e)
|
@@ -1001,14 +1020,55 @@ class WPvivid {
|
|
1001 |
//catch error and stop task recording history
|
1002 |
$this->deal_task_error($task_id,'error',$e);
|
1003 |
$this->wpvivid_log->CloseFile();
|
|
|
1004 |
die();
|
1005 |
}
|
1006 |
-
|
1007 |
die();
|
1008 |
}
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1012 |
$cron_backup_count = WPvivid_Setting::get_option('cron_backup_count');
|
1013 |
if(empty($cron_backup_count)){
|
1014 |
$cron_backup_count = 0;
|
@@ -1029,249 +1089,170 @@ class WPvivid {
|
|
1029 |
}
|
1030 |
}
|
1031 |
/**
|
1032 |
-
* start
|
1033 |
*
|
1034 |
* @var string $task_id
|
1035 |
*
|
1036 |
-
* @
|
1037 |
-
*
|
1038 |
-
* @since 0.9.1
|
1039 |
*/
|
1040 |
-
|
1041 |
{
|
1042 |
-
$
|
1043 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1044 |
|
1045 |
-
|
|
|
|
|
|
|
1046 |
{
|
1047 |
-
$
|
|
|
|
|
1048 |
}
|
1049 |
else
|
1050 |
{
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
$
|
|
|
|
|
1055 |
}
|
1056 |
-
|
1057 |
-
|
1058 |
-
return $backup_ret;
|
1059 |
}
|
1060 |
-
/**
|
1061 |
-
* start upload files to remote.
|
1062 |
-
*
|
1063 |
-
* @var string $task_id
|
1064 |
-
*
|
1065 |
-
* @var array $backup_ret return data of backup
|
1066 |
-
*
|
1067 |
-
* @since 0.9.1
|
1068 |
-
*/
|
1069 |
-
private function upload_start($task_id,$backup_ret)
|
1070 |
-
{
|
1071 |
-
$upload=new WPvivid_Backup();
|
1072 |
-
$backup_options=WPvivid_taskmanager::get_task_options($task_id,'backup_options');
|
1073 |
-
|
1074 |
-
$path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR. $backup_options['dir'];
|
1075 |
-
$files=array();
|
1076 |
-
if ($backup_ret['ismerge'])
|
1077 |
-
{
|
1078 |
-
foreach ($backup_ret['data']['meta']['files'] as $file)
|
1079 |
-
{
|
1080 |
-
$files[] = $path . DIRECTORY_SEPARATOR . $file['file_name'];
|
1081 |
-
}
|
1082 |
-
} else {
|
1083 |
-
foreach ($backup_ret['data']['type'] as $type)
|
1084 |
-
{
|
1085 |
-
foreach ($type['files'] as $file)
|
1086 |
-
{
|
1087 |
-
$files[] = $path . DIRECTORY_SEPARATOR . $file['file_name'];
|
1088 |
-
}
|
1089 |
-
}
|
1090 |
-
}
|
1091 |
|
1092 |
-
|
1093 |
-
|
|
|
|
|
1094 |
{
|
1095 |
-
|
1096 |
-
$
|
|
|
|
|
|
|
1097 |
}
|
|
|
|
|
|
|
1098 |
}
|
1099 |
-
/**
|
1100 |
-
* recording finished backup task.
|
1101 |
-
*
|
1102 |
-
* @var string $task_id
|
1103 |
-
*
|
1104 |
-
* @var array $backup_ret return data of backup
|
1105 |
-
*
|
1106 |
-
* @return boolean
|
1107 |
-
*
|
1108 |
-
* @since 0.9.1
|
1109 |
-
*/
|
1110 |
-
private function finish_backup_task($task_id,$backup_ret)
|
1111 |
-
{
|
1112 |
-
$status=WPvivid_taskmanager::get_backup_task_status($task_id);
|
1113 |
-
if($status['str']=='running')
|
1114 |
-
{
|
1115 |
-
$backup_data=array();
|
1116 |
-
$task=WPvivid_taskmanager::get_task($task_id);
|
1117 |
-
$backup_data['type']=$task['type'];
|
1118 |
-
$backup_data['create_time']=$status['start_time'];
|
1119 |
-
$backup_data['manual_delete']=0;
|
1120 |
-
|
1121 |
-
$backup_options=WPvivid_taskmanager::get_task_options($task_id,'backup_options');
|
1122 |
-
$lock=WPvivid_taskmanager::get_task_options($task_id,'lock');
|
1123 |
-
$backup_data['local']['path']=$backup_options['dir'];
|
1124 |
-
$backup_data['compress']['compress_type']=$backup_options['compress']['compress_type'];
|
1125 |
-
$backup_data['log']=$this->wpvivid_log->log_file;
|
1126 |
-
$backup_data['backup']=$backup_ret;
|
1127 |
-
$backup_data['remote']=array();
|
1128 |
-
if($lock==1)
|
1129 |
-
$backup_data['lock']=1;
|
1130 |
-
$this->wpvivid_log->WriteLog('Backup succeeded.','notice');
|
1131 |
-
WPvivid_Backuplist::add_new_backup($task_id,$backup_data);
|
1132 |
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
$this->wpvivid_log->CloseFile();
|
1148 |
-
return false;
|
1149 |
-
}
|
1150 |
}
|
1151 |
-
|
|
|
1152 |
{
|
1153 |
-
|
1154 |
-
|
1155 |
-
{
|
1156 |
-
$save_local=WPvivid_taskmanager::get_task_options($task_id,'save_local');
|
1157 |
-
if($save_local==0)
|
1158 |
-
{
|
1159 |
-
$this->wpvivid_log->WriteLog('Clean up local files after uploading to remote storages.','notice');
|
1160 |
-
$file_prefix=WPvivid_taskmanager::get_task_options($task_id,'file_prefix');
|
1161 |
-
$backup_options=WPvivid_taskmanager::get_task_options($task_id,'backup_options');
|
1162 |
-
$backup=new WPvivid_Backup();
|
1163 |
-
$backup->clean_backup($file_prefix,$backup_options['dir']);
|
1164 |
-
}
|
1165 |
-
$this->wpvivid_log->WriteLog('Upload succeeded.','notice');
|
1166 |
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
$
|
1172 |
-
return true;
|
1173 |
}
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
$this->wpvivid_log->CloseFile();
|
1179 |
-
return false;
|
1180 |
}
|
|
|
|
|
|
|
|
|
|
|
1181 |
}
|
|
|
1182 |
public function deal_shutdown_error($task_id)
|
1183 |
{
|
1184 |
-
$
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
{
|
1191 |
-
$error=false;
|
1192 |
-
}
|
1193 |
-
//$this->task_monitor($task_id,$error);
|
1194 |
-
if(WPvivid_taskmanager::get_task($task_id)!==false)
|
1195 |
-
{
|
1196 |
-
if($this->wpvivid_log->log_file_handle==false)
|
1197 |
-
{
|
1198 |
-
$this->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id,'log_file_name'));
|
1199 |
}
|
|
|
|
|
|
|
|
|
|
|
1200 |
|
1201 |
-
|
1202 |
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
$time_spend=time()-$status['timeout'];
|
1207 |
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
$this->check_cancel_backup($task_id);
|
1225 |
-
$message='Task timed out.';
|
1226 |
-
if($this->add_resume_event($task_id))
|
1227 |
-
{
|
1228 |
-
WPvivid_taskmanager::update_backup_task_status($task_id,false,'wait_resume',false,$status['resume_count']);
|
1229 |
-
}
|
1230 |
-
else
|
1231 |
-
{
|
1232 |
-
WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1233 |
-
$this->update_last_backup_task($task_id);
|
1234 |
-
$this->add_clean_backing_up_data_event($task_id);
|
1235 |
-
WPvivid_mail_report::send_report_mail($task_id);
|
1236 |
-
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1237 |
-
WPvivid_Schedule::clear_monitor_schedule($task_id);
|
1238 |
-
}
|
1239 |
-
}
|
1240 |
-
if($this->wpvivid_log)
|
1241 |
-
$this->wpvivid_log->WriteLog($message,'error');
|
1242 |
-
}
|
1243 |
-
else {
|
1244 |
-
if($status['str']!='error')
|
1245 |
-
{
|
1246 |
-
if($error!==false)
|
1247 |
-
{
|
1248 |
-
$message=$error['message'].' file:'.$error['file'].' line:'.$error['line'];
|
1249 |
}
|
1250 |
-
|
1251 |
-
$message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1252 |
}
|
1253 |
-
WPvivid_taskmanager::
|
|
|
1254 |
}
|
1255 |
-
$this->update_last_backup_task($task_id);
|
1256 |
-
$this->add_clean_backing_up_data_event($task_id);
|
1257 |
-
WPvivid_mail_report::send_report_mail($task_id);
|
1258 |
-
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1259 |
-
WPvivid_Schedule::clear_monitor_schedule($task_id);
|
1260 |
}
|
1261 |
}
|
|
|
1262 |
}
|
1263 |
-
die();
|
1264 |
}
|
1265 |
public function deal_task_error($task_id,$error_type,$error)
|
1266 |
{
|
1267 |
$message = 'An '.$error_type.' has occurred. class:'.get_class($error).';msg:'.$error->getMessage().';code:'.$error->getCode().';line:'.$error->getLine().';in_file:'.$error->getFile().';';
|
1268 |
error_log($message);
|
1269 |
-
WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,false,$message);
|
1270 |
$this->wpvivid_log->WriteLog($message,'error');
|
1271 |
|
1272 |
-
|
1273 |
-
WPvivid_mail_report::send_report_mail($task_id);
|
1274 |
-
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1275 |
}
|
1276 |
/**
|
1277 |
* update time limit.
|
@@ -1323,12 +1304,9 @@ class WPvivid {
|
|
1323 |
if($status['resume_count']>WPVIVID_RESUME_RETRY_TIMES)
|
1324 |
{
|
1325 |
$message=__('Too many resumption attempts.', 'wpvivid');
|
1326 |
-
WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1327 |
-
$this->update_last_backup_task($task_id);
|
1328 |
-
$this->add_clean_backing_up_data_event($task_id);
|
1329 |
-
WPvivid_mail_report::send_report_mail($task_id);
|
1330 |
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1331 |
-
|
1332 |
}
|
1333 |
else
|
1334 |
{
|
@@ -1340,12 +1318,8 @@ class WPvivid {
|
|
1340 |
}
|
1341 |
else
|
1342 |
{
|
1343 |
-
WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1344 |
-
|
1345 |
-
$this->add_clean_backing_up_data_event($task_id);
|
1346 |
-
WPvivid_mail_report::send_report_mail($task_id);
|
1347 |
-
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1348 |
-
WPvivid_Schedule::clear_monitor_schedule($task_id);
|
1349 |
}
|
1350 |
}
|
1351 |
if($this->wpvivid_log)
|
@@ -1364,12 +1338,8 @@ class WPvivid {
|
|
1364 |
if($error!==false)
|
1365 |
{
|
1366 |
$message=$error['message'].' file:'.$error['file'].' line:'.$error['line'];
|
1367 |
-
WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1368 |
-
|
1369 |
-
$this->add_clean_backing_up_data_event($task_id);
|
1370 |
-
WPvivid_mail_report::send_report_mail($task_id);
|
1371 |
-
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1372 |
-
WPvivid_Schedule::clear_monitor_schedule($task_id);
|
1373 |
}
|
1374 |
else
|
1375 |
{
|
@@ -1455,12 +1425,28 @@ class WPvivid {
|
|
1455 |
{
|
1456 |
$alter_fcgi=false;
|
1457 |
}
|
1458 |
-
|
1459 |
if($check_db)
|
1460 |
{
|
1461 |
$ret['big_tables']=array();
|
1462 |
$db_info=array();
|
1463 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1464 |
$sth = $pdo->query('SHOW TABLE STATUS');
|
1465 |
$dbSize = 0;
|
1466 |
$sum_rows=0;
|
@@ -1524,10 +1510,9 @@ class WPvivid {
|
|
1524 |
|
1525 |
$db_size=$this->formatBytes($dbSize);
|
1526 |
}
|
1527 |
-
|
1528 |
if($check_file)
|
1529 |
{
|
1530 |
-
include_once
|
1531 |
$backup = new WPvivid_Backup();
|
1532 |
|
1533 |
$files=array();
|
@@ -1545,42 +1530,12 @@ class WPvivid {
|
|
1545 |
WPvivid_Setting::set_default_common_option();
|
1546 |
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
1547 |
}
|
1548 |
-
$
|
1549 |
-
|
1550 |
-
$backup->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'upgrade',
|
1551 |
-
$backup->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir(),
|
1552 |
-
WPVIVID_PLUGIN_DIR,
|
1553 |
-
$backup->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.$options['log_save_location'],
|
1554 |
-
);
|
1555 |
-
switch ($type_name)
|
1556 |
-
{
|
1557 |
-
case WPVIVID_BACKUP_TYPE_PLUGIN:
|
1558 |
-
$path = $backup->get_default_directory(WPVIVID_BACKUP_TYPE_PLUGIN);
|
1559 |
-
break;
|
1560 |
-
case WPVIVID_BACKUP_TYPE_THEMES:
|
1561 |
-
$path = $backup->get_default_directory(WPVIVID_BACKUP_TYPE_THEMES);
|
1562 |
-
break;
|
1563 |
-
case WPVIVID_BACKUP_TYPE_UPLOADS:
|
1564 |
-
$path = $backup->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS);
|
1565 |
-
break;
|
1566 |
-
case WPVIVID_BACKUP_TYPE_CONTENT:
|
1567 |
-
$path = $backup -> get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT);
|
1568 |
-
$exclude_folder[] = $backup->get_default_directory(WPVIVID_BACKUP_TYPE_PLUGIN);
|
1569 |
-
$exclude_folder[] = $backup->get_default_directory(WPVIVID_BACKUP_TYPE_THEMES);
|
1570 |
-
$exclude_folder[] = $backup->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS);
|
1571 |
-
break;
|
1572 |
-
case WPVIVID_BACKUP_TYPE_CORE:
|
1573 |
-
$path = dirname(WP_CONTENT_DIR);
|
1574 |
-
$exclude_folder[] = $path;
|
1575 |
-
$exclude_folder[] = $backup -> get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT);
|
1576 |
-
break;
|
1577 |
-
default:
|
1578 |
-
break;
|
1579 |
-
}
|
1580 |
|
1581 |
-
if($path
|
1582 |
{
|
1583 |
-
$this->get_dir_files($files[$type_name],$temp,$path,
|
1584 |
}
|
1585 |
}
|
1586 |
|
@@ -1600,10 +1555,10 @@ class WPvivid {
|
|
1600 |
$ret['alter_files']=true;
|
1601 |
}
|
1602 |
$size+=$_file_size;
|
|
|
1603 |
}
|
1604 |
$file_size[$type_name]=$this->formatBytes($size);
|
1605 |
$sum_size+=$size;
|
1606 |
-
$sum_count++;
|
1607 |
}
|
1608 |
}
|
1609 |
|
@@ -1627,6 +1582,9 @@ class WPvivid {
|
|
1627 |
if($alter_fcgi)
|
1628 |
$ret['alter_fcgi']=true;
|
1629 |
}
|
|
|
|
|
|
|
1630 |
$file_size['sum']=$this->formatBytes($sum_size);
|
1631 |
}
|
1632 |
|
@@ -1828,11 +1786,9 @@ class WPvivid {
|
|
1828 |
|
1829 |
$this->wpvivid_log->WriteLog('Backup cancelled.','notice');
|
1830 |
WPvivid_taskmanager::update_backup_task_status($task_id,false,'cancel',false);
|
1831 |
-
$this->update_last_backup_task($task_id);
|
1832 |
$this->add_clean_backing_up_data_event($task_id);
|
1833 |
-
WPvivid_mail_report::send_report_mail($task_id);
|
1834 |
-
WPvivid_taskmanager::delete_task($task_id);
|
1835 |
WPvivid_Schedule::clear_monitor_schedule($task_id);
|
|
|
1836 |
die();
|
1837 |
}
|
1838 |
}
|
@@ -1842,9 +1798,13 @@ class WPvivid {
|
|
1842 |
$ret['result']='success';
|
1843 |
$ret['task_id']=$task_id;
|
1844 |
$json=json_encode($ret);
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
|
|
|
|
|
|
|
|
1848 |
|
1849 |
if (session_id())
|
1850 |
session_write_close();
|
@@ -1928,7 +1888,7 @@ class WPvivid {
|
|
1928 |
$download_info['backup_id']=sanitize_key($_POST['backup_id']);
|
1929 |
$download_info['file_name']=sanitize_file_name($_POST['file_name']);
|
1930 |
|
1931 |
-
|
1932 |
if (session_id())
|
1933 |
session_write_close();
|
1934 |
try
|
@@ -1955,10 +1915,23 @@ class WPvivid {
|
|
1955 |
|
1956 |
public function init_download($backup_id)
|
1957 |
{
|
1958 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
1959 |
$type_list=array();
|
1960 |
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
1961 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1962 |
if($backup['backup']['ismerge']==1)
|
1963 |
{
|
1964 |
$type_list[]='all';
|
@@ -2042,10 +2015,10 @@ class WPvivid {
|
|
2042 |
if($b_has_remote)
|
2043 |
{
|
2044 |
$data['files'][$file['file_name']]['status']='need_download';
|
2045 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2046 |
<span>Part'.$format_part.'</span></br>
|
2047 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2048 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0
|
2049 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2050 |
</div>';
|
2051 |
}
|
@@ -2061,7 +2034,7 @@ class WPvivid {
|
|
2061 |
if(time()-$task['run_time']>60)
|
2062 |
{
|
2063 |
$data['files'][$file['file_name']]['status']='timeout';
|
2064 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2065 |
<span>Part'.$format_part.'</span></br>
|
2066 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2067 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
@@ -2071,7 +2044,7 @@ class WPvivid {
|
|
2071 |
else
|
2072 |
{
|
2073 |
$data['files'][$file['file_name']]['status'] = 'running';
|
2074 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2075 |
<span>Part'.$format_part.'</span></br>
|
2076 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
2077 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
@@ -2085,10 +2058,10 @@ class WPvivid {
|
|
2085 |
if($b_has_remote)
|
2086 |
{
|
2087 |
$data['files'][$file['file_name']]['status']='need_download';
|
2088 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2089 |
<span>Part'.$format_part.'</span></br>
|
2090 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2091 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0
|
2092 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2093 |
</div>';
|
2094 |
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
@@ -2104,10 +2077,10 @@ class WPvivid {
|
|
2104 |
if($b_has_remote)
|
2105 |
{
|
2106 |
$data['files'][$file['file_name']]['status']='need_download';
|
2107 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2108 |
<span>Part'.$format_part.'</span></br>
|
2109 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2110 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0
|
2111 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2112 |
</div>';
|
2113 |
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
@@ -2128,7 +2101,7 @@ class WPvivid {
|
|
2128 |
$data['files'][$file['file_name']]['status']='completed';
|
2129 |
$download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
|
2130 |
$data['files'][$file['file_name']]['download_path']=$download_path;
|
2131 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2132 |
<span>Part'.$format_part.'</span></br>
|
2133 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Download</a></span></br>
|
2134 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:100%;height:5px;"></div></div>
|
@@ -2147,10 +2120,10 @@ class WPvivid {
|
|
2147 |
else{
|
2148 |
$format_part=$file_count;
|
2149 |
}
|
2150 |
-
$data['place_html']='<div style="float:left;margin:10px 10px 10px
|
2151 |
<span>Part'.$format_part.'</span></br>
|
2152 |
<span>Download</span></br>
|
2153 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0
|
2154 |
<span>size:</span><span>0</span>
|
2155 |
</div>';
|
2156 |
}
|
@@ -2205,7 +2178,7 @@ class WPvivid {
|
|
2205 |
if(time()-$task['run_time']>60)
|
2206 |
{
|
2207 |
$data['files'][$file['file_name']]['status']='timeout';
|
2208 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2209 |
<span>Part'.$format_part.'</span></br>
|
2210 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2211 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
@@ -2215,7 +2188,7 @@ class WPvivid {
|
|
2215 |
else
|
2216 |
{
|
2217 |
$data['files'][$file['file_name']]['status'] = 'running';
|
2218 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2219 |
<span>Part'.$format_part.'</span></br>
|
2220 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
2221 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
@@ -2226,7 +2199,7 @@ class WPvivid {
|
|
2226 |
} else if ($task['files'][$file['file_name']]['status'] == 'completed')
|
2227 |
{
|
2228 |
$data['files'][$file['file_name']]['status'] = 'completed';
|
2229 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2230 |
<span>Part'.$format_part.'</span></br>
|
2231 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Download</a></span></br>
|
2232 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:100%;height:5px;"></div></div>
|
@@ -2238,10 +2211,10 @@ class WPvivid {
|
|
2238 |
} else if ($task['files'][$file['file_name']]['status'] == 'error')
|
2239 |
{
|
2240 |
$data['files'][$file['file_name']]['status'] = 'error';
|
2241 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2242 |
<span>Part'.$format_part.'</span></br>
|
2243 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2244 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0
|
2245 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2246 |
</div>';
|
2247 |
$data['files'][$file['file_name']]['error']=__($task['files'][$file['file_name']]['error'], 'wpvivid');
|
@@ -2253,10 +2226,10 @@ class WPvivid {
|
|
2253 |
if($data['files'][$file['file_name']]['status']=='error')
|
2254 |
{
|
2255 |
$data['files'][$file['file_name']]['status']='need_download';
|
2256 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px
|
2257 |
<span>Part'.$format_part.'</span></br>
|
2258 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2259 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0
|
2260 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2261 |
</div>';
|
2262 |
$data['files'][$file['file_name']]['error']='';
|
@@ -2273,10 +2246,10 @@ class WPvivid {
|
|
2273 |
else{
|
2274 |
$format_part=$file_count;
|
2275 |
}
|
2276 |
-
$data['place_html']='<div style="float:left;margin:10px 10px 10px
|
2277 |
<span>Part'.$format_part.'</span></br>
|
2278 |
<span>Download</span></br>
|
2279 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0
|
2280 |
<span>size:</span><span>0</span>
|
2281 |
</div>';
|
2282 |
}
|
@@ -2417,12 +2390,16 @@ class WPvivid {
|
|
2417 |
session_write_close();
|
2418 |
|
2419 |
$size = filesize($path);
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
|
|
|
|
|
|
|
|
2426 |
if($size<1024*1024*60)
|
2427 |
{
|
2428 |
ob_end_clean();
|
@@ -2693,6 +2670,7 @@ class WPvivid {
|
|
2693 |
|
2694 |
$remote_options['type']=$_POST['type'];
|
2695 |
$ret=$this->remote_collection->add_remote($remote_options);
|
|
|
2696 |
if($ret['result']=='success')
|
2697 |
{
|
2698 |
$html = '';
|
@@ -2707,8 +2685,10 @@ class WPvivid {
|
|
2707 |
$schedule_local_remote='';
|
2708 |
$schedule_local_remote= apply_filters('wpvivid_schedule_local_remote',$schedule_local_remote);
|
2709 |
$ret['local_remote'] = $schedule_local_remote;
|
|
|
|
|
|
|
2710 |
}
|
2711 |
-
|
2712 |
echo json_encode($ret);
|
2713 |
die();
|
2714 |
}
|
@@ -2742,6 +2722,12 @@ class WPvivid {
|
|
2742 |
$dir = '';
|
2743 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
2744 |
$ret['dir'] = $dir;
|
|
|
|
|
|
|
|
|
|
|
|
|
2745 |
}
|
2746 |
else
|
2747 |
{
|
@@ -2817,6 +2803,12 @@ class WPvivid {
|
|
2817 |
$dir = '';
|
2818 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
2819 |
$ret['dir'] = $dir;
|
|
|
|
|
|
|
|
|
|
|
|
|
2820 |
}
|
2821 |
|
2822 |
echo json_encode($ret);
|
@@ -2841,6 +2833,12 @@ class WPvivid {
|
|
2841 |
$dir = '';
|
2842 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
2843 |
$ret['dir'] = $dir;
|
|
|
|
|
|
|
|
|
|
|
|
|
2844 |
|
2845 |
echo json_encode($ret);
|
2846 |
die();
|
@@ -3019,26 +3017,38 @@ class WPvivid {
|
|
3019 |
$this->ajax_check_security();
|
3020 |
|
3021 |
if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id'])
|
3022 |
-
||!isset($_POST['file_name'])||empty($_POST['file_name'])||!is_string($_POST['file_name'])
|
3023 |
-
||!isset($_POST['file_size'])||empty($_POST['file_size'])||!is_string($_POST['file_size'])
|
3024 |
-
||!isset($_POST['md5'])||empty($_POST['md5'])||!is_string($_POST['md5']))
|
3025 |
{
|
3026 |
die();
|
3027 |
}
|
|
|
|
|
|
|
3028 |
$backup_id = sanitize_key($_POST['backup_id']);
|
3029 |
$file_name=sanitize_file_name($_POST['file_name']);
|
3030 |
-
|
3031 |
-
$file_md5=$_POST['md5'];
|
3032 |
-
$backup = WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
3033 |
-
//echo json_encode($backup);
|
3034 |
-
//die();
|
3035 |
-
$download_dir = $backup['local']['path'];
|
3036 |
-
$file_path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $download_dir . DIRECTORY_SEPARATOR;
|
3037 |
-
$remotes = $backup['remote'];
|
3038 |
$file['file_name']=$file_name;
|
3039 |
-
$file['size']=$
|
3040 |
-
$file['md5']=$
|
3041 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3042 |
echo json_encode($ret);
|
3043 |
die();
|
3044 |
}
|
@@ -3058,29 +3068,39 @@ class WPvivid {
|
|
3058 |
|
3059 |
$restore_data=new WPvivid_restore_data();
|
3060 |
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
|
|
|
|
|
|
3078 |
}
|
3079 |
-
}
|
3080 |
-
|
3081 |
-
|
3082 |
-
$
|
3083 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3084 |
}
|
3085 |
|
3086 |
try
|
@@ -3237,6 +3257,32 @@ class WPvivid {
|
|
3237 |
}
|
3238 |
}
|
3239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3240 |
public function init_filesystem()
|
3241 |
{
|
3242 |
$credentials = request_filesystem_credentials(wp_nonce_url(admin_url('admin.php')."?page=WPvivid", 'wpvivid-nonce'));
|
@@ -3304,9 +3350,8 @@ class WPvivid {
|
|
3304 |
echo $message;
|
3305 |
}
|
3306 |
|
3307 |
-
public function update_last_backup_task($
|
3308 |
{
|
3309 |
-
$task=WPvivid_taskmanager::get_task($task_id);
|
3310 |
WPvivid_Setting::update_option('wpvivid_last_msg',$task);
|
3311 |
}
|
3312 |
/**
|
@@ -3357,15 +3402,25 @@ class WPvivid {
|
|
3357 |
public function list_tasks()
|
3358 |
{
|
3359 |
$this->ajax_check_security('manage_options');
|
3360 |
-
|
3361 |
-
if (isset($_POST['backup_id']))
|
3362 |
{
|
3363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3364 |
}
|
3365 |
-
|
3366 |
-
|
|
|
|
|
|
|
|
|
3367 |
}
|
3368 |
-
|
3369 |
die();
|
3370 |
}
|
3371 |
|
@@ -3419,6 +3474,9 @@ class WPvivid {
|
|
3419 |
$descript='';
|
3420 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3421 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
|
|
|
|
|
|
3422 |
if($list_tasks[$task['id']]['status']['str']=='ready'){
|
3423 |
$descript=__('Ready to backup. Progress: 0%, running time: 0second.','wpvivid');
|
3424 |
$css_btn_cancel='pointer-events: none; opacity: 0.4;';
|
@@ -3426,7 +3484,37 @@ class WPvivid {
|
|
3426 |
}
|
3427 |
else if($list_tasks[$task['id']]['status']['str']=='running'){
|
3428 |
if($list_tasks[$task['id']]['is_canceled'] == false){
|
3429 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3430 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3431 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
3432 |
}
|
@@ -3457,37 +3545,77 @@ class WPvivid {
|
|
3457 |
$descript='Task '.$task['id'].' completed.';
|
3458 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3459 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
3460 |
-
$
|
3461 |
-
$
|
3462 |
-
$list_tasks[$task['id']]['backuplist_html'] = $html;
|
3463 |
}
|
3464 |
else if($list_tasks[$task['id']]['status']['str']=='error'){
|
3465 |
$descript='Backup error: '.$list_tasks[$task['id']]['status']['error'];
|
3466 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3467 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
3468 |
-
$
|
3469 |
-
$
|
3470 |
-
$list_tasks[$task['id']]['backuplist_html'] = $html;
|
3471 |
}
|
3472 |
|
3473 |
-
$list_tasks[$task['id']]['progress_html']='<div class="action-progress-bar" id="wpvivid_action_progress_bar">
|
3474 |
-
<div class="action-progress-bar-percent" id="wpvivid_action_progress_bar_percent" style="height:24px;width:'
|
|
|
|
|
|
|
|
|
3475 |
</div>
|
3476 |
-
<div id="
|
3477 |
-
<div class="backup-basic-info"><span>'.__('
|
3478 |
-
<div class="backup-basic-info"><span>'.__('
|
|
|
3479 |
</div>
|
3480 |
<div style="clear:both;"></div>
|
3481 |
-
<div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_current_doing">'
|
3482 |
<div style="clear: both;"></div>
|
3483 |
<div>
|
3484 |
-
<div id="wpvivid_backup_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_backup_cancel_btn" type="submit" value="'.esc_attr('Cancel', 'wpvivid'
|
3485 |
-
<div id="wpvivid_backup_log" class="backup-log-btn"><input class="button-primary backup-log-btn" id="wpvivid_backup_log_btn" type="submit" value="'.esc_attr('Log', 'wpvivid'
|
3486 |
</div>
|
3487 |
<div style="clear: both;"></div>';
|
|
|
|
|
|
|
3488 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3489 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3490 |
}
|
|
|
3491 |
|
3492 |
$ret['backup']['result']='success';
|
3493 |
$ret['backup']['data']=$list_tasks;
|
@@ -3513,6 +3641,7 @@ class WPvivid {
|
|
3513 |
{
|
3514 |
delete_option('wpvivid_download_cache');
|
3515 |
delete_option('wpvivid_download_task');
|
|
|
3516 |
WPvivid_taskmanager::delete_ready_task();
|
3517 |
}
|
3518 |
/**
|
@@ -3730,114 +3859,127 @@ class WPvivid {
|
|
3730 |
{
|
3731 |
$this->ajax_check_security();
|
3732 |
|
3733 |
-
|
3734 |
-
{
|
3735 |
-
die();
|
3736 |
-
}
|
3737 |
-
$options=$_POST['options'];
|
3738 |
-
$options =stripslashes($options);
|
3739 |
-
$options=json_decode($options,true);
|
3740 |
-
if(is_null($options))
|
3741 |
-
{
|
3742 |
-
die();
|
3743 |
-
}
|
3744 |
-
if($options['log']=='0' && $options['backup_cache']=='0' && $options['junk_files']=='0' && $options['old_files']=='0')
|
3745 |
-
{
|
3746 |
-
$ret['result']=WPVIVID_FAILED;
|
3747 |
-
$ret['msg']=__('Choose at least one type of junk files for deleting.', 'wpvivid');
|
3748 |
-
echo json_encode($ret);
|
3749 |
-
die();
|
3750 |
-
}
|
3751 |
-
$delete_files = array();
|
3752 |
-
$delete_folder=array();
|
3753 |
-
if($options['log']=='1')
|
3754 |
{
|
3755 |
-
$
|
3756 |
-
|
3757 |
-
|
3758 |
-
|
3759 |
-
|
3760 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3761 |
{
|
3762 |
-
$
|
3763 |
-
$
|
3764 |
-
|
|
|
|
|
|
|
3765 |
{
|
3766 |
-
$
|
|
|
|
|
|
|
|
|
|
|
3767 |
}
|
3768 |
}
|
3769 |
-
}
|
3770 |
|
3771 |
-
|
3772 |
-
|
3773 |
-
|
3774 |
-
|
3775 |
-
|
3776 |
|
3777 |
-
|
3778 |
-
{
|
3779 |
-
$list=WPvivid_Backuplist::get_backuplist();
|
3780 |
-
$files=array();
|
3781 |
-
foreach ($list as $backup)
|
3782 |
{
|
3783 |
-
|
|
|
|
|
3784 |
{
|
3785 |
-
|
3786 |
{
|
3787 |
-
$
|
|
|
|
|
|
|
3788 |
}
|
3789 |
-
|
3790 |
-
else
|
3791 |
-
{
|
3792 |
-
foreach ($backup['backup']['data']['type'] as $type)
|
3793 |
{
|
3794 |
-
foreach ($
|
3795 |
{
|
3796 |
-
$
|
|
|
|
|
|
|
3797 |
}
|
3798 |
}
|
3799 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3800 |
}
|
3801 |
|
3802 |
-
$
|
3803 |
-
|
3804 |
-
|
3805 |
-
|
3806 |
-
$path = substr($path, 0, -1);
|
3807 |
}
|
3808 |
-
$folder[]= $path;
|
3809 |
|
3810 |
-
$
|
3811 |
-
|
|
|
|
|
|
|
3812 |
|
3813 |
-
|
3814 |
-
|
3815 |
-
|
3816 |
-
|
3817 |
-
|
3818 |
|
3819 |
-
|
3820 |
-
|
3821 |
-
|
|
|
|
|
|
|
|
|
|
|
3822 |
}
|
3823 |
-
|
3824 |
-
foreach ($delete_folder as $folder)
|
3825 |
{
|
3826 |
-
|
|
|
|
|
|
|
3827 |
}
|
3828 |
|
3829 |
-
$ret['result']='success';
|
3830 |
-
$ret['msg']=__('The selected junk flies have been deleted.', 'wpvivid');
|
3831 |
-
$ret['data']=$this->_junk_files_info();
|
3832 |
-
$html = '';
|
3833 |
-
$html = apply_filters('wpvivid_get_log_list', $html);
|
3834 |
-
$ret['html'] = $html['html'];
|
3835 |
-
$ret['log_count'] = $html['log_count'];
|
3836 |
-
echo json_encode($ret);
|
3837 |
die();
|
3838 |
}
|
3839 |
|
3840 |
-
public function get_dir_files(&$files,&$folder,$path,$except_regex,$exclude_files=array(),$exclude_folder=array(),$exclude_file_size=0)
|
3841 |
{
|
3842 |
$handler=opendir($path);
|
3843 |
while(($filename=readdir($handler))!==false)
|
@@ -3845,26 +3987,27 @@ class WPvivid {
|
|
3845 |
if($filename != "." && $filename != "..")
|
3846 |
{
|
3847 |
$dir=str_replace('/',DIRECTORY_SEPARATOR,$path.DIRECTORY_SEPARATOR.$filename);
|
|
|
|
|
3848 |
if(in_array($dir,$exclude_folder))
|
3849 |
{
|
3850 |
continue;
|
3851 |
}
|
3852 |
else if(is_dir($path.DIRECTORY_SEPARATOR.$filename))
|
3853 |
{
|
3854 |
-
$this->get_dir_files($files ,$folder, $path.DIRECTORY_SEPARATOR.$filename,$except_regex,$exclude_folder);
|
3855 |
if($except_regex!==false)
|
3856 |
{
|
3857 |
-
if(
|
3858 |
-
|
3859 |
-
$folder[]=$path.DIRECTORY_SEPARATOR.$filename;
|
3860 |
}
|
3861 |
-
|
3862 |
-
else
|
3863 |
{
|
3864 |
$folder[]=$path.DIRECTORY_SEPARATOR.$filename;
|
3865 |
}
|
|
|
3866 |
}else {
|
3867 |
-
if($except_regex===false
|
3868 |
{
|
3869 |
if(in_array($filename,$exclude_files))
|
3870 |
{
|
@@ -3884,8 +4027,51 @@ class WPvivid {
|
|
3884 |
}
|
3885 |
if($handler)
|
3886 |
@closedir($handler);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3887 |
}
|
3888 |
|
|
|
3889 |
public function get_setting()
|
3890 |
{
|
3891 |
$this->ajax_check_security('manage_options');
|
@@ -3956,6 +4142,12 @@ class WPvivid {
|
|
3956 |
$dir = '';
|
3957 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
3958 |
$ret['dir'] = $dir;
|
|
|
|
|
|
|
|
|
|
|
|
|
3959 |
echo json_encode($ret);
|
3960 |
die();
|
3961 |
}
|
@@ -4012,7 +4204,8 @@ class WPvivid {
|
|
4012 |
die();
|
4013 |
}
|
4014 |
|
4015 |
-
public function wpvivid_set_general_setting($setting_data, $setting, $options)
|
|
|
4016 |
$setting['use_temp_file'] = intval($setting['use_temp_file']);
|
4017 |
$setting['use_temp_size'] = intval($setting['use_temp_size']);
|
4018 |
$setting['exclude_file_size'] = intval($setting['exclude_file_size']);
|
@@ -4024,7 +4217,7 @@ class WPvivid {
|
|
4024 |
$setting_data['wpvivid_email_setting']['email_enable'] = $setting['email_enable'];
|
4025 |
|
4026 |
$setting_data['wpvivid_compress_setting']['compress_type'] = $setting['compress_type'];
|
4027 |
-
$setting_data['wpvivid_compress_setting']['max_file_size'] = $setting['max_file_size']
|
4028 |
$setting_data['wpvivid_compress_setting']['no_compress'] = $setting['no_compress'];
|
4029 |
$setting_data['wpvivid_compress_setting']['use_temp_file'] = $setting['use_temp_file'];
|
4030 |
$setting_data['wpvivid_compress_setting']['use_temp_size'] = $setting['use_temp_size'];
|
@@ -4047,51 +4240,61 @@ class WPvivid {
|
|
4047 |
|
4048 |
$ret=array();
|
4049 |
|
4050 |
-
|
4051 |
-
$json_setting = $_POST['setting'];
|
4052 |
-
$json_setting = stripslashes($json_setting);
|
4053 |
-
$setting = json_decode($json_setting, true);
|
4054 |
-
if (is_null($setting)){
|
4055 |
-
die();
|
4056 |
-
}
|
4057 |
-
$ret = $this->check_setting_option($setting);
|
4058 |
-
if($ret['result']!=WPVIVID_SUCCESS)
|
4059 |
-
{
|
4060 |
-
echo json_encode($ret);
|
4061 |
-
die();
|
4062 |
-
}
|
4063 |
-
add_filter('wpvivid_set_general_setting', array('WPvivid', 'wpvivid_set_general_setting'), 10, 3);
|
4064 |
-
$options=WPvivid_Setting::get_setting(true, "");
|
4065 |
-
$setting_data = array();
|
4066 |
-
$setting_data= apply_filters('wpvivid_set_general_setting',$setting_data, $setting, $options);
|
4067 |
-
$ret['setting']=WPvivid_Setting::update_setting($setting_data);
|
4068 |
-
}
|
4069 |
-
|
4070 |
-
if(isset($_POST['schedule'])&&!empty($_POST['schedule']))
|
4071 |
{
|
4072 |
-
$
|
4073 |
-
$json = stripslashes($json);
|
4074 |
-
$schedule = json_decode($json, true);
|
4075 |
-
if (is_null($schedule))
|
4076 |
-
{
|
4077 |
-
die();
|
4078 |
-
}
|
4079 |
-
$ret = $this->check_schedule_option($schedule);
|
4080 |
-
if($ret['result']!=WPVIVID_SUCCESS)
|
4081 |
{
|
4082 |
-
|
4083 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4084 |
}
|
4085 |
-
|
4086 |
-
$
|
4087 |
-
if($ret['result']!='success')
|
4088 |
{
|
4089 |
-
|
4090 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4091 |
}
|
4092 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4093 |
echo json_encode($ret);
|
4094 |
-
|
4095 |
die();
|
4096 |
}
|
4097 |
|
@@ -4227,12 +4430,15 @@ class WPvivid {
|
|
4227 |
}
|
4228 |
|
4229 |
$json=WPvivid_Setting::export_setting_to_json($setting,$history,$review);
|
4230 |
-
|
4231 |
-
|
4232 |
-
|
4233 |
-
|
4234 |
-
|
4235 |
-
|
|
|
|
|
|
|
4236 |
|
4237 |
echo json_encode($json);
|
4238 |
}
|
@@ -4285,7 +4491,7 @@ class WPvivid {
|
|
4285 |
{
|
4286 |
$subject = 'WPvivid Test Mail';
|
4287 |
$body = 'This is a test mail from WPvivid backup plugin';
|
4288 |
-
$headers = '
|
4289 |
if(wp_mail( $send_to, $subject, $body,$headers)===false)
|
4290 |
{
|
4291 |
$ret['result']='failed';
|
@@ -4348,12 +4554,16 @@ class WPvivid {
|
|
4348 |
session_write_close();
|
4349 |
|
4350 |
$size = filesize($path);
|
4351 |
-
|
4352 |
-
|
4353 |
-
|
4354 |
-
|
4355 |
-
|
4356 |
-
|
|
|
|
|
|
|
|
|
4357 |
|
4358 |
ob_end_clean();
|
4359 |
readfile( $path );
|
@@ -4380,7 +4590,6 @@ class WPvivid {
|
|
4380 |
|
4381 |
public function wpvivid_get_log_list($html)
|
4382 |
{
|
4383 |
-
$html = '';
|
4384 |
$loglist=$this->get_log_list_ex();
|
4385 |
$current_num=1;
|
4386 |
$max_log_diaplay=20;
|
@@ -4653,12 +4862,33 @@ class WPvivid {
|
|
4653 |
|
4654 |
if( $ret['data']['pdo_mysql']=='support')
|
4655 |
{
|
4656 |
-
$
|
4657 |
-
$
|
4658 |
-
$
|
4659 |
-
|
4660 |
-
|
4661 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4662 |
}
|
4663 |
}
|
4664 |
else {
|
@@ -4726,6 +4956,15 @@ class WPvivid {
|
|
4726 |
}
|
4727 |
|
4728 |
$remote_pic_html='';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4729 |
$b_has_remote=false;
|
4730 |
if(is_array($remote)) {
|
4731 |
foreach ($remote as $key1 => $value1) {
|
@@ -4747,7 +4986,7 @@ class WPvivid {
|
|
4747 |
$html .= '<tr>
|
4748 |
<th class="check-column"><input name="check_backup" type="checkbox" id="'.esc_attr($key, 'wpvivid').'" value="'.esc_attr($key, 'wpvivid').'" onclick="wpvivid_click_check_backup(\''.__($key, 'wpvivid').'\');" /></th>
|
4749 |
<td class="tablelistcolumn">
|
4750 |
-
<div style="float:left;padding:
|
4751 |
<div class="backuptime"><strong>'.__(date('M d, Y H:i',$value['create_time']), 'wpvivid').'</strong></div>
|
4752 |
<div class="common-table">
|
4753 |
<span title="To lock the backup, the backup can only be deleted manually" id="wpvivid_lock_'.$key.'">
|
@@ -4760,10 +4999,10 @@ class WPvivid {
|
|
4760 |
</div>
|
4761 |
</td>
|
4762 |
<td class="tablelistcolumn">
|
4763 |
-
<div style="float:left;padding:10px 10px 10px
|
4764 |
</td>
|
4765 |
<td class="tablelistcolumn">
|
4766 |
-
<div id="wpvivid_file_part_'.__($key, 'wpvivid').'" style="float:left;padding:10px 10px 10px
|
4767 |
<div style="cursor:pointer;" onclick="wpvivid_initialize_download(\''.__($key, 'wpvivid').'\');" title="Prepare to download the backup">
|
4768 |
<img id="wpvivid_download_btn_'.__($key, 'wpvivid').'" src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/download.png').'" style="vertical-align:middle;" />'.__('Download', 'wpvivid').'
|
4769 |
<div class="spinner" id="wpvivid_download_loading_'.__($key, 'wpvivid').'" style="float:right;width:auto;height:auto;padding:10px 180px 10px 0;background-position:0 0;"></div>
|
@@ -4811,14 +5050,25 @@ class WPvivid {
|
|
4811 |
<td>'.__($storage_type, 'wpvivid').'</td>
|
4812 |
<td class="row-title"><label for="tablecell">'.__($value['name'], 'wpvivid').'</label></td>
|
4813 |
<td>
|
4814 |
-
<div style="float: left;"><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Edit.png').'" onclick="click_retrieve_remote_storage(\''.__($key, 'wpvivid').'\',\''.__($value['type'], 'wpvivid').'\',\''.__($value['name'], 'wpvivid').'\'
|
4815 |
-
|
|
|
|
|
4816 |
</td>
|
4817 |
</tr>';
|
4818 |
}
|
4819 |
return $html;
|
4820 |
}
|
4821 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4822 |
public function wpvivid_schedule_add_remote_pic($html){
|
4823 |
$html = '';
|
4824 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
@@ -5028,4 +5278,25 @@ class WPvivid {
|
|
5028 |
}
|
5029 |
die();
|
5030 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5031 |
}
|
45 |
|
46 |
public $remote_collection;
|
47 |
|
48 |
+
public $end_shutdown_function;
|
49 |
+
|
50 |
public function __construct()
|
51 |
{
|
52 |
$this->version = WPVIVID_PLUGIN_VERSION;
|
53 |
|
54 |
$this->plugin_name = WPVIVID_PLUGIN_SLUG;
|
55 |
|
56 |
+
$this->end_shutdown_function = false;
|
57 |
+
|
58 |
//Load dependent files
|
59 |
$this->load_dependencies();
|
60 |
|
92 |
add_filter('wpvivid_get_log_list', array( $this, 'wpvivid_get_log_list' ), 10);
|
93 |
add_filter('wpvivid_get_last_backup_message', array( $this, 'wpvivid_get_last_backup_message' ), 10);
|
94 |
add_filter('wpvivid_schedule_local_remote', array( $this, 'wpvivid_schedule_local_remote' ), 10);
|
95 |
+
add_filter('wpvivid_remote_storage', array( $this, 'wpvivid_remote_storage'), 10);
|
96 |
+
add_action('wpvivid_handle_backup_succeed',array($this,'wpvivid_handle_backup_succeed'),10);
|
97 |
+
add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_handle_backup_succeed'),10);
|
98 |
+
|
99 |
+
add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_mark_task'),20);
|
100 |
+
add_action('wpvivid_handle_backup_succeed',array($this,'wpvivid_mark_task'),20);
|
101 |
+
|
102 |
+
add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_handle_backup_failed'),9);
|
103 |
+
|
104 |
+
add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_deal_upload_succeed'),9);
|
105 |
+
|
106 |
+
add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_mark_task'),20);
|
107 |
|
108 |
//Initialisation schedule hook
|
109 |
$this->init_cron();
|
126 |
|
127 |
private function load_dependencies()
|
128 |
{
|
129 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-schedule.php';
|
130 |
|
131 |
+
require_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-i18n.php';
|
132 |
+
require_once WPVIVID_PLUGIN_DIR . '/admin/class-wpvivid-admin.php';
|
133 |
|
134 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-setting.php';
|
135 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-log.php';
|
136 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-error-log.php';
|
137 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-backuplist.php';
|
138 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore-data.php';
|
139 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-taskmanager.php';
|
140 |
|
141 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-downloader.php';
|
142 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-backup.php';
|
143 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-mail-report.php';
|
144 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore.php';
|
145 |
|
146 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-remote-collection.php';
|
147 |
+
include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-upload.php';
|
148 |
$this->remote_collection=new WPvivid_Remote_collection();
|
149 |
}
|
150 |
|
276 |
add_action('wp_ajax_wpvivid_rollback',array( $this,'rollback'));
|
277 |
add_action('wp_ajax_wpvivid_get_restore_progress',array( $this,'get_restore_progress'));
|
278 |
add_action('wp_ajax_wpvivid_get_rollback_progress',array( $this,'get_rollback_progress'));
|
279 |
+
add_action('wp_ajax_wpvivid_get_download_restore_progress',array( $this,'download_restore_progress'));
|
280 |
//When restoring the database use wp_ajax_nopriv_
|
281 |
add_action('wp_ajax_nopriv_wpvivid_init_restore_page',array( $this,'init_restore_page'));
|
282 |
add_action('wp_ajax_nopriv_wpvivid_delete_last_restore_data',array( $this,'delete_last_restore_data'));
|
292 |
//Get default remote storage when backing up
|
293 |
add_action('wp_ajax_wpvivid_get_default_remote_storage',array( $this,'get_default_remote_storage'));
|
294 |
add_action('wp_ajax_wpvivid_need_review',array( $this,'need_review'));
|
295 |
+
add_action('wp_ajax_wpvivid_send_debug_info',array($this,'wpvivid_send_debug_info'));
|
296 |
}
|
297 |
|
298 |
public function get_plugin_name()
|
360 |
echo json_encode($ret);
|
361 |
die();
|
362 |
}
|
|
|
363 |
add_filter('wpvivid_check_backup_options_valid',array($this,'check_backup_options_valid'),10);
|
364 |
$backup_options=apply_filters('wpvivid_check_backup_options_valid',$backup_options);
|
365 |
|
370 |
echo json_encode($ret);
|
371 |
die();
|
372 |
}
|
|
|
373 |
$ret=$this->pre_backup($backup_options,'Manual');
|
374 |
if($ret['result']=='success')
|
375 |
{
|
376 |
//Check the website data to be backed up
|
377 |
$ret['check']=$this->check_backup($ret['task_id'],$backup_options['backup_files']);
|
378 |
+
if(isset($ret['check']['result']) && $ret['check']['result'] == WPVIVID_FAILED){
|
379 |
+
echo json_encode(array('result' => WPVIVID_FAILED,'error' => $ret['check']['error']));
|
380 |
+
die();
|
381 |
+
}
|
382 |
+
|
383 |
$html = '';
|
384 |
$html = apply_filters('wpvivid_add_backup_list', $html);
|
385 |
$ret['html'] = $html;
|
729 |
{
|
730 |
die();
|
731 |
}
|
732 |
+
|
733 |
+
$doing=WPvivid_taskmanager::get_backup_main_task_progress($task_id);
|
734 |
+
if($doing=='backup')
|
735 |
+
{
|
736 |
+
$this->backup($task_id);
|
737 |
+
}
|
738 |
+
else if($doing=='upload')
|
739 |
+
{
|
740 |
+
$this->upload($task_id);
|
741 |
+
}
|
742 |
//resume backup
|
743 |
+
|
744 |
die();
|
745 |
}
|
746 |
|
967 |
public function backup($task_id)
|
968 |
{
|
969 |
//register shutdown function to catch php fatal error such as script time out and memory limit
|
970 |
+
$this->end_shutdown_function=false;
|
971 |
register_shutdown_function(array($this,'deal_shutdown_error'),$task_id);
|
972 |
@ignore_user_abort(true);
|
973 |
WPvivid_taskmanager::update_backup_task_status($task_id,true,'running');
|
978 |
$this->flush($task_id);
|
979 |
$this->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id,'log_file_name'));
|
980 |
$this->wpvivid_log->WriteLog('Start backing up.','notice');
|
981 |
+
$this->wpvivid_log->WriteLogHander();
|
982 |
//start backup
|
983 |
try
|
984 |
{
|
|
|
985 |
$backup=new WPvivid_Backup();
|
986 |
|
987 |
+
$backup_ret=$backup->backup($task_id);
|
988 |
+
|
989 |
+
WPvivid_tools::clearcache($task_id);
|
990 |
+
|
991 |
+
if($backup_ret['result'] != 'succeed')
|
992 |
{
|
993 |
+
$this->wpvivid_log->WriteLog('Backup ends with an error '. $backup_ret['error'], 'error');
|
994 |
+
}
|
995 |
+
else {
|
996 |
+
$this->wpvivid_log->WriteLog('Backup completed.','notice');
|
997 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
998 |
|
999 |
+
if(!$this->finish_backup_task($task_id,$backup_ret))
|
1000 |
+
{
|
1001 |
+
$this->end_shutdown_function=true;
|
1002 |
+
die();
|
|
|
|
|
|
|
|
|
|
|
1003 |
}
|
1004 |
+
|
1005 |
if(WPvivid_taskmanager::get_task_options($task_id,'remote_options')!=false)
|
1006 |
{
|
1007 |
+
$this->upload($task_id);
|
|
|
|
|
|
|
1008 |
}
|
|
|
1009 |
}
|
1010 |
catch (Exception $e)
|
1011 |
{
|
1012 |
//catch error and stop task recording history
|
1013 |
$this->deal_task_error($task_id,'exception',$e);
|
1014 |
$this->wpvivid_log->CloseFile();
|
1015 |
+
$this->end_shutdown_function=true;
|
1016 |
die();
|
1017 |
}
|
1018 |
catch (Error $e)
|
1020 |
//catch error and stop task recording history
|
1021 |
$this->deal_task_error($task_id,'error',$e);
|
1022 |
$this->wpvivid_log->CloseFile();
|
1023 |
+
$this->end_shutdown_function=true;
|
1024 |
die();
|
1025 |
}
|
1026 |
+
$this->end_shutdown_function=true;
|
1027 |
die();
|
1028 |
}
|
1029 |
+
|
1030 |
+
/**
|
1031 |
+
* recording finished backup task.
|
1032 |
+
*
|
1033 |
+
* @var string $task_id
|
1034 |
+
*
|
1035 |
+
* @var array $backup_ret return data of backup
|
1036 |
+
*
|
1037 |
+
* @return boolean
|
1038 |
+
*
|
1039 |
+
* @since 0.9.1
|
1040 |
+
*/
|
1041 |
+
private function finish_backup_task($task_id,$backup_ret)
|
1042 |
+
{
|
1043 |
+
$status=WPvivid_taskmanager::get_backup_task_status($task_id);
|
1044 |
+
if($status['str']=='running')
|
1045 |
+
{
|
1046 |
+
$this->wpvivid_log->WriteLog('Backup succeeded.','notice');
|
1047 |
+
WPvivid_Backuplist::add_new_backup($task_id,$backup_ret);
|
1048 |
+
|
1049 |
+
$remote_options=WPvivid_taskmanager::get_task_options($task_id,'remote_options');
|
1050 |
+
if($remote_options===false)
|
1051 |
+
{
|
1052 |
+
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'completed');
|
1053 |
+
do_action('wpvivid_handle_backup_succeed',$task);
|
1054 |
+
}
|
1055 |
+
else
|
1056 |
+
{
|
1057 |
+
WPvivid_taskmanager::update_task_options($task_id,'backup',WPvivid_Backuplist::get_backuplist_by_key($task_id));
|
1058 |
+
}
|
1059 |
+
return true;
|
1060 |
+
}
|
1061 |
+
else
|
1062 |
+
{
|
1063 |
+
$task=WPvivid_taskmanager::get_task($task_id);
|
1064 |
+
do_action('wpvivid_handle_backup_failed',$task);
|
1065 |
+
return false;
|
1066 |
+
}
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
public function wpvivid_analysis_backup($task){
|
1070 |
+
if($task['type'] == 'Cron')
|
1071 |
+
{
|
1072 |
$cron_backup_count = WPvivid_Setting::get_option('cron_backup_count');
|
1073 |
if(empty($cron_backup_count)){
|
1074 |
$cron_backup_count = 0;
|
1089 |
}
|
1090 |
}
|
1091 |
/**
|
1092 |
+
* start upload files to remote.
|
1093 |
*
|
1094 |
* @var string $task_id
|
1095 |
*
|
1096 |
+
* @since 0.9.10
|
|
|
|
|
1097 |
*/
|
1098 |
+
public function upload($task_id)
|
1099 |
{
|
1100 |
+
$this->end_shutdown_function=false;
|
1101 |
+
register_shutdown_function(array($this,'deal_shutdown_error'),$task_id);
|
1102 |
+
@ignore_user_abort(true);
|
1103 |
+
WPvivid_taskmanager::update_backup_task_status($task_id,true,'running');
|
1104 |
+
$this->current_task=WPvivid_taskmanager::get_task($task_id);
|
1105 |
+
//start a watch task event
|
1106 |
+
$this->add_monitor_event($task_id);
|
1107 |
+
//flush buffer
|
1108 |
+
$this->flush($task_id);
|
1109 |
+
$this->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id,'log_file_name'));
|
1110 |
+
$this->wpvivid_log->WriteLog('Start upload.','notice');
|
1111 |
+
|
1112 |
+
$this->set_time_limit($task_id);
|
1113 |
|
1114 |
+
$upload=new WPvivid_Upload();
|
1115 |
+
$backup=WPvivid_taskmanager::get_task_options($task_id,'backup');
|
1116 |
+
$ret=$upload->upload($task_id,$backup);
|
1117 |
+
if($ret['result'] == WPVIVID_SUCCESS)
|
1118 |
{
|
1119 |
+
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'completed');
|
1120 |
+
do_action('wpvivid_handle_upload_succeed',$task);
|
1121 |
+
|
1122 |
}
|
1123 |
else
|
1124 |
{
|
1125 |
+
$list = WPvivid_Setting::get_option('wpvivid_backup_list');
|
1126 |
+
$list[$task_id]['save_local']=1;
|
1127 |
+
WPvivid_Setting::update_option('wpvivid_backup_list',$list);
|
1128 |
+
$this->wpvivid_log->WriteLog('Uploading the file ends with an error '. $ret['error'], 'error');
|
1129 |
+
$task=WPvivid_taskmanager::get_task($task_id);
|
1130 |
+
do_action('wpvivid_handle_backup_failed',$task);
|
1131 |
}
|
1132 |
+
$this->end_shutdown_function=true;
|
1133 |
+
die();
|
|
|
1134 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1135 |
|
1136 |
+
function wpvivid_deal_upload_succeed($task)
|
1137 |
+
{
|
1138 |
+
$save_local=$task['options']['save_local'];
|
1139 |
+
if($save_local==0)
|
1140 |
{
|
1141 |
+
$this->wpvivid_log->WriteLog('Cleaned up local files after uploading to remote storages.','notice');
|
1142 |
+
$file_prefix=$task['options']['file_prefix'];
|
1143 |
+
$backup_options=$task['options']['backup_options'];
|
1144 |
+
$backup=new WPvivid_Backup();
|
1145 |
+
$backup->clean_backup($file_prefix,$backup_options['dir']);
|
1146 |
}
|
1147 |
+
$this->wpvivid_log->WriteLog('Upload succeeded.','notice');
|
1148 |
+
$remote_options=$task['options']['remote_options'];
|
1149 |
+
WPvivid_Backuplist::update_backup($task['id'],'remote',$remote_options);
|
1150 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1151 |
|
1152 |
+
function wpvivid_handle_backup_succeed($task)
|
1153 |
+
{
|
1154 |
+
$backup_success_count=WPvivid_Setting::get_option('wpvivid_backup_success_count');
|
1155 |
+
if(empty($backup_success_count)){
|
1156 |
+
$backup_success_count=0;
|
1157 |
+
}
|
1158 |
+
$backup_success_count++;
|
1159 |
+
WPvivid_Setting::update_option('wpvivid_backup_success_count', $backup_success_count);
|
1160 |
+
$this->wpvivid_log->WriteLog('->succeed->01.','notice');
|
1161 |
+
$this->wpvivid_analysis_backup($task);
|
1162 |
+
WPvivid_Schedule::clear_monitor_schedule($task['id']);
|
1163 |
+
WPvivid_mail_report::send_report_mail($task);
|
1164 |
+
$this->wpvivid_log->WriteLog('->succeed->02.','notice');
|
1165 |
+
$this->wpvivid_log->CloseFile();
|
|
|
|
|
|
|
1166 |
}
|
1167 |
+
|
1168 |
+
function wpvivid_mark_task($task)
|
1169 |
{
|
1170 |
+
WPvivid_taskmanager::mark_task($task['id']);
|
1171 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1172 |
|
1173 |
+
function wpvivid_handle_backup_failed($task)
|
1174 |
+
{
|
1175 |
+
$backup_error_array=WPvivid_Setting::get_option('wpvivid_backup_error_array');
|
1176 |
+
if(empty($backup_error_array)){
|
1177 |
+
$backup_error_array=array();
|
|
|
1178 |
}
|
1179 |
+
if(!array_key_exists($task['id'], $backup_error_array['bu_error'])){
|
1180 |
+
$backup_error_array['bu_error']['task_id'] = $task['id'];
|
1181 |
+
$backup_error_array['bu_error']['error_msg'] = $task['status']['error'];
|
1182 |
+
WPvivid_Setting::update_option('wpvivid_backup_error_array', $backup_error_array);
|
|
|
|
|
1183 |
}
|
1184 |
+
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1185 |
+
$this->wpvivid_log->CloseFile();
|
1186 |
+
WPvivid_Schedule::clear_monitor_schedule($task['id']);
|
1187 |
+
$this->add_clean_backing_up_data_event($task['id']);
|
1188 |
+
WPvivid_mail_report::send_report_mail($task);
|
1189 |
}
|
1190 |
+
|
1191 |
public function deal_shutdown_error($task_id)
|
1192 |
{
|
1193 |
+
if($this->end_shutdown_function===false) {
|
1194 |
+
$last_error = error_get_last();
|
1195 |
+
if (!empty($last_error) && !in_array($last_error['type'], array(E_NOTICE), true)) {
|
1196 |
+
$error = $last_error;
|
1197 |
+
} else {
|
1198 |
+
$error = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1199 |
}
|
1200 |
+
//$this->task_monitor($task_id,$error);
|
1201 |
+
if (WPvivid_taskmanager::get_task($task_id) !== false) {
|
1202 |
+
if ($this->wpvivid_log->log_file_handle == false) {
|
1203 |
+
$this->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id, 'log_file_name'));
|
1204 |
+
}
|
1205 |
|
1206 |
+
$status = WPvivid_taskmanager::get_backup_task_status($task_id);
|
1207 |
|
1208 |
+
if ($status['str'] == 'running' || $status['str'] == 'error' || $status['str'] == 'no_responds') {
|
1209 |
+
$limit = WPvivid_taskmanager::get_task_options($task_id, 'max_execution_time');
|
1210 |
+
$time_spend = time() - $status['timeout'];
|
|
|
1211 |
|
1212 |
+
if ($time_spend >= $limit) {
|
1213 |
+
//time out
|
1214 |
+
$status['resume_count']++;
|
1215 |
+
if ($status['resume_count'] > WPVIVID_RESUME_RETRY_TIMES) {
|
1216 |
+
$message = __('Too many resumption attempts.', 'wpvivid');
|
1217 |
+
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1218 |
+
do_action('wpvivid_handle_backup_failed', $task);
|
1219 |
+
} else {
|
1220 |
+
$this->check_cancel_backup($task_id);
|
1221 |
+
$message = 'Task timed out.';
|
1222 |
+
if ($this->add_resume_event($task_id)) {
|
1223 |
+
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'wait_resume', false, $status['resume_count']);
|
1224 |
+
} else {
|
1225 |
+
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1226 |
+
do_action('wpvivid_handle_backup_failed', $task);
|
1227 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1228 |
}
|
1229 |
+
if ($this->wpvivid_log)
|
1230 |
+
$this->wpvivid_log->WriteLog($message, 'error');
|
1231 |
+
} else {
|
1232 |
+
if ($status['str'] != 'error') {
|
1233 |
+
if ($error !== false) {
|
1234 |
+
$message = $error['message'] . ' file:' . $error['file'] . ' line:' . $error['line'];
|
1235 |
+
} else {
|
1236 |
+
$message = __('backup failed error unknown', 'wpvivid');
|
1237 |
+
}
|
1238 |
+
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1239 |
}
|
1240 |
+
$task = WPvivid_taskmanager::get_task($task_id);
|
1241 |
+
do_action('wpvivid_handle_backup_failed', $task);
|
1242 |
}
|
|
|
|
|
|
|
|
|
|
|
1243 |
}
|
1244 |
}
|
1245 |
+
die();
|
1246 |
}
|
|
|
1247 |
}
|
1248 |
public function deal_task_error($task_id,$error_type,$error)
|
1249 |
{
|
1250 |
$message = 'An '.$error_type.' has occurred. class:'.get_class($error).';msg:'.$error->getMessage().';code:'.$error->getCode().';line:'.$error->getLine().';in_file:'.$error->getFile().';';
|
1251 |
error_log($message);
|
1252 |
+
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,false,$message);
|
1253 |
$this->wpvivid_log->WriteLog($message,'error');
|
1254 |
|
1255 |
+
do_action('wpvivid_handle_backup_failed',$task);
|
|
|
|
|
1256 |
}
|
1257 |
/**
|
1258 |
* update time limit.
|
1304 |
if($status['resume_count']>WPVIVID_RESUME_RETRY_TIMES)
|
1305 |
{
|
1306 |
$message=__('Too many resumption attempts.', 'wpvivid');
|
1307 |
+
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
|
|
|
|
|
|
1308 |
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1309 |
+
do_action('wpvivid_handle_backup_failed',$task);
|
1310 |
}
|
1311 |
else
|
1312 |
{
|
1318 |
}
|
1319 |
else
|
1320 |
{
|
1321 |
+
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1322 |
+
do_action('wpvivid_handle_backup_failed',$task);
|
|
|
|
|
|
|
|
|
1323 |
}
|
1324 |
}
|
1325 |
if($this->wpvivid_log)
|
1338 |
if($error!==false)
|
1339 |
{
|
1340 |
$message=$error['message'].' file:'.$error['file'].' line:'.$error['line'];
|
1341 |
+
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1342 |
+
do_action('wpvivid_handle_backup_failed',$task);
|
|
|
|
|
|
|
|
|
1343 |
}
|
1344 |
else
|
1345 |
{
|
1425 |
{
|
1426 |
$alter_fcgi=false;
|
1427 |
}
|
|
|
1428 |
if($check_db)
|
1429 |
{
|
1430 |
$ret['big_tables']=array();
|
1431 |
$db_info=array();
|
1432 |
+
|
1433 |
+
$res = explode(':',DB_HOST);
|
1434 |
+
$db_host = $res[0];
|
1435 |
+
$db_port = empty($res[1])?'':$res[1];
|
1436 |
+
if(!empty($db_port))
|
1437 |
+
$db_host = $db_host.':'.$db_port;
|
1438 |
+
try{
|
1439 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
1440 |
+
}catch (Exception $e)
|
1441 |
+
{
|
1442 |
+
if(!empty($db_port)){
|
1443 |
+
$db_host = $res[0];
|
1444 |
+
$pdo=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
1445 |
+
}else{
|
1446 |
+
return array('result' => WPVIVID_FAILED,'error' => 'The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.');
|
1447 |
+
}
|
1448 |
+
}
|
1449 |
+
|
1450 |
$sth = $pdo->query('SHOW TABLE STATUS');
|
1451 |
$dbSize = 0;
|
1452 |
$sum_rows=0;
|
1510 |
|
1511 |
$db_size=$this->formatBytes($dbSize);
|
1512 |
}
|
|
|
1513 |
if($check_file)
|
1514 |
{
|
1515 |
+
include_once WPVIVID_PLUGIN_DIR .'/includes/class-wpvivid-backup.php';
|
1516 |
$backup = new WPvivid_Backup();
|
1517 |
|
1518 |
$files=array();
|
1530 |
WPvivid_Setting::set_default_common_option();
|
1531 |
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
1532 |
}
|
1533 |
+
$path = $backup->get_default_directory($type_name);
|
1534 |
+
$exclude_regex = $backup -> get_default_exclude_regex($type_name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1535 |
|
1536 |
+
if(!empty($path))
|
1537 |
{
|
1538 |
+
$this->get_dir_files($files[$type_name],$temp,$path,$exclude_regex,array(),array(),$exclude_size);
|
1539 |
}
|
1540 |
}
|
1541 |
|
1555 |
$ret['alter_files']=true;
|
1556 |
}
|
1557 |
$size+=$_file_size;
|
1558 |
+
$sum_count++;
|
1559 |
}
|
1560 |
$file_size[$type_name]=$this->formatBytes($size);
|
1561 |
$sum_size+=$size;
|
|
|
1562 |
}
|
1563 |
}
|
1564 |
|
1582 |
if($alter_fcgi)
|
1583 |
$ret['alter_fcgi']=true;
|
1584 |
}
|
1585 |
+
else{
|
1586 |
+
$ret['sum_count']=$sum_count;
|
1587 |
+
}
|
1588 |
$file_size['sum']=$this->formatBytes($sum_size);
|
1589 |
}
|
1590 |
|
1786 |
|
1787 |
$this->wpvivid_log->WriteLog('Backup cancelled.','notice');
|
1788 |
WPvivid_taskmanager::update_backup_task_status($task_id,false,'cancel',false);
|
|
|
1789 |
$this->add_clean_backing_up_data_event($task_id);
|
|
|
|
|
1790 |
WPvivid_Schedule::clear_monitor_schedule($task_id);
|
1791 |
+
WPvivid_taskmanager::delete_task($task_id);
|
1792 |
die();
|
1793 |
}
|
1794 |
}
|
1798 |
$ret['result']='success';
|
1799 |
$ret['task_id']=$task_id;
|
1800 |
$json=json_encode($ret);
|
1801 |
+
if(!headers_sent())
|
1802 |
+
{
|
1803 |
+
header('Content-Length: '.strlen($json));
|
1804 |
+
header('Connection: close');
|
1805 |
+
header('Content-Encoding: none');
|
1806 |
+
}
|
1807 |
+
|
1808 |
|
1809 |
if (session_id())
|
1810 |
session_write_close();
|
1888 |
$download_info['backup_id']=sanitize_key($_POST['backup_id']);
|
1889 |
$download_info['file_name']=sanitize_file_name($_POST['file_name']);
|
1890 |
|
1891 |
+
set_time_limit(600);
|
1892 |
if (session_id())
|
1893 |
session_write_close();
|
1894 |
try
|
1915 |
|
1916 |
public function init_download($backup_id)
|
1917 |
{
|
1918 |
+
if(empty($backup_id))
|
1919 |
+
{
|
1920 |
+
$ret['result']=WPVIVID_SUCCESS;
|
1921 |
+
$ret['data']=array();
|
1922 |
+
return $ret;
|
1923 |
+
}
|
1924 |
+
$ret['result']=WPVIVID_SUCCESS;
|
1925 |
$type_list=array();
|
1926 |
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
1927 |
|
1928 |
+
if($backup===false)
|
1929 |
+
{
|
1930 |
+
$ret['result']=WPVIVID_FAILED;
|
1931 |
+
$ret['error']='backup id not found';
|
1932 |
+
return $ret;
|
1933 |
+
}
|
1934 |
+
|
1935 |
if($backup['backup']['ismerge']==1)
|
1936 |
{
|
1937 |
$type_list[]='all';
|
2015 |
if($b_has_remote)
|
2016 |
{
|
2017 |
$data['files'][$file['file_name']]['status']='need_download';
|
2018 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2019 |
<span>Part'.$format_part.'</span></br>
|
2020 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2021 |
+
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2022 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2023 |
</div>';
|
2024 |
}
|
2034 |
if(time()-$task['run_time']>60)
|
2035 |
{
|
2036 |
$data['files'][$file['file_name']]['status']='timeout';
|
2037 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2038 |
<span>Part'.$format_part.'</span></br>
|
2039 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2040 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
2044 |
else
|
2045 |
{
|
2046 |
$data['files'][$file['file_name']]['status'] = 'running';
|
2047 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2048 |
<span>Part'.$format_part.'</span></br>
|
2049 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
2050 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
2058 |
if($b_has_remote)
|
2059 |
{
|
2060 |
$data['files'][$file['file_name']]['status']='need_download';
|
2061 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2062 |
<span>Part'.$format_part.'</span></br>
|
2063 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2064 |
+
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2065 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2066 |
</div>';
|
2067 |
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
2077 |
if($b_has_remote)
|
2078 |
{
|
2079 |
$data['files'][$file['file_name']]['status']='need_download';
|
2080 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2081 |
<span>Part'.$format_part.'</span></br>
|
2082 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2083 |
+
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2084 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2085 |
</div>';
|
2086 |
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
2101 |
$data['files'][$file['file_name']]['status']='completed';
|
2102 |
$download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
|
2103 |
$data['files'][$file['file_name']]['download_path']=$download_path;
|
2104 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2105 |
<span>Part'.$format_part.'</span></br>
|
2106 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Download</a></span></br>
|
2107 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:100%;height:5px;"></div></div>
|
2120 |
else{
|
2121 |
$format_part=$file_count;
|
2122 |
}
|
2123 |
+
$data['place_html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px; color:#cccccc;">
|
2124 |
<span>Part'.$format_part.'</span></br>
|
2125 |
<span>Download</span></br>
|
2126 |
+
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2127 |
<span>size:</span><span>0</span>
|
2128 |
</div>';
|
2129 |
}
|
2178 |
if(time()-$task['run_time']>60)
|
2179 |
{
|
2180 |
$data['files'][$file['file_name']]['status']='timeout';
|
2181 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2182 |
<span>Part'.$format_part.'</span></br>
|
2183 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2184 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
2188 |
else
|
2189 |
{
|
2190 |
$data['files'][$file['file_name']]['status'] = 'running';
|
2191 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2192 |
<span>Part'.$format_part.'</span></br>
|
2193 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
2194 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
|
2199 |
} else if ($task['files'][$file['file_name']]['status'] == 'completed')
|
2200 |
{
|
2201 |
$data['files'][$file['file_name']]['status'] = 'completed';
|
2202 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2203 |
<span>Part'.$format_part.'</span></br>
|
2204 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Download</a></span></br>
|
2205 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:100%;height:5px;"></div></div>
|
2211 |
} else if ($task['files'][$file['file_name']]['status'] == 'error')
|
2212 |
{
|
2213 |
$data['files'][$file['file_name']]['status'] = 'error';
|
2214 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2215 |
<span>Part'.$format_part.'</span></br>
|
2216 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2217 |
+
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2218 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2219 |
</div>';
|
2220 |
$data['files'][$file['file_name']]['error']=__($task['files'][$file['file_name']]['error'], 'wpvivid');
|
2226 |
if($data['files'][$file['file_name']]['status']=='error')
|
2227 |
{
|
2228 |
$data['files'][$file['file_name']]['status']='need_download';
|
2229 |
+
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px;">
|
2230 |
<span>Part'.$format_part.'</span></br>
|
2231 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
|
2232 |
+
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2233 |
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2234 |
</div>';
|
2235 |
$data['files'][$file['file_name']]['error']='';
|
2246 |
else{
|
2247 |
$format_part=$file_count;
|
2248 |
}
|
2249 |
+
$data['place_html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:290px; color:#cccccc;">
|
2250 |
<span>Part'.$format_part.'</span></br>
|
2251 |
<span>Download</span></br>
|
2252 |
+
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2253 |
<span>size:</span><span>0</span>
|
2254 |
</div>';
|
2255 |
}
|
2390 |
session_write_close();
|
2391 |
|
2392 |
$size = filesize($path);
|
2393 |
+
if (!headers_sent())
|
2394 |
+
{
|
2395 |
+
header('Content-Description: File Transfer');
|
2396 |
+
header('Content-Type: application/zip');
|
2397 |
+
header('Content-Disposition: attachment; filename="'.basename($path).'"');
|
2398 |
+
header('Cache-Control: must-revalidate');
|
2399 |
+
header('Content-Length: ' . $size);
|
2400 |
+
header('Content-Transfer-Encoding: binary' );
|
2401 |
+
}
|
2402 |
+
|
2403 |
if($size<1024*1024*60)
|
2404 |
{
|
2405 |
ob_end_clean();
|
2670 |
|
2671 |
$remote_options['type']=$_POST['type'];
|
2672 |
$ret=$this->remote_collection->add_remote($remote_options);
|
2673 |
+
|
2674 |
if($ret['result']=='success')
|
2675 |
{
|
2676 |
$html = '';
|
2685 |
$schedule_local_remote='';
|
2686 |
$schedule_local_remote= apply_filters('wpvivid_schedule_local_remote',$schedule_local_remote);
|
2687 |
$ret['local_remote'] = $schedule_local_remote;
|
2688 |
+
$remote_storage = '';
|
2689 |
+
$remote_storage = apply_filters('wpvivid_remote_storage',$remote_storage);
|
2690 |
+
$ret['remote_storage'] = $remote_storage;
|
2691 |
}
|
|
|
2692 |
echo json_encode($ret);
|
2693 |
die();
|
2694 |
}
|
2722 |
$dir = '';
|
2723 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
2724 |
$ret['dir'] = $dir;
|
2725 |
+
$schedule_local_remote='';
|
2726 |
+
$schedule_local_remote= apply_filters('wpvivid_schedule_local_remote',$schedule_local_remote);
|
2727 |
+
$ret['local_remote'] = $schedule_local_remote;
|
2728 |
+
$remote_storage = '';
|
2729 |
+
$remote_storage = apply_filters('wpvivid_remote_storage',$remote_storage);
|
2730 |
+
$ret['remote_storage'] = $remote_storage;
|
2731 |
}
|
2732 |
else
|
2733 |
{
|
2803 |
$dir = '';
|
2804 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
2805 |
$ret['dir'] = $dir;
|
2806 |
+
$schedule_local_remote='';
|
2807 |
+
$schedule_local_remote= apply_filters('wpvivid_schedule_local_remote',$schedule_local_remote);
|
2808 |
+
$ret['local_remote'] = $schedule_local_remote;
|
2809 |
+
$remote_storage = '';
|
2810 |
+
$remote_storage = apply_filters('wpvivid_remote_storage',$remote_storage);
|
2811 |
+
$ret['remote_storage'] = $remote_storage;
|
2812 |
}
|
2813 |
|
2814 |
echo json_encode($ret);
|
2833 |
$dir = '';
|
2834 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
2835 |
$ret['dir'] = $dir;
|
2836 |
+
$schedule_local_remote='';
|
2837 |
+
$schedule_local_remote= apply_filters('wpvivid_schedule_local_remote',$schedule_local_remote);
|
2838 |
+
$ret['local_remote'] = $schedule_local_remote;
|
2839 |
+
$remote_storage = '';
|
2840 |
+
$remote_storage = apply_filters('wpvivid_remote_storage',$remote_storage);
|
2841 |
+
$ret['remote_storage'] = $remote_storage;
|
2842 |
|
2843 |
echo json_encode($ret);
|
2844 |
die();
|
3017 |
$this->ajax_check_security();
|
3018 |
|
3019 |
if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id'])
|
3020 |
+
||!isset($_POST['file_name'])||empty($_POST['file_name'])||!is_string($_POST['file_name']))
|
|
|
|
|
3021 |
{
|
3022 |
die();
|
3023 |
}
|
3024 |
+
|
3025 |
+
set_time_limit(600);
|
3026 |
+
|
3027 |
$backup_id = sanitize_key($_POST['backup_id']);
|
3028 |
$file_name=sanitize_file_name($_POST['file_name']);
|
3029 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3030 |
$file['file_name']=$file_name;
|
3031 |
+
$file['size']=$_POST['size'];
|
3032 |
+
$file['md5']=$_POST['md5'];
|
3033 |
+
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
3034 |
+
if(!$backup)
|
3035 |
+
{
|
3036 |
+
echo json_encode(array('result' => WPVIVID_FAILED ,'error'=>'backup not found'));
|
3037 |
+
die();
|
3038 |
+
}
|
3039 |
+
$local_path=$backup['local']['path'];
|
3040 |
+
$remotes=$backup['remote'];
|
3041 |
+
$remote_option=array_shift($remotes);
|
3042 |
+
|
3043 |
+
if(is_null($remote_option))
|
3044 |
+
{
|
3045 |
+
echo json_encode(array('result' => WPVIVID_FAILED ,'error'=>'Retrieving the cloud storage information failed while downloading backups. Please try again later.'));
|
3046 |
+
die();
|
3047 |
+
}
|
3048 |
+
|
3049 |
+
$downloader=new WPvivid_downloader();
|
3050 |
+
$ret=$downloader->download($file,$local_path,$remote_option);
|
3051 |
+
|
3052 |
echo json_encode($ret);
|
3053 |
die();
|
3054 |
}
|
3068 |
|
3069 |
$restore_data=new WPvivid_restore_data();
|
3070 |
|
3071 |
+
try {
|
3072 |
+
if ($restore_data->has_restore()) {
|
3073 |
+
$status = $restore_data->get_restore_status();
|
3074 |
|
3075 |
+
if ($status === WPVIVID_RESTORE_ERROR) {
|
3076 |
+
$ret['result'] = 'failed';
|
3077 |
+
$ret['error'] = $restore_data->get_restore_error();
|
3078 |
+
echo json_encode($ret);
|
3079 |
+
die();
|
3080 |
+
} else if ($status === WPVIVID_RESTORE_COMPLETED) {
|
3081 |
+
$restore_data->write_log('disable maintenance mode', 'notice');
|
3082 |
+
$this->_disable_maintenance_mode();
|
3083 |
+
echo json_encode(array('result' => 'finished'));
|
3084 |
+
die();
|
3085 |
+
}
|
3086 |
+
} else {
|
3087 |
+
$restore_data->init_restore_data($backup_id);
|
3088 |
+
$restore_data->write_log('init restore data', 'notice');
|
3089 |
+
$this->_enable_maintenance_mode();
|
3090 |
+
$restore_data->write_log('enable maintenance mode', 'notice');
|
3091 |
}
|
3092 |
+
}
|
3093 |
+
catch (Exception $error)
|
3094 |
+
{
|
3095 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
3096 |
+
echo $message;
|
3097 |
+
die();
|
3098 |
+
}
|
3099 |
+
catch (Error $error)
|
3100 |
+
{
|
3101 |
+
$message = 'An error has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
3102 |
+
echo $message;
|
3103 |
+
die();
|
3104 |
}
|
3105 |
|
3106 |
try
|
3257 |
}
|
3258 |
}
|
3259 |
|
3260 |
+
public function download_restore_progress()
|
3261 |
+
{
|
3262 |
+
if(!isset($_POST['file_name']))
|
3263 |
+
{
|
3264 |
+
die();
|
3265 |
+
}
|
3266 |
+
|
3267 |
+
$task=WPvivid_taskmanager::get_download_task_v2($_POST['file_name']);
|
3268 |
+
|
3269 |
+
if($task===false)
|
3270 |
+
{
|
3271 |
+
$ret['result']=WPVIVID_FAILED;
|
3272 |
+
$ret['error']='not found download file';
|
3273 |
+
echo json_encode($ret);
|
3274 |
+
}
|
3275 |
+
else
|
3276 |
+
{
|
3277 |
+
$ret['result']=WPVIVID_SUCCESS;
|
3278 |
+
$ret['status']=$task['status'];
|
3279 |
+
$ret['log']=$task['progress_text'];
|
3280 |
+
$ret['error']=$task['error'];
|
3281 |
+
echo json_encode($ret);
|
3282 |
+
}
|
3283 |
+
die();
|
3284 |
+
}
|
3285 |
+
|
3286 |
public function init_filesystem()
|
3287 |
{
|
3288 |
$credentials = request_filesystem_credentials(wp_nonce_url(admin_url('admin.php')."?page=WPvivid", 'wpvivid-nonce'));
|
3350 |
echo $message;
|
3351 |
}
|
3352 |
|
3353 |
+
public function update_last_backup_task($task)
|
3354 |
{
|
|
|
3355 |
WPvivid_Setting::update_option('wpvivid_last_msg',$task);
|
3356 |
}
|
3357 |
/**
|
3402 |
public function list_tasks()
|
3403 |
{
|
3404 |
$this->ajax_check_security('manage_options');
|
3405 |
+
try
|
|
|
3406 |
{
|
3407 |
+
if (isset($_POST['backup_id']))
|
3408 |
+
{
|
3409 |
+
$backup_id=sanitize_key($_POST['backup_id']);
|
3410 |
+
}
|
3411 |
+
else{
|
3412 |
+
$backup_id=false;
|
3413 |
+
}
|
3414 |
+
echo json_encode($this->_list_tasks($backup_id));
|
3415 |
}
|
3416 |
+
catch (Exception $error)
|
3417 |
+
{
|
3418 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
3419 |
+
error_log($message);
|
3420 |
+
echo json_encode(array('result'=>'failed','error'=>$message));
|
3421 |
+
die();
|
3422 |
}
|
3423 |
+
|
3424 |
die();
|
3425 |
}
|
3426 |
|
3474 |
$descript='';
|
3475 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3476 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
3477 |
+
$total = 'N/A';
|
3478 |
+
$upload = 'N/A';
|
3479 |
+
$speed = 'N/A';
|
3480 |
if($list_tasks[$task['id']]['status']['str']=='ready'){
|
3481 |
$descript=__('Ready to backup. Progress: 0%, running time: 0second.','wpvivid');
|
3482 |
$css_btn_cancel='pointer-events: none; opacity: 0.4;';
|
3484 |
}
|
3485 |
else if($list_tasks[$task['id']]['status']['str']=='running'){
|
3486 |
if($list_tasks[$task['id']]['is_canceled'] == false){
|
3487 |
+
if($list_tasks[$task['id']]['data']['type'] == 'upload'){
|
3488 |
+
$descript = $list_tasks[$task['id']]['data']['descript'];
|
3489 |
+
$find_str = 'Total size: ';
|
3490 |
+
if(stripos($descript, $find_str) != false) {
|
3491 |
+
$pos = stripos($descript, $find_str);
|
3492 |
+
$rest = substr($descript, $pos);
|
3493 |
+
$descript = substr($descript, 0, $pos);
|
3494 |
+
|
3495 |
+
$find_str = 'Uploaded: ';
|
3496 |
+
if(stripos($rest, $find_str) != false) {
|
3497 |
+
$pos = stripos($rest, $find_str);
|
3498 |
+
$total = substr($rest, 0, $pos);
|
3499 |
+
$rest = substr($rest, $pos);
|
3500 |
+
|
3501 |
+
$find_str = 'speed';
|
3502 |
+
if(stripos($rest, $find_str) != false) {
|
3503 |
+
$pos = stripos($rest, $find_str);
|
3504 |
+
$upload = substr($rest, 0, $pos);
|
3505 |
+
$speed = substr($rest, $pos);
|
3506 |
+
|
3507 |
+
$total = str_replace('Total size:', '', $total);
|
3508 |
+
$upload = str_replace('Uploaded:', '', $upload);
|
3509 |
+
$speed = str_replace('speed:', '', $speed);
|
3510 |
+
}
|
3511 |
+
}
|
3512 |
+
}
|
3513 |
+
$descript = $descript.__(' Progress: ', 'wpvivid') . $backup_percent . __(', running time: ', 'wpvivid') . $list_tasks[$task['id']]['data']['running_time'];
|
3514 |
+
}
|
3515 |
+
else {
|
3516 |
+
$descript = $list_tasks[$task['id']]['data']['descript'] . __(' Progress: ', 'wpvivid') . $backup_percent . __(', running time: ', 'wpvivid') . $list_tasks[$task['id']]['data']['running_time'];
|
3517 |
+
}
|
3518 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3519 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
3520 |
}
|
3545 |
$descript='Task '.$task['id'].' completed.';
|
3546 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3547 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
3548 |
+
$task_msg = WPvivid_taskmanager::get_task($task['id']);
|
3549 |
+
$this->update_last_backup_task($task_msg);
|
|
|
3550 |
}
|
3551 |
else if($list_tasks[$task['id']]['status']['str']=='error'){
|
3552 |
$descript='Backup error: '.$list_tasks[$task['id']]['status']['error'];
|
3553 |
$css_btn_cancel='pointer-events: auto; opacity: 1;';
|
3554 |
$css_btn_log='pointer-events: auto; opacity: 1;';
|
3555 |
+
$task_msg = WPvivid_taskmanager::get_task($task['id']);
|
3556 |
+
$this->update_last_backup_task($task_msg);
|
|
|
3557 |
}
|
3558 |
|
3559 |
+
$list_tasks[$task['id']]['progress_html'] = '<div class="action-progress-bar" id="wpvivid_action_progress_bar">
|
3560 |
+
<div class="action-progress-bar-percent" id="wpvivid_action_progress_bar_percent" style="height:24px;width:' . $backup_percent . '"></div>
|
3561 |
+
</div>
|
3562 |
+
<div id="wpvivid_estimate_backup_info" style="float:left; ' . $estimate_backup . '">
|
3563 |
+
<div class="backup-basic-info"><span>' . __('Database Size:', 'wpvivid') . '</span><span id="wpvivid_backup_database_size">' . $db_size . '</span></div>
|
3564 |
+
<div class="backup-basic-info"><span>' . __('File Size:', 'wpvivid') . '</span><span id="wpvivid_backup_file_size">' . $file_size . '</span></div>
|
3565 |
</div>
|
3566 |
+
<div id="wpvivid_estimate_upload_info" style="float: left;">
|
3567 |
+
<div class="backup-basic-info"><span>' . __('Total Size:', 'wpvivid') . '</span><span>' . $total . '</span></div>
|
3568 |
+
<div class="backup-basic-info"><span>' . __('Uploaded:', 'wpvivid') . '</span><span>' . $upload . '</span></div>
|
3569 |
+
<div class="backup-basic-info"><span>' . __('Speed:', 'wpvivid') . '</span><span>' . $speed . '</span></div>
|
3570 |
</div>
|
3571 |
<div style="clear:both;"></div>
|
3572 |
+
<div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_current_doing">' . $descript . '</p></div>
|
3573 |
<div style="clear: both;"></div>
|
3574 |
<div>
|
3575 |
+
<div id="wpvivid_backup_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_backup_cancel_btn" type="submit" value="' . esc_attr('Cancel', 'wpvivid') . '" onclick="wpvivid_cancel_backup();" style="' . $css_btn_cancel . '" /></div>
|
3576 |
+
<div id="wpvivid_backup_log" class="backup-log-btn"><input class="button-primary backup-log-btn" id="wpvivid_backup_log_btn" type="submit" value="' . esc_attr('Log', 'wpvivid') . '" onclick="wpvivid_read_log(\'' . __('wpvivid_view_backup_task_log') . '\');" style="' . $css_btn_log . '" /></div>
|
3577 |
</div>
|
3578 |
<div style="clear: both;"></div>';
|
3579 |
+
}
|
3580 |
+
}
|
3581 |
+
WPvivid_taskmanager::delete_marked_task();
|
3582 |
|
3583 |
+
$ret['backuplist_html'] = false;
|
3584 |
+
$backup_success_count=WPvivid_Setting::get_option('wpvivid_backup_success_count');
|
3585 |
+
if(!empty($backup_success_count)){
|
3586 |
+
$notice_msg = $backup_success_count.' backup tasks have been completed. Please switch to <a href="#" onclick="wpvivid_click_switch_page(\'wrap\', \'wpvivid_tab_log\', true);">Log</a> page to check the details.';
|
3587 |
+
$success_notice_html=__('<div class="notice notice-success is-dismissible inline"><p>'.$notice_msg.'</p>
|
3588 |
+
<button type="button" class="notice-dismiss" onclick="click_dismiss_notice(this);">
|
3589 |
+
<span class="screen-reader-text">Dismiss this notice.</span>
|
3590 |
+
</button>
|
3591 |
+
</div>');
|
3592 |
+
WPvivid_Setting::delete_option('wpvivid_backup_success_count');
|
3593 |
+
$html = '';
|
3594 |
+
$html = apply_filters('wpvivid_add_backup_list', $html);
|
3595 |
+
$ret['backuplist_html'] = $html;
|
3596 |
+
}
|
3597 |
+
else {
|
3598 |
+
$success_notice_html = false;
|
3599 |
+
}
|
3600 |
+
$ret['success_notice_html'] = $success_notice_html;
|
3601 |
+
|
3602 |
+
$backup_error_array=WPvivid_Setting::get_option('wpvivid_backup_error_array');
|
3603 |
+
if(!empty($backup_error_array)){
|
3604 |
+
$error_notice_html = array();
|
3605 |
+
foreach ($backup_error_array as $key => $value){
|
3606 |
+
$notice_msg = 'Backup error: '.$value['error_msg'].', task id: '.$value['task_id'];
|
3607 |
+
$error_notice_html['bu_error']['task_id']=$value['task_id'];
|
3608 |
+
$error_notice_html['bu_error']['error_msg']=__('<div class="notice notice-error inline"><p>'.$notice_msg.', Please switch to <a href="#" onclick="wpvivid_click_switch_page(\'wrap\', \'wpvivid_tab_debug\', true);">Website Info</a> page to send us the debug information. </p></div>');
|
3609 |
}
|
3610 |
+
WPvivid_Setting::delete_option('wpvivid_backup_error_array');
|
3611 |
+
$html = '';
|
3612 |
+
$html = apply_filters('wpvivid_add_backup_list', $html);
|
3613 |
+
$ret['backuplist_html'] = $html;
|
3614 |
+
}
|
3615 |
+
else{
|
3616 |
+
$error_notice_html = false;
|
3617 |
}
|
3618 |
+
$ret['error_notice_html'] = $error_notice_html;
|
3619 |
|
3620 |
$ret['backup']['result']='success';
|
3621 |
$ret['backup']['data']=$list_tasks;
|
3641 |
{
|
3642 |
delete_option('wpvivid_download_cache');
|
3643 |
delete_option('wpvivid_download_task');
|
3644 |
+
WPvivid_taskmanager::delete_out_of_date_finished_task();
|
3645 |
WPvivid_taskmanager::delete_ready_task();
|
3646 |
}
|
3647 |
/**
|
3859 |
{
|
3860 |
$this->ajax_check_security();
|
3861 |
|
3862 |
+
try
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3863 |
{
|
3864 |
+
if(!isset($_POST['options'])||empty($_POST['options'])||!is_string($_POST['options']))
|
3865 |
+
{
|
3866 |
+
die();
|
3867 |
+
}
|
3868 |
+
$options=$_POST['options'];
|
3869 |
+
$options =stripslashes($options);
|
3870 |
+
$options=json_decode($options,true);
|
3871 |
+
if(is_null($options))
|
3872 |
+
{
|
3873 |
+
die();
|
3874 |
+
}
|
3875 |
+
if($options['log']=='0' && $options['backup_cache']=='0' && $options['junk_files']=='0' && $options['old_files']=='0')
|
3876 |
+
{
|
3877 |
+
$ret['result']=WPVIVID_FAILED;
|
3878 |
+
$ret['msg']=__('Choose at least one type of junk files for deleting.', 'wpvivid');
|
3879 |
+
echo json_encode($ret);
|
3880 |
+
die();
|
3881 |
+
}
|
3882 |
+
$delete_files = array();
|
3883 |
+
$delete_folder=array();
|
3884 |
+
if($options['log']=='1')
|
3885 |
{
|
3886 |
+
$log_dir=$this->wpvivid_log->GetSaveLogFolder();
|
3887 |
+
$log_files=array();
|
3888 |
+
$temp=array();
|
3889 |
+
$this -> get_dir_files($log_files,$temp,$log_dir,array('file' => '&wpvivid-&'),array(),array(),0,false);
|
3890 |
+
|
3891 |
+
foreach ($log_files as $file)
|
3892 |
{
|
3893 |
+
$file_name=basename($file);
|
3894 |
+
$id=substr ($file_name,0,21);
|
3895 |
+
if(WPvivid_Backuplist::get_backuplist_by_key($id)===false)
|
3896 |
+
{
|
3897 |
+
$delete_files[]=$file;
|
3898 |
+
}
|
3899 |
}
|
3900 |
}
|
|
|
3901 |
|
3902 |
+
if($options['backup_cache']=='1')
|
3903 |
+
{
|
3904 |
+
$backup_id_list=WPvivid_Backuplist::get_has_remote_backuplist();
|
3905 |
+
$this->delete_local_backup($backup_id_list);
|
3906 |
+
}
|
3907 |
|
3908 |
+
if($options['junk_files']=='1')
|
|
|
|
|
|
|
|
|
3909 |
{
|
3910 |
+
$list=WPvivid_Backuplist::get_backuplist();
|
3911 |
+
$files=array();
|
3912 |
+
foreach ($list as $backup)
|
3913 |
{
|
3914 |
+
if($backup['backup']['ismerge'])
|
3915 |
{
|
3916 |
+
foreach ($backup['backup']['data']['meta']['files'] as $file)
|
3917 |
+
{
|
3918 |
+
$files[]=$file['file_name'];
|
3919 |
+
}
|
3920 |
}
|
3921 |
+
else
|
|
|
|
|
|
|
3922 |
{
|
3923 |
+
foreach ($backup['backup']['data']['type'] as $type)
|
3924 |
{
|
3925 |
+
foreach ($type['files'] as $file)
|
3926 |
+
{
|
3927 |
+
$files[]=$file['file_name'];
|
3928 |
+
}
|
3929 |
}
|
3930 |
}
|
3931 |
}
|
3932 |
+
|
3933 |
+
$dir=WPvivid_Setting::get_backupdir();
|
3934 |
+
$dir=WP_CONTENT_DIR.DIRECTORY_SEPARATOR. $dir;
|
3935 |
+
$path=str_replace('/',DIRECTORY_SEPARATOR,$this->wpvivid_log->GetSaveLogFolder());
|
3936 |
+
if(substr($path, -1) == DIRECTORY_SEPARATOR) {
|
3937 |
+
$path = substr($path, 0, -1);
|
3938 |
+
}
|
3939 |
+
$folder[]= $path;
|
3940 |
+
|
3941 |
+
$this -> get_dir_files($delete_files,$delete_folder,$dir,array('file' => '&wpvivid-&'),$files,$folder,0,false);
|
3942 |
}
|
3943 |
|
3944 |
+
if($options['old_files']=='1')
|
3945 |
+
{
|
3946 |
+
$restore_data=new WPvivid_restore_data();
|
3947 |
+
$restore_data->delete_old_files();
|
|
|
3948 |
}
|
|
|
3949 |
|
3950 |
+
foreach ($delete_files as $file)
|
3951 |
+
{
|
3952 |
+
if(file_exists($file))
|
3953 |
+
@unlink($file);
|
3954 |
+
}
|
3955 |
|
3956 |
+
foreach ($delete_folder as $folder)
|
3957 |
+
{
|
3958 |
+
if(file_exists($folder))
|
3959 |
+
@rmdir($folder);
|
3960 |
+
}
|
3961 |
|
3962 |
+
$ret['result']='success';
|
3963 |
+
$ret['msg']=__('The selected junk flies have been deleted.', 'wpvivid');
|
3964 |
+
$ret['data']=$this->_junk_files_info();
|
3965 |
+
$html = '';
|
3966 |
+
$html = apply_filters('wpvivid_get_log_list', $html);
|
3967 |
+
$ret['html'] = $html['html'];
|
3968 |
+
$ret['log_count'] = $html['log_count'];
|
3969 |
+
echo json_encode($ret);
|
3970 |
}
|
3971 |
+
catch (Exception $error)
|
|
|
3972 |
{
|
3973 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
3974 |
+
error_log($message);
|
3975 |
+
echo json_encode(array('result'=>'failed','error'=>$message));
|
3976 |
+
die();
|
3977 |
}
|
3978 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3979 |
die();
|
3980 |
}
|
3981 |
|
3982 |
+
public function get_dir_files(&$files,&$folder,$path,$except_regex,$exclude_files=array(),$exclude_folder=array(),$exclude_file_size=0,$flag = true)
|
3983 |
{
|
3984 |
$handler=opendir($path);
|
3985 |
while(($filename=readdir($handler))!==false)
|
3987 |
if($filename != "." && $filename != "..")
|
3988 |
{
|
3989 |
$dir=str_replace('/',DIRECTORY_SEPARATOR,$path.DIRECTORY_SEPARATOR.$filename);
|
3990 |
+
|
3991 |
+
|
3992 |
if(in_array($dir,$exclude_folder))
|
3993 |
{
|
3994 |
continue;
|
3995 |
}
|
3996 |
else if(is_dir($path.DIRECTORY_SEPARATOR.$filename))
|
3997 |
{
|
|
|
3998 |
if($except_regex!==false)
|
3999 |
{
|
4000 |
+
if($this -> regex_match($except_regex['directory'],$path.DIRECTORY_SEPARATOR.$filename,$flag)){
|
4001 |
+
continue;
|
|
|
4002 |
}
|
4003 |
+
$folder[]=$path.DIRECTORY_SEPARATOR.$filename;
|
4004 |
+
}else
|
4005 |
{
|
4006 |
$folder[]=$path.DIRECTORY_SEPARATOR.$filename;
|
4007 |
}
|
4008 |
+
$this->get_dir_files($files ,$folder, $path.DIRECTORY_SEPARATOR.$filename,$except_regex,$exclude_folder);
|
4009 |
}else {
|
4010 |
+
if($except_regex===false||!$this -> regex_match($except_regex['file'] ,$path.DIRECTORY_SEPARATOR.$filename,$flag))
|
4011 |
{
|
4012 |
if(in_array($filename,$exclude_files))
|
4013 |
{
|
4027 |
}
|
4028 |
if($handler)
|
4029 |
@closedir($handler);
|
4030 |
+
|
4031 |
+
}
|
4032 |
+
private function regex_match($regex_array,$filename,$flag){
|
4033 |
+
if($flag){
|
4034 |
+
if(empty($regex_array)){
|
4035 |
+
return false;
|
4036 |
+
}
|
4037 |
+
if(is_array($regex_array)){
|
4038 |
+
foreach ($regex_array as $regex)
|
4039 |
+
{
|
4040 |
+
if(preg_match($regex,$filename))
|
4041 |
+
{
|
4042 |
+
return true;
|
4043 |
+
}
|
4044 |
+
}
|
4045 |
+
}else{
|
4046 |
+
if(preg_match($regex_array,$filename))
|
4047 |
+
{
|
4048 |
+
return true;
|
4049 |
+
}
|
4050 |
+
}
|
4051 |
+
return false;
|
4052 |
+
}else{
|
4053 |
+
if(empty($regex_array)){
|
4054 |
+
return true;
|
4055 |
+
}
|
4056 |
+
if(is_array($regex_array)){
|
4057 |
+
foreach ($regex_array as $regex)
|
4058 |
+
{
|
4059 |
+
if(preg_match($regex,$filename))
|
4060 |
+
{
|
4061 |
+
return false;
|
4062 |
+
}
|
4063 |
+
}
|
4064 |
+
}else{
|
4065 |
+
if(preg_match($regex_array,$filename))
|
4066 |
+
{
|
4067 |
+
return false;
|
4068 |
+
}
|
4069 |
+
}
|
4070 |
+
return true;
|
4071 |
+
}
|
4072 |
}
|
4073 |
|
4074 |
+
|
4075 |
public function get_setting()
|
4076 |
{
|
4077 |
$this->ajax_check_security('manage_options');
|
4142 |
$dir = '';
|
4143 |
$dir = apply_filters('wpvivid_get_remote_directory', $dir);
|
4144 |
$ret['dir'] = $dir;
|
4145 |
+
$schedule_local_remote='';
|
4146 |
+
$schedule_local_remote= apply_filters('wpvivid_schedule_local_remote',$schedule_local_remote);
|
4147 |
+
$ret['local_remote'] = $schedule_local_remote;
|
4148 |
+
$remote_storage = '';
|
4149 |
+
$remote_storage = apply_filters('wpvivid_remote_storage',$remote_storage);
|
4150 |
+
$ret['remote_storage'] = $remote_storage;
|
4151 |
echo json_encode($ret);
|
4152 |
die();
|
4153 |
}
|
4204 |
die();
|
4205 |
}
|
4206 |
|
4207 |
+
public function wpvivid_set_general_setting($setting_data, $setting, $options)
|
4208 |
+
{
|
4209 |
$setting['use_temp_file'] = intval($setting['use_temp_file']);
|
4210 |
$setting['use_temp_size'] = intval($setting['use_temp_size']);
|
4211 |
$setting['exclude_file_size'] = intval($setting['exclude_file_size']);
|
4217 |
$setting_data['wpvivid_email_setting']['email_enable'] = $setting['email_enable'];
|
4218 |
|
4219 |
$setting_data['wpvivid_compress_setting']['compress_type'] = $setting['compress_type'];
|
4220 |
+
$setting_data['wpvivid_compress_setting']['max_file_size'] = $setting['max_file_size'] . 'M';
|
4221 |
$setting_data['wpvivid_compress_setting']['no_compress'] = $setting['no_compress'];
|
4222 |
$setting_data['wpvivid_compress_setting']['use_temp_file'] = $setting['use_temp_file'];
|
4223 |
$setting_data['wpvivid_compress_setting']['use_temp_size'] = $setting['use_temp_size'];
|
4240 |
|
4241 |
$ret=array();
|
4242 |
|
4243 |
+
try
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4244 |
{
|
4245 |
+
if(isset($_POST['setting'])&&!empty($_POST['setting']))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4246 |
{
|
4247 |
+
$json_setting = $_POST['setting'];
|
4248 |
+
$json_setting = stripslashes($json_setting);
|
4249 |
+
$setting = json_decode($json_setting, true);
|
4250 |
+
if (is_null($setting)){
|
4251 |
+
die();
|
4252 |
+
}
|
4253 |
+
$ret = $this->check_setting_option($setting);
|
4254 |
+
if($ret['result']!=WPVIVID_SUCCESS)
|
4255 |
+
{
|
4256 |
+
echo json_encode($ret);
|
4257 |
+
die();
|
4258 |
+
}
|
4259 |
+
add_filter('wpvivid_set_general_setting', array('WPvivid', 'wpvivid_set_general_setting'), 10, 3);
|
4260 |
+
$options=WPvivid_Setting::get_setting(true, "");
|
4261 |
+
$setting_data = array();
|
4262 |
+
$setting_data= apply_filters('wpvivid_set_general_setting',$setting_data, $setting, $options);
|
4263 |
+
$ret['setting']=WPvivid_Setting::update_setting($setting_data);
|
4264 |
}
|
4265 |
+
|
4266 |
+
if(isset($_POST['schedule'])&&!empty($_POST['schedule']))
|
|
|
4267 |
{
|
4268 |
+
$json = $_POST['schedule'];
|
4269 |
+
$json = stripslashes($json);
|
4270 |
+
$schedule = json_decode($json, true);
|
4271 |
+
if (is_null($schedule))
|
4272 |
+
{
|
4273 |
+
die();
|
4274 |
+
}
|
4275 |
+
$ret = $this->check_schedule_option($schedule);
|
4276 |
+
if($ret['result']!=WPVIVID_SUCCESS)
|
4277 |
+
{
|
4278 |
+
echo json_encode($ret);
|
4279 |
+
die();
|
4280 |
+
}
|
4281 |
+
//set_schedule_ex
|
4282 |
+
$ret=WPvivid_Schedule::set_schedule_ex($schedule);
|
4283 |
+
if($ret['result']!='success')
|
4284 |
+
{
|
4285 |
+
echo json_encode($ret);
|
4286 |
+
die();
|
4287 |
+
}
|
4288 |
}
|
4289 |
}
|
4290 |
+
catch (Exception $error)
|
4291 |
+
{
|
4292 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
4293 |
+
error_log($message);
|
4294 |
+
echo json_encode(array('result'=>'failed','error'=>$message));
|
4295 |
+
die();
|
4296 |
+
}
|
4297 |
echo json_encode($ret);
|
|
|
4298 |
die();
|
4299 |
}
|
4300 |
|
4430 |
}
|
4431 |
|
4432 |
$json=WPvivid_Setting::export_setting_to_json($setting,$history,$review);
|
4433 |
+
if (!headers_sent())
|
4434 |
+
{
|
4435 |
+
header('Content-Disposition: attachment; filename=wpvivid_setting.json');
|
4436 |
+
//header('Content-type: application/json');
|
4437 |
+
header('Content-Type: application/force-download');
|
4438 |
+
header('Content-Description: File Transfer');
|
4439 |
+
header('Cache-Control: must-revalidate');
|
4440 |
+
header('Content-Transfer-Encoding: binary' );
|
4441 |
+
}
|
4442 |
|
4443 |
echo json_encode($json);
|
4444 |
}
|
4491 |
{
|
4492 |
$subject = 'WPvivid Test Mail';
|
4493 |
$body = 'This is a test mail from WPvivid backup plugin';
|
4494 |
+
$headers = array('Content-Type: text/html; charset=UTF-8');
|
4495 |
if(wp_mail( $send_to, $subject, $body,$headers)===false)
|
4496 |
{
|
4497 |
$ret['result']='failed';
|
4554 |
session_write_close();
|
4555 |
|
4556 |
$size = filesize($path);
|
4557 |
+
if (!headers_sent())
|
4558 |
+
{
|
4559 |
+
header('Content-Description: File Transfer');
|
4560 |
+
header('Content-Type: application/zip');
|
4561 |
+
header('Content-Disposition: attachment; filename="'.basename($path).'"');
|
4562 |
+
header('Cache-Control: must-revalidate');
|
4563 |
+
header('Content-Length: ' . $size);
|
4564 |
+
header('Content-Transfer-Encoding: binary' );
|
4565 |
+
}
|
4566 |
+
|
4567 |
|
4568 |
ob_end_clean();
|
4569 |
readfile( $path );
|
4590 |
|
4591 |
public function wpvivid_get_log_list($html)
|
4592 |
{
|
|
|
4593 |
$loglist=$this->get_log_list_ex();
|
4594 |
$current_num=1;
|
4595 |
$max_log_diaplay=20;
|
4862 |
|
4863 |
if( $ret['data']['pdo_mysql']=='support')
|
4864 |
{
|
4865 |
+
$res = explode(':',DB_HOST);
|
4866 |
+
$db_host = $res[0];
|
4867 |
+
$db_port = empty($res[1])?'':$res[1];
|
4868 |
+
if(!empty($db_port))
|
4869 |
+
$db_host = $db_host.':'.$db_port;
|
4870 |
+
|
4871 |
+
try{
|
4872 |
+
$conn=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
4873 |
+
$sth = $conn->query('SELECT @@SESSION.sql_mode');
|
4874 |
+
$rows = $sth->fetchAll();
|
4875 |
+
foreach ($rows as $row)
|
4876 |
+
{
|
4877 |
+
$ret['mysql_mode']=$row["@@SESSION.sql_mode"];
|
4878 |
+
}
|
4879 |
+
}catch (Exception $e)
|
4880 |
+
{
|
4881 |
+
if(!empty($db_port)){
|
4882 |
+
$db_host = $res[0];
|
4883 |
+
$conn=new PDO('mysql:host=' . $db_host . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD );
|
4884 |
+
$sth = $conn->query('SELECT @@SESSION.sql_mode');
|
4885 |
+
$rows = $sth->fetchAll();
|
4886 |
+
foreach ($rows as $row)
|
4887 |
+
{
|
4888 |
+
$ret['mysql_mode']=$row["@@SESSION.sql_mode"];
|
4889 |
+
}
|
4890 |
+
}
|
4891 |
+
$ret['data']['mysql_mode']= 'The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.';
|
4892 |
}
|
4893 |
}
|
4894 |
else {
|
4956 |
}
|
4957 |
|
4958 |
$remote_pic_html='';
|
4959 |
+
$save_local_pic_y = '/admin/partials/images/storage-local.png';
|
4960 |
+
$save_local_pic_n = '/admin/partials/images/storage-local(gray).png';
|
4961 |
+
$local_title = 'Localhost';
|
4962 |
+
if($value['save_local'] == 1){
|
4963 |
+
$remote_pic_html .= '<img src="' . esc_url(WPVIVID_PLUGIN_URL . $save_local_pic_y) . '" style="vertical-align:middle; " title="' . $local_title . '"/>';
|
4964 |
+
}
|
4965 |
+
else{
|
4966 |
+
$remote_pic_html .= '<img src="' . esc_url(WPVIVID_PLUGIN_URL . $save_local_pic_n) . '" style="vertical-align:middle; " title="' . $local_title . '"/>';
|
4967 |
+
}
|
4968 |
$b_has_remote=false;
|
4969 |
if(is_array($remote)) {
|
4970 |
foreach ($remote as $key1 => $value1) {
|
4986 |
$html .= '<tr>
|
4987 |
<th class="check-column"><input name="check_backup" type="checkbox" id="'.esc_attr($key, 'wpvivid').'" value="'.esc_attr($key, 'wpvivid').'" onclick="wpvivid_click_check_backup(\''.__($key, 'wpvivid').'\');" /></th>
|
4988 |
<td class="tablelistcolumn">
|
4989 |
+
<div style="float:left;padding:0 10px 10px 0;">
|
4990 |
<div class="backuptime"><strong>'.__(date('M d, Y H:i',$value['create_time']), 'wpvivid').'</strong></div>
|
4991 |
<div class="common-table">
|
4992 |
<span title="To lock the backup, the backup can only be deleted manually" id="wpvivid_lock_'.$key.'">
|
4999 |
</div>
|
5000 |
</td>
|
5001 |
<td class="tablelistcolumn">
|
5002 |
+
<div style="float:left;padding:10px 10px 10px 0;">'.$remote_pic_html.'</div>
|
5003 |
</td>
|
5004 |
<td class="tablelistcolumn">
|
5005 |
+
<div id="wpvivid_file_part_'.__($key, 'wpvivid').'" style="float:left;padding:10px 10px 10px 0;">
|
5006 |
<div style="cursor:pointer;" onclick="wpvivid_initialize_download(\''.__($key, 'wpvivid').'\');" title="Prepare to download the backup">
|
5007 |
<img id="wpvivid_download_btn_'.__($key, 'wpvivid').'" src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/download.png').'" style="vertical-align:middle;" />'.__('Download', 'wpvivid').'
|
5008 |
<div class="spinner" id="wpvivid_download_loading_'.__($key, 'wpvivid').'" style="float:right;width:auto;height:auto;padding:10px 180px 10px 0;background-position:0 0;"></div>
|
5050 |
<td>'.__($storage_type, 'wpvivid').'</td>
|
5051 |
<td class="row-title"><label for="tablecell">'.__($value['name'], 'wpvivid').'</label></td>
|
5052 |
<td>
|
5053 |
+
<div style="float: left;"><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Edit.png').'" onclick="click_retrieve_remote_storage(\''.__($key, 'wpvivid').'\',\''.__($value['type'], 'wpvivid').'\',\''.__($value['name'], 'wpvivid').'\'
|
5054 |
+
);" style="vertical-align:middle; cursor:pointer;" title="Edit the remote storage"/></div>
|
5055 |
+
<div><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Delete.png').'" onclick="wpvivid_delete_remote_storage(\''.__($key, 'wpvivid').'\'
|
5056 |
+
);" style="vertical-align:middle; cursor:pointer;" title="Remove the remote storage"/></div>
|
5057 |
</td>
|
5058 |
</tr>';
|
5059 |
}
|
5060 |
return $html;
|
5061 |
}
|
5062 |
|
5063 |
+
public function wpvivid_remote_storage($remote_storage){
|
5064 |
+
$remote_id_array = WPvivid_Setting::get_user_history('remote_selected');
|
5065 |
+
$remote_storage = false;
|
5066 |
+
foreach ($remote_id_array as $value){
|
5067 |
+
$remote_storage = true;
|
5068 |
+
}
|
5069 |
+
return $remote_storage;
|
5070 |
+
}
|
5071 |
+
|
5072 |
public function wpvivid_schedule_add_remote_pic($html){
|
5073 |
$html = '';
|
5074 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
5278 |
}
|
5279 |
die();
|
5280 |
}
|
5281 |
+
|
5282 |
+
public function wpvivid_send_debug_info(){
|
5283 |
+
$this->ajax_check_security();
|
5284 |
+
if(!isset($_POST['user_mail']) || empty($_POST['user_mail']))
|
5285 |
+
{
|
5286 |
+
$ret['result']='failed';
|
5287 |
+
$ret['error']=__('User\'s email address is required.', 'wpvivid');
|
5288 |
+
}
|
5289 |
+
else {
|
5290 |
+
$pattern = '/^[a-z0-9]+([._-][a-z0-9]+)*@([0-9a-z]+\.[a-z]{2,14}(\.[a-z]{2})?)$/i';
|
5291 |
+
if (!preg_match($pattern, $_POST['user_mail'])) {
|
5292 |
+
$ret['result'] = 'failed';
|
5293 |
+
$ret['error'] = __('Please enter a valid email address.', 'wpvivid');
|
5294 |
+
} else {
|
5295 |
+
$this->ajax_check_security();
|
5296 |
+
$ret = WPvivid_mail_report::wpvivid_send_debug_info($_POST['user_mail']);
|
5297 |
+
}
|
5298 |
+
}
|
5299 |
+
echo json_encode($ret);
|
5300 |
+
die();
|
5301 |
+
}
|
5302 |
}
|
includes/customclass/class-wpvivid-amazons3-plus.php
CHANGED
@@ -94,7 +94,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
94 |
<input type="password" option="edit-amazons3" name="secret" placeholder="Amazon S3 secret key" class="regular-text"/>
|
95 |
</div>
|
96 |
<div class="storage-account-form">
|
97 |
-
<input type="text" autocomplete="off" option="amazons3" name="s3Path" placeholder="Amazon S3 path(e.g. test/test)" class="regular-text" onkeyup="value=value.replace(/^\//g, '')" />
|
98 |
</div>
|
99 |
<div class="remote-storage-amazons3-storage-class">
|
100 |
<label>
|
@@ -229,10 +229,11 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
229 |
$job_data[basename($file)]=$file_data;
|
230 |
}
|
231 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,'0','Start uploading',$job_data);
|
|
|
232 |
}
|
233 |
|
234 |
foreach ($files as $file){
|
235 |
-
if(array_key_exists(basename($file),$upload_job['job_data']))
|
236 |
{
|
237 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
238 |
continue;
|
94 |
<input type="password" option="edit-amazons3" name="secret" placeholder="Amazon S3 secret key" class="regular-text"/>
|
95 |
</div>
|
96 |
<div class="storage-account-form">
|
97 |
+
<input type="text" autocomplete="off" option="edit-amazons3" name="s3Path" placeholder="Amazon S3 path(e.g. test/test)" class="regular-text" onkeyup="value=value.replace(/^\//g, '')" />
|
98 |
</div>
|
99 |
<div class="remote-storage-amazons3-storage-class">
|
100 |
<label>
|
229 |
$job_data[basename($file)]=$file_data;
|
230 |
}
|
231 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,'0','Start uploading',$job_data);
|
232 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
233 |
}
|
234 |
|
235 |
foreach ($files as $file){
|
236 |
+
if(is_array($upload_job['job_data']) &&array_key_exists(basename($file),$upload_job['job_data']))
|
237 |
{
|
238 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
239 |
continue;
|
includes/customclass/class-wpvivid-dropbox.php
CHANGED
@@ -93,10 +93,11 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
93 |
$job_data[basename($file)]=$file_data;
|
94 |
}
|
95 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,'0','Start uploading',$job_data);
|
|
|
96 |
}
|
97 |
|
98 |
foreach ($files as $file){
|
99 |
-
if(array_key_exists(basename($file),$upload_job['job_data']))
|
100 |
{
|
101 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
102 |
continue;
|
@@ -125,6 +126,7 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
125 |
$this -> current_file_name = basename($file);
|
126 |
|
127 |
if($this -> current_file_size > $this -> upload_chunk_size){
|
|
|
128 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,'0','Start uploading '.basename($file).'.',$upload_job['job_data']);
|
129 |
$result = $dropbox -> upload_session_start();
|
130 |
if(isset($result['error_summary'])){
|
@@ -133,6 +135,7 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
133 |
$build_id = $result['session_id'];
|
134 |
$result = $this -> large_file_upload($build_id,$file,$dropbox,$callback);
|
135 |
}else{
|
|
|
136 |
$result = $dropbox -> upload($path,$file);
|
137 |
if(isset($result['error_summary'])){
|
138 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,'0','Uploading '.basename($file).' failed.',$upload_job['job_data']);
|
@@ -182,7 +185,7 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
182 |
public function _upload_loop($session_id,$offset,$data,$dropbox){
|
183 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES; $i ++){
|
184 |
$result = $dropbox -> upload_session_append_v2($session_id,$offset,$data);
|
185 |
-
if(isset($result['error_summary'])){
|
186 |
$result = array('result' => WPVIVID_FAILED,'error' => 'Uploading '.$this -> current_file_name.' to Dropbox server failed. '.$result['error_summary']);
|
187 |
}else{
|
188 |
return array('result' => WPVIVID_SUCCESS);
|
93 |
$job_data[basename($file)]=$file_data;
|
94 |
}
|
95 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,'0','Start uploading',$job_data);
|
96 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX);
|
97 |
}
|
98 |
|
99 |
foreach ($files as $file){
|
100 |
+
if(is_array($upload_job['job_data']) &&array_key_exists(basename($file),$upload_job['job_data']))
|
101 |
{
|
102 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
103 |
continue;
|
126 |
$this -> current_file_name = basename($file);
|
127 |
|
128 |
if($this -> current_file_size > $this -> upload_chunk_size){
|
129 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Creating upload session.','notice');
|
130 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,'0','Start uploading '.basename($file).'.',$upload_job['job_data']);
|
131 |
$result = $dropbox -> upload_session_start();
|
132 |
if(isset($result['error_summary'])){
|
135 |
$build_id = $result['session_id'];
|
136 |
$result = $this -> large_file_upload($build_id,$file,$dropbox,$callback);
|
137 |
}else{
|
138 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Uploaded files are less than 2M.','notice');
|
139 |
$result = $dropbox -> upload($path,$file);
|
140 |
if(isset($result['error_summary'])){
|
141 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,'0','Uploading '.basename($file).' failed.',$upload_job['job_data']);
|
185 |
public function _upload_loop($session_id,$offset,$data,$dropbox){
|
186 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES; $i ++){
|
187 |
$result = $dropbox -> upload_session_append_v2($session_id,$offset,$data);
|
188 |
+
if(isset($result['error_summary']) && !strstr($result['error_summary'],'incorrect_offset')){
|
189 |
$result = array('result' => WPVIVID_FAILED,'error' => 'Uploading '.$this -> current_file_name.' to Dropbox server failed. '.$result['error_summary']);
|
190 |
}else{
|
191 |
return array('result' => WPVIVID_SUCCESS);
|
includes/customclass/class-wpvivid-ftpclass.php
CHANGED
@@ -45,7 +45,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
45 |
<input type="text" autocomplete="off" option="ftp" name="name" placeholder="Custom an unique name: e.g. FTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
|
46 |
</div>
|
47 |
<div class="storage-account-form">
|
48 |
-
<input type="text" autocomplete="off" option="ftp" name="
|
49 |
</div>
|
50 |
<div class="storage-account-form">
|
51 |
<input type="text" autocomplete="off" option="ftp" name="username" placeholder="FTP login" class="regular-text" />
|
@@ -54,7 +54,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
54 |
<input type="password" autocomplete="new-password" option="ftp" name="password" placeholder="FTP password" class="regular-text" />
|
55 |
</div>
|
56 |
<div class="storage-account-form">
|
57 |
-
<input type="text" autocomplete="off" option="ftp" name="path" placeholder="Directory
|
58 |
</div>
|
59 |
<div class="remote-storage-set-default-block">
|
60 |
<label>
|
@@ -81,7 +81,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
81 |
<input type="text" option="edit-ftp" name="name" placeholder="Custom an unique name: e.g. FTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
|
82 |
</div>
|
83 |
<div class="storage-account-form">
|
84 |
-
<input type="text" option="edit-ftp" name="
|
85 |
</div>
|
86 |
<div class="storage-account-form">
|
87 |
<input type="text" option="edit-ftp" name="username" placeholder="FTP login" class="regular-text"/>
|
@@ -90,7 +90,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
90 |
<input type="password" option="edit-ftp" name="password" placeholder="FTP password" class="regular-text"/>
|
91 |
</div>
|
92 |
<div class="storage-account-form">
|
93 |
-
<input type="text" option="edit-ftp" name="path" placeholder="Directory
|
94 |
</div>
|
95 |
<div class="remote-storage-ftp-passive-block">
|
96 |
<label>
|
@@ -111,19 +111,20 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
111 |
|
112 |
public function test_connect()
|
113 |
{
|
|
|
114 |
$host = $this->options['host'];
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
$conn = $this -> do_connect($host,$username,$password,$port);
|
121 |
if(is_array($conn) && array_key_exists('result',$conn))
|
122 |
return $conn;
|
123 |
-
|
124 |
return $this->do_chdir($conn,$path);
|
125 |
}
|
126 |
|
|
|
127 |
public function sanitize_options($skip_name='')
|
128 |
{
|
129 |
$ret['result']=WPVIVID_FAILED;
|
@@ -151,20 +152,31 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
151 |
}
|
152 |
}
|
153 |
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
{
|
156 |
$ret['error']="Warning: The FTP server is required.";
|
157 |
return $ret;
|
158 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
if(empty($this->options['host']))
|
163 |
-
{
|
164 |
-
$ret['error']="Warning: The FTP server is required.";
|
165 |
-
return $ret;
|
166 |
}
|
167 |
|
|
|
168 |
if(!isset($this->options['username']))
|
169 |
{
|
170 |
$ret['error']="Warning: The FTP login is required.";
|
@@ -231,18 +243,26 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
231 |
return array('result'=>WPVIVID_FAILED,'error'=>'Login failed. The connection has timed out. Please try again later.');
|
232 |
}
|
233 |
}
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
if (!@ftp_chdir($conn,$path)){
|
241 |
return array('result'=>WPVIVID_FAILED,'error'=>'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
|
242 |
}
|
243 |
-
|
244 |
-
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
public function upload($task_id,$files,$callback = '')
|
248 |
{
|
@@ -269,11 +289,14 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
269 |
$job_data[basename($file)]=$file_data;
|
270 |
}
|
271 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_FTP,'0','Start uploading.',$job_data);
|
|
|
272 |
}
|
|
|
273 |
$conn = $this -> do_connect($host,$username,$password,$port);
|
274 |
if(is_array($conn) && array_key_exists('result',$conn))
|
275 |
return $conn;
|
276 |
ftp_pasv($conn,$passive);
|
|
|
277 |
$str = $this -> do_chdir($conn , $path);
|
278 |
if($str['result'] !== WPVIVID_SUCCESS)
|
279 |
return $str;
|
@@ -282,7 +305,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
282 |
$error = '';
|
283 |
foreach ($files as $key => $file)
|
284 |
{
|
285 |
-
if(
|
286 |
{
|
287 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
288 |
continue;
|
45 |
<input type="text" autocomplete="off" option="ftp" name="name" placeholder="Custom an unique name: e.g. FTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
|
46 |
</div>
|
47 |
<div class="storage-account-form">
|
48 |
+
<input type="text" autocomplete="off" option="ftp" name="server" placeholder="FTP server (server's port 21)" class="regular-text"/>
|
49 |
</div>
|
50 |
<div class="storage-account-form">
|
51 |
<input type="text" autocomplete="off" option="ftp" name="username" placeholder="FTP login" class="regular-text" />
|
54 |
<input type="password" autocomplete="new-password" option="ftp" name="password" placeholder="FTP password" class="regular-text" />
|
55 |
</div>
|
56 |
<div class="storage-account-form">
|
57 |
+
<input type="text" autocomplete="off" option="ftp" name="path" placeholder="User Directory (e.g. /home/username/wpvivid)" class="regular-text"/>
|
58 |
</div>
|
59 |
<div class="remote-storage-set-default-block">
|
60 |
<label>
|
81 |
<input type="text" option="edit-ftp" name="name" placeholder="Custom an unique name: e.g. FTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
|
82 |
</div>
|
83 |
<div class="storage-account-form">
|
84 |
+
<input type="text" option="edit-ftp" name="server" placeholder="FTP server (server's port 21)" class="regular-text"/>
|
85 |
</div>
|
86 |
<div class="storage-account-form">
|
87 |
<input type="text" option="edit-ftp" name="username" placeholder="FTP login" class="regular-text"/>
|
90 |
<input type="password" option="edit-ftp" name="password" placeholder="FTP password" class="regular-text"/>
|
91 |
</div>
|
92 |
<div class="storage-account-form">
|
93 |
+
<input type="text" option="edit-ftp" name="path" placeholder="User Directory (e.g. /home/username/wpvivid)" class="regular-text"/>
|
94 |
</div>
|
95 |
<div class="remote-storage-ftp-passive-block">
|
96 |
<label>
|
111 |
|
112 |
public function test_connect()
|
113 |
{
|
114 |
+
$passive =$this->options['passive'];
|
115 |
$host = $this->options['host'];
|
116 |
+
$username = $this->options['username'];
|
117 |
+
$password = $this->options['password'];
|
118 |
+
$path = $this->options['path'];
|
119 |
+
$port = empty($this->options['port'])?21:$this->options['port'];
|
|
|
120 |
$conn = $this -> do_connect($host,$username,$password,$port);
|
121 |
if(is_array($conn) && array_key_exists('result',$conn))
|
122 |
return $conn;
|
123 |
+
ftp_pasv($conn,$passive);
|
124 |
return $this->do_chdir($conn,$path);
|
125 |
}
|
126 |
|
127 |
+
|
128 |
public function sanitize_options($skip_name='')
|
129 |
{
|
130 |
$ret['result']=WPVIVID_FAILED;
|
152 |
}
|
153 |
}
|
154 |
|
155 |
+
$this->options['server']=sanitize_text_field($this->options['server']);
|
156 |
+
|
157 |
+
// if(empty($this->options['host']))
|
158 |
+
// {
|
159 |
+
// $ret['error']="Warning: The FTP server is required.";
|
160 |
+
// return $ret;
|
161 |
+
// }
|
162 |
+
if(empty($this->options['server']))
|
163 |
{
|
164 |
$ret['error']="Warning: The FTP server is required.";
|
165 |
return $ret;
|
166 |
}
|
167 |
+
$res = explode(':',$this -> options['server']);
|
168 |
+
if(sizeof($res) > 1){
|
169 |
+
$this ->options['host'] = $res[0];
|
170 |
+
if($res[1] != 21){
|
171 |
+
$ret['error']='Currently, only port 21 is supported.';
|
172 |
+
return $ret;
|
173 |
+
}
|
174 |
|
175 |
+
}else{
|
176 |
+
$this -> options['host'] = $res[0];
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
|
179 |
+
|
180 |
if(!isset($this->options['username']))
|
181 |
{
|
182 |
$ret['error']="Warning: The FTP login is required.";
|
243 |
return array('result'=>WPVIVID_FAILED,'error'=>'Login failed. The connection has timed out. Please try again later.');
|
244 |
}
|
245 |
}
|
246 |
+
public function do_chdir($conn,$path){
|
247 |
+
if(!@ftp_chdir($conn,$path))
|
248 |
+
{
|
249 |
+
if ( ! ftp_mkdir( $conn, $path ) ) {
|
250 |
+
return array('result'=>WPVIVID_FAILED,'error'=>'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
|
251 |
+
}
|
252 |
if (!@ftp_chdir($conn,$path)){
|
253 |
return array('result'=>WPVIVID_FAILED,'error'=>'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
|
254 |
}
|
255 |
+
}
|
256 |
+
$temp_file = md5(rand());
|
257 |
+
$temp_path = trailingslashit(WP_CONTENT_DIR).WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.$temp_file;
|
258 |
+
file_put_contents($temp_path,print_r($temp_file,true));
|
259 |
+
if(! ftp_put($conn,trailingslashit($path).$temp_file,$temp_path,FTP_BINARY)){
|
260 |
+
return array('result'=>WPVIVID_FAILED,'error'=>'No privilege to create files in this remote storage directory.');
|
261 |
+
}
|
262 |
+
@unlink($temp_path);
|
263 |
+
@ftp_delete($conn,trailingslashit($path).$temp_file);
|
264 |
+
return array('result'=>WPVIVID_SUCCESS);
|
265 |
+
}
|
266 |
|
267 |
public function upload($task_id,$files,$callback = '')
|
268 |
{
|
289 |
$job_data[basename($file)]=$file_data;
|
290 |
}
|
291 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_FTP,'0','Start uploading.',$job_data);
|
292 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_FTP);
|
293 |
}
|
294 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Connecting to server '.$host,'notice');
|
295 |
$conn = $this -> do_connect($host,$username,$password,$port);
|
296 |
if(is_array($conn) && array_key_exists('result',$conn))
|
297 |
return $conn;
|
298 |
ftp_pasv($conn,$passive);
|
299 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('chdir '.$path,'notice');
|
300 |
$str = $this -> do_chdir($conn , $path);
|
301 |
if($str['result'] !== WPVIVID_SUCCESS)
|
302 |
return $str;
|
305 |
$error = '';
|
306 |
foreach ($files as $key => $file)
|
307 |
{
|
308 |
+
if(is_array($upload_job['job_data']) && array_key_exists(basename($file),$upload_job['job_data']))
|
309 |
{
|
310 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
311 |
continue;
|
includes/customclass/class-wpvivid-google-drive.php
CHANGED
@@ -10,7 +10,7 @@ define('WPVIVID_REMOTE_GOOGLEDRIVE','googledrive');
|
|
10 |
define('WPVIVID_GOOGLEDRIVE_DEFAULT_FOLDER','wpvivid_backup');
|
11 |
define('WPVIVID_GOOGLEDRIVE_SECRETS',WPVIVID_PLUGIN_DIR.'/includes/customclass/client_secrets.json');
|
12 |
define('WPVIVID_GOOGLEDRIVE_UPLOAD_SIZE',1024*1024*2);
|
13 |
-
|
14 |
class Wpvivid_Google_drive extends WPvivid_Remote
|
15 |
{
|
16 |
public $options;
|
@@ -73,7 +73,11 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
73 |
return;
|
74 |
}
|
75 |
}
|
76 |
-
|
|
|
|
|
|
|
|
|
77 |
include_once WPVIVID_PLUGIN_DIR.'/vendor/autoload.php';
|
78 |
$client = new Google_Client();
|
79 |
$client->setAuthConfig(WPVIVID_GOOGLEDRIVE_SECRETS);
|
@@ -394,7 +398,13 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
394 |
{
|
395 |
global $wpvivid_pulgin;
|
396 |
|
|
|
397 |
$client=$this->get_client();
|
|
|
|
|
|
|
|
|
|
|
398 |
if($client===false)
|
399 |
{
|
400 |
return array('result' => WPVIVID_FAILED,'error'=> 'Token refresh failed.');
|
@@ -402,6 +412,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
402 |
|
403 |
$service = new Google_Service_Drive($client);
|
404 |
$path=$this->options['path'];
|
|
|
405 |
$folder_id=$this->get_folder($service,$path);
|
406 |
|
407 |
if($folder_id==false)
|
@@ -420,11 +431,12 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
420 |
$job_data[basename($file)]=$file_data;
|
421 |
}
|
422 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,'0','Start uploading',$job_data);
|
|
|
423 |
}
|
424 |
|
425 |
foreach ($files as $file)
|
426 |
{
|
427 |
-
if(array_key_exists(basename($file),$upload_job['job_data']))
|
428 |
{
|
429 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
430 |
continue;
|
@@ -447,6 +459,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
447 |
public function _upload($task_id, $file,$client,$service,$folder_id, $callback = '')
|
448 |
{
|
449 |
global $wpvivid_pulgin;
|
|
|
450 |
if(!$this->delete_exist_file($folder_id,$file,$service))
|
451 |
{
|
452 |
return array('result' =>WPVIVID_FAILED,'error'=>'Uploading '.$file.' to Google Drive server failed. '.$file.' might be deleted or network doesn\'t work properly . Please verify the file and confirm the network connection and try again later.');
|
@@ -456,6 +469,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
456 |
$this -> current_file_size = filesize($file);
|
457 |
$this -> current_file_name = basename($file);
|
458 |
|
|
|
459 |
$fileMetadata = new Google_Service_Drive_DriveFile(array(
|
460 |
'name' => basename($file),
|
461 |
'parents' => array($folder_id)));
|
@@ -499,7 +513,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
499 |
}
|
500 |
|
501 |
fclose($handle);
|
502 |
-
|
503 |
if ($status != false)
|
504 |
{
|
505 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
@@ -515,6 +529,11 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
515 |
|
516 |
private function get_client()
|
517 |
{
|
|
|
|
|
|
|
|
|
|
|
518 |
include_once WPVIVID_PLUGIN_DIR.'/vendor/autoload.php';
|
519 |
$client = new Google_Client();
|
520 |
$client->setConfig('access_type','offline');
|
@@ -531,16 +550,16 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
531 |
$token=$client->getAccessToken();
|
532 |
$this->options['token']=json_decode(json_encode($token),1);
|
533 |
WPvivid_Setting::update_remote_option($this->options['id'],$this->options);
|
534 |
-
return $client;
|
535 |
}
|
536 |
else
|
537 |
{
|
538 |
-
|
539 |
}
|
540 |
}
|
541 |
else
|
542 |
{
|
543 |
-
|
544 |
}
|
545 |
}
|
546 |
|
@@ -579,6 +598,9 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
579 |
try
|
580 |
{
|
581 |
$client=$this->get_client();
|
|
|
|
|
|
|
582 |
|
583 |
if($client===false)
|
584 |
{
|
@@ -595,10 +617,10 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
595 |
return array('result' => WPVIVID_FAILED,'error'=> 'Unable to create the local file. Please make sure the folder is writable and try again.');
|
596 |
}
|
597 |
|
598 |
-
$response = $service->files->listFiles(
|
599 |
'q' => "name='".$file['file_name']."' and '".$folder_id."' in parents",
|
600 |
'fields' => 'files(id,size,webContentLink)'
|
601 |
-
|
602 |
|
603 |
if(sizeof($response->getFiles())==0)
|
604 |
{
|
@@ -652,7 +674,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
652 |
}
|
653 |
else
|
654 |
{
|
655 |
-
throw new Exception('Failed to obtain any new data at size: '.$offset);
|
656 |
}
|
657 |
|
658 |
if((time() - $this -> last_time) >3)
|
@@ -705,6 +727,9 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
705 |
public function delete_exist_file($folder_id,$file,$service)
|
706 |
{
|
707 |
$client=$this->get_client();
|
|
|
|
|
|
|
708 |
|
709 |
if($client===false)
|
710 |
{
|
@@ -736,6 +761,9 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
736 |
public function cleanup($files)
|
737 |
{
|
738 |
$client=$this->get_client();
|
|
|
|
|
|
|
739 |
|
740 |
if($client===false)
|
741 |
{
|
@@ -798,4 +826,10 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
798 |
}
|
799 |
return $storage_type;
|
800 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
801 |
}
|
10 |
define('WPVIVID_GOOGLEDRIVE_DEFAULT_FOLDER','wpvivid_backup');
|
11 |
define('WPVIVID_GOOGLEDRIVE_SECRETS',WPVIVID_PLUGIN_DIR.'/includes/customclass/client_secrets.json');
|
12 |
define('WPVIVID_GOOGLEDRIVE_UPLOAD_SIZE',1024*1024*2);
|
13 |
+
define('WPVIVID_GOOGLE_NEED_PHP_VERSION','5.5');
|
14 |
class Wpvivid_Google_drive extends WPvivid_Remote
|
15 |
{
|
16 |
public $options;
|
73 |
return;
|
74 |
}
|
75 |
}
|
76 |
+
$res = $this -> compare_php_version();
|
77 |
+
if($res['result'] == WPVIVID_FAILED){
|
78 |
+
_e('<div class="notice notice-warning is-dismissible"><p>'.$res['error'].'</p></div>');
|
79 |
+
return ;
|
80 |
+
}
|
81 |
include_once WPVIVID_PLUGIN_DIR.'/vendor/autoload.php';
|
82 |
$client = new Google_Client();
|
83 |
$client->setAuthConfig(WPVIVID_GOOGLEDRIVE_SECRETS);
|
398 |
{
|
399 |
global $wpvivid_pulgin;
|
400 |
|
401 |
+
|
402 |
$client=$this->get_client();
|
403 |
+
if($client['result'] == WPVIVID_FAILED){
|
404 |
+
return $client;
|
405 |
+
}
|
406 |
+
$client = $client['data'];
|
407 |
+
|
408 |
if($client===false)
|
409 |
{
|
410 |
return array('result' => WPVIVID_FAILED,'error'=> 'Token refresh failed.');
|
412 |
|
413 |
$service = new Google_Service_Drive($client);
|
414 |
$path=$this->options['path'];
|
415 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Check upload folder '.$path,'notice');
|
416 |
$folder_id=$this->get_folder($service,$path);
|
417 |
|
418 |
if($folder_id==false)
|
431 |
$job_data[basename($file)]=$file_data;
|
432 |
}
|
433 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,'0','Start uploading',$job_data);
|
434 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE);
|
435 |
}
|
436 |
|
437 |
foreach ($files as $file)
|
438 |
{
|
439 |
+
if(is_array($upload_job['job_data'])&&array_key_exists(basename($file),$upload_job['job_data']))
|
440 |
{
|
441 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
442 |
continue;
|
459 |
public function _upload($task_id, $file,$client,$service,$folder_id, $callback = '')
|
460 |
{
|
461 |
global $wpvivid_pulgin;
|
462 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Check if the server already has the same name file.','notice');
|
463 |
if(!$this->delete_exist_file($folder_id,$file,$service))
|
464 |
{
|
465 |
return array('result' =>WPVIVID_FAILED,'error'=>'Uploading '.$file.' to Google Drive server failed. '.$file.' might be deleted or network doesn\'t work properly . Please verify the file and confirm the network connection and try again later.');
|
469 |
$this -> current_file_size = filesize($file);
|
470 |
$this -> current_file_name = basename($file);
|
471 |
|
472 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Initiate a resumable upload session.','notice');
|
473 |
$fileMetadata = new Google_Service_Drive_DriveFile(array(
|
474 |
'name' => basename($file),
|
475 |
'parents' => array($folder_id)));
|
513 |
}
|
514 |
|
515 |
fclose($handle);
|
516 |
+
$client->setDefer(false);
|
517 |
if ($status != false)
|
518 |
{
|
519 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
529 |
|
530 |
private function get_client()
|
531 |
{
|
532 |
+
$res = $this -> compare_php_version();
|
533 |
+
if($res['result'] == WPVIVID_FAILED){
|
534 |
+
return $res;
|
535 |
+
}
|
536 |
+
|
537 |
include_once WPVIVID_PLUGIN_DIR.'/vendor/autoload.php';
|
538 |
$client = new Google_Client();
|
539 |
$client->setConfig('access_type','offline');
|
550 |
$token=$client->getAccessToken();
|
551 |
$this->options['token']=json_decode(json_encode($token),1);
|
552 |
WPvivid_Setting::update_remote_option($this->options['id'],$this->options);
|
553 |
+
return array('result' => WPVIVID_SUCCESS,'data' => $client);
|
554 |
}
|
555 |
else
|
556 |
{
|
557 |
+
return array('result' => WPVIVID_SUCCESS,'data' => false);
|
558 |
}
|
559 |
}
|
560 |
else
|
561 |
{
|
562 |
+
return array('result' => WPVIVID_SUCCESS,'data' => $client);
|
563 |
}
|
564 |
}
|
565 |
|
598 |
try
|
599 |
{
|
600 |
$client=$this->get_client();
|
601 |
+
if($client['result'] == WPVIVID_FAILED)
|
602 |
+
return $client;
|
603 |
+
$client = $client['data'];
|
604 |
|
605 |
if($client===false)
|
606 |
{
|
617 |
return array('result' => WPVIVID_FAILED,'error'=> 'Unable to create the local file. Please make sure the folder is writable and try again.');
|
618 |
}
|
619 |
|
620 |
+
$response = $service->files->listFiles(array(
|
621 |
'q' => "name='".$file['file_name']."' and '".$folder_id."' in parents",
|
622 |
'fields' => 'files(id,size,webContentLink)'
|
623 |
+
));
|
624 |
|
625 |
if(sizeof($response->getFiles())==0)
|
626 |
{
|
674 |
}
|
675 |
else
|
676 |
{
|
677 |
+
throw new Exception('Failed to obtain any new data at size: '.$offset.' http code:'.$http_response);
|
678 |
}
|
679 |
|
680 |
if((time() - $this -> last_time) >3)
|
727 |
public function delete_exist_file($folder_id,$file,$service)
|
728 |
{
|
729 |
$client=$this->get_client();
|
730 |
+
if($client['result'] == WPVIVID_FAILED)
|
731 |
+
return false;
|
732 |
+
$client = $client['data'];
|
733 |
|
734 |
if($client===false)
|
735 |
{
|
761 |
public function cleanup($files)
|
762 |
{
|
763 |
$client=$this->get_client();
|
764 |
+
if($client['result'] == WPVIVID_FAILED)
|
765 |
+
return $client;
|
766 |
+
$client = $client['data'];
|
767 |
|
768 |
if($client===false)
|
769 |
{
|
826 |
}
|
827 |
return $storage_type;
|
828 |
}
|
829 |
+
private function compare_php_version(){
|
830 |
+
if(version_compare(WPVIVID_GOOGLE_NEED_PHP_VERSION,phpversion()) > 0){
|
831 |
+
return array('result' => WPVIVID_FAILED,error => 'The required PHP version is higher than '.WPVIVID_GOOGLE_NEED_PHP_VERSION.'. After updating your PHP version, please try again.');
|
832 |
+
}
|
833 |
+
return array('result' => WPVIVID_SUCCESS);
|
834 |
+
}
|
835 |
}
|
includes/customclass/class-wpvivid-one-drive.php
CHANGED
@@ -381,6 +381,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
381 |
|
382 |
if($this->need_refresh())
|
383 |
{
|
|
|
384 |
$ret=$this->refresh_token();
|
385 |
if($ret['result']===WPVIVID_FAILED)
|
386 |
{
|
@@ -389,7 +390,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
389 |
}
|
390 |
|
391 |
$path=$this->options['path'];
|
392 |
-
|
393 |
$ret=$this->check_folder($path);
|
394 |
|
395 |
if($ret['result']===WPVIVID_FAILED)
|
@@ -408,11 +409,12 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
408 |
$job_data[basename($file)]=$file_data;
|
409 |
}
|
410 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,'0','Start uploading',$job_data);
|
|
|
411 |
}
|
412 |
|
413 |
foreach ($files as $file)
|
414 |
{
|
415 |
-
if(array_key_exists(basename($file),$upload_job['job_data']))
|
416 |
{
|
417 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
418 |
continue;
|
@@ -617,7 +619,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
617 |
{
|
618 |
if(isset($response['code'])&&$response['code'] ==404)
|
619 |
{
|
620 |
-
$body=array( 'name' => $folder, 'folder' =>
|
621 |
$body=json_encode($body);
|
622 |
$url='https://graph.microsoft.com/v1.0/me/drive/root/children';
|
623 |
|
@@ -657,27 +659,27 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
657 |
|
658 |
private function _upload($task_id,$local_file,$callback)
|
659 |
{
|
|
|
|
|
660 |
$this -> current_file_size = filesize($local_file);
|
661 |
$this -> current_file_name = basename($local_file);
|
662 |
|
663 |
-
$
|
664 |
|
665 |
-
|
666 |
-
{
|
667 |
-
if($ret['error']!='file not found')
|
668 |
-
return $ret;
|
669 |
-
}
|
670 |
|
671 |
$file_size=filesize($local_file);
|
672 |
|
673 |
//small file
|
674 |
if($file_size<1024*1024*4)
|
675 |
{
|
|
|
676 |
$ret=$this->upload_small_file($local_file,$task_id);
|
677 |
return $ret;
|
678 |
}
|
679 |
else
|
680 |
{
|
|
|
681 |
//big file
|
682 |
$ret=$this->create_upload_session(basename($local_file));
|
683 |
|
@@ -685,7 +687,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
685 |
{
|
686 |
return $ret;
|
687 |
}
|
688 |
-
|
689 |
$ret=$this->upload_resume($ret['session_url'],$local_file,$task_id,$callback);
|
690 |
|
691 |
return $ret;
|
@@ -694,6 +696,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
694 |
|
695 |
private function upload_small_file($file,$task_id)
|
696 |
{
|
|
|
697 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE);
|
698 |
|
699 |
$path=$this->options['path'].'/'.basename($file);
|
@@ -711,6 +714,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
711 |
if(!is_wp_error($response) && ($response['response']['code'] == 200||$response['response']['code'] == 201))
|
712 |
{
|
713 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
|
|
714 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,'0','Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
715 |
return array('result' =>WPVIVID_SUCCESS);
|
716 |
}
|
381 |
|
382 |
if($this->need_refresh())
|
383 |
{
|
384 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('The token expired and will go to the server to refresh the token.','notice');
|
385 |
$ret=$this->refresh_token();
|
386 |
if($ret['result']===WPVIVID_FAILED)
|
387 |
{
|
390 |
}
|
391 |
|
392 |
$path=$this->options['path'];
|
393 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Check upload folder '.$path,'notice');
|
394 |
$ret=$this->check_folder($path);
|
395 |
|
396 |
if($ret['result']===WPVIVID_FAILED)
|
409 |
$job_data[basename($file)]=$file_data;
|
410 |
}
|
411 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,'0','Start uploading',$job_data);
|
412 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE);
|
413 |
}
|
414 |
|
415 |
foreach ($files as $file)
|
416 |
{
|
417 |
+
if(is_array($upload_job['job_data'])&&array_key_exists(basename($file),$upload_job['job_data']))
|
418 |
{
|
419 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
420 |
continue;
|
619 |
{
|
620 |
if(isset($response['code'])&&$response['code'] ==404)
|
621 |
{
|
622 |
+
$body=array( 'name' => $folder, 'folder' => array("childCount" => '0'));
|
623 |
$body=json_encode($body);
|
624 |
$url='https://graph.microsoft.com/v1.0/me/drive/root/children';
|
625 |
|
659 |
|
660 |
private function _upload($task_id,$local_file,$callback)
|
661 |
{
|
662 |
+
global $wpvivid_pulgin;
|
663 |
+
|
664 |
$this -> current_file_size = filesize($local_file);
|
665 |
$this -> current_file_name = basename($local_file);
|
666 |
|
667 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Check if the server already has the same name file.','notice');
|
668 |
|
669 |
+
$this->delete_file_by_name($this->options['path'],basename($local_file));
|
|
|
|
|
|
|
|
|
670 |
|
671 |
$file_size=filesize($local_file);
|
672 |
|
673 |
//small file
|
674 |
if($file_size<1024*1024*4)
|
675 |
{
|
676 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Uploaded files are less than 4M.','notice');
|
677 |
$ret=$this->upload_small_file($local_file,$task_id);
|
678 |
return $ret;
|
679 |
}
|
680 |
else
|
681 |
{
|
682 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Creating upload session.','notice');
|
683 |
//big file
|
684 |
$ret=$this->create_upload_session(basename($local_file));
|
685 |
|
687 |
{
|
688 |
return $ret;
|
689 |
}
|
690 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Ready to start uploading files.','notice');
|
691 |
$ret=$this->upload_resume($ret['session_url'],$local_file,$task_id,$callback);
|
692 |
|
693 |
return $ret;
|
696 |
|
697 |
private function upload_small_file($file,$task_id)
|
698 |
{
|
699 |
+
global $wpvivid_pulgin;
|
700 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE);
|
701 |
|
702 |
$path=$this->options['path'].'/'.basename($file);
|
714 |
if(!is_wp_error($response) && ($response['response']['code'] == 200||$response['response']['code'] == 201))
|
715 |
{
|
716 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
717 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
718 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,'0','Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
719 |
return array('result' =>WPVIVID_SUCCESS);
|
720 |
}
|
includes/customclass/class-wpvivid-s3compat.php
CHANGED
@@ -6,6 +6,7 @@ if(!defined('WPVIVID_REMOTE_S3COMPAT')){
|
|
6 |
define('WPVIVID_REMOTE_S3COMPAT','s3compat');
|
7 |
}
|
8 |
define('WPVIVID_S3COMPAT_DEFAULT_FOLDER','/wpvivid_backup');
|
|
|
9 |
require_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-remote.php';
|
10 |
use Aws\S3\S3Client;
|
11 |
use Aws\S3\Exception\S3Exception;
|
@@ -32,6 +33,10 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
32 |
}
|
33 |
|
34 |
public function getClient(){
|
|
|
|
|
|
|
|
|
35 |
$path_temp = str_replace('s3generic://','',$this->options['s3directory'].$this -> options['path']);
|
36 |
if (preg_match("#^/*([^/]+)/(.*)$#", $path_temp, $bmatches))
|
37 |
{
|
@@ -73,6 +78,10 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
73 |
public function test_connect()
|
74 |
{
|
75 |
$s3compat = $this -> getClient();
|
|
|
|
|
|
|
|
|
76 |
$temp_file = md5(rand());
|
77 |
try{
|
78 |
$result = $s3compat -> putObject(
|
@@ -86,10 +95,10 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
86 |
if(!isset($etag)){
|
87 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, but create test file failed.');
|
88 |
}
|
89 |
-
$result = $s3compat ->deleteObject(
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
if(empty($result)){
|
94 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, and create test file succeed, but delete test file failed.');
|
95 |
}
|
@@ -105,6 +114,10 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
105 |
{
|
106 |
global $wpvivid_pulgin;
|
107 |
$s3compat = $this -> getClient();
|
|
|
|
|
|
|
|
|
108 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
109 |
if(empty($upload_job))
|
110 |
{
|
@@ -116,10 +129,11 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
116 |
$job_data[basename($file)]=$file_data;
|
117 |
}
|
118 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,'0','Start uploading',$job_data);
|
|
|
119 |
}
|
120 |
|
121 |
foreach ($files as $file){
|
122 |
-
if(array_key_exists(basename($file),$upload_job['job_data']))
|
123 |
{
|
124 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
125 |
continue;
|
@@ -148,10 +162,10 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
148 |
|
149 |
try{
|
150 |
if($this->current_file_size > $this -> upload_chunk_size){
|
151 |
-
$result = $s3compat ->createMultipartUpload(
|
152 |
'Bucket' => $this -> bucket,
|
153 |
'Key' => $path,
|
154 |
-
|
155 |
if(!isset($result['UploadId']))
|
156 |
return array('result' => WPVIVID_FAILED, 'error' => 'Creating upload task failed. Please try again.');
|
157 |
|
@@ -219,18 +233,18 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
219 |
}
|
220 |
public function _upload_loop($s3compat,$uploadId,$path,$data,$partNumber,&$parts){
|
221 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES;$i ++){
|
222 |
-
$ret = $s3compat ->uploadPart(
|
223 |
'Bucket' => $this ->bucket,
|
224 |
'Key' => $path,
|
225 |
'UploadId' => $uploadId,
|
226 |
'PartNumber' => $partNumber,
|
227 |
'Body' => $data,
|
228 |
-
|
229 |
if(isset($ret['ETag'])){
|
230 |
-
$parts[] =
|
231 |
'ETag' => $ret['ETag'],
|
232 |
'PartNumber' => $partNumber,
|
233 |
-
|
234 |
return array('result' => WPVIVID_SUCCESS);
|
235 |
}
|
236 |
}
|
@@ -244,6 +258,9 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
244 |
$file_path = trailingslashit($local_path).$this -> current_file_name;
|
245 |
$file_md5 = $file['md5'];
|
246 |
$s3compat = $this -> getClient();
|
|
|
|
|
|
|
247 |
|
248 |
$start_offset = file_exists($file_path)?filesize($file_path):0;
|
249 |
$fh = fopen($file_path, 'a');
|
@@ -285,11 +302,11 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
285 |
public function _download_loop($s3compat,$range,$fh){
|
286 |
try{
|
287 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES;$i ++){
|
288 |
-
$response = $s3compat -> getObject(
|
289 |
'Bucket' => $this -> bucket,
|
290 |
'Key' => $this -> options['path'].$this -> current_file_name,
|
291 |
'Range' => $range
|
292 |
-
|
293 |
if(isset($response['Body']) && fwrite($fh,$response['Body'])) {
|
294 |
return array('result' => WPVIVID_SUCCESS);
|
295 |
}
|
@@ -305,6 +322,10 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
305 |
public function cleanup($files)
|
306 |
{
|
307 |
$s3compat = $this -> getClient(true);
|
|
|
|
|
|
|
|
|
308 |
$keys = array();
|
309 |
foreach ($files as $file){
|
310 |
$keys[] = array('Key' => $this -> options['path'].basename($file));
|
@@ -348,6 +369,9 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
348 |
<div class="storage-account-form">
|
349 |
<input type="text" autocomplete="off" option="s3compat" name="endpoint" placeholder="region.digitaloceanspaces.com" class="regular-text"/>
|
350 |
</div>
|
|
|
|
|
|
|
351 |
<div class="remote-storage-set-default-block">
|
352 |
<label>
|
353 |
<input type="checkbox" option="s3compat" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid'); ?>
|
@@ -356,6 +380,16 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
356 |
<div id="wpvivid_storage_account_notice"></div>
|
357 |
<div class=""><input class="button-primary storage-account-button" option="add-remote" id="storage_account_button" type="button" value="<?php _e( 'Test and Add', 'wpvivid' ); ?>" /></div>
|
358 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
<?php
|
360 |
}
|
361 |
|
@@ -380,8 +414,21 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
380 |
<div class="storage-account-form">
|
381 |
<input type="text" option="edit-s3compat" name="endpoint" placeholder="region.digitaloceanspaces.com" class="regular-text"/>
|
382 |
</div>
|
|
|
|
|
|
|
383 |
<div class=""><input class="button-primary storage-account-button" option="edit-remote" type="button" name="s3compat" value="<?php _e( 'Save Changes', 'wpvivid' ); ?>" /></div>
|
384 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
<?php
|
386 |
}
|
387 |
|
@@ -485,7 +532,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
485 |
public function wpvivid_get_out_of_date_s3compat($out_of_date_remote, $remote)
|
486 |
{
|
487 |
if($remote['type'] == WPVIVID_REMOTE_S3COMPAT){
|
488 |
-
$out_of_date_remote = $remote['
|
489 |
}
|
490 |
return $out_of_date_remote;
|
491 |
}
|
@@ -497,4 +544,10 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
497 |
}
|
498 |
return $storage_type;
|
499 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
}
|
6 |
define('WPVIVID_REMOTE_S3COMPAT','s3compat');
|
7 |
}
|
8 |
define('WPVIVID_S3COMPAT_DEFAULT_FOLDER','/wpvivid_backup');
|
9 |
+
define('WPVIVID_S3COMPAT_NEED_PHP_VERSION','5.3.9');
|
10 |
require_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-remote.php';
|
11 |
use Aws\S3\S3Client;
|
12 |
use Aws\S3\Exception\S3Exception;
|
33 |
}
|
34 |
|
35 |
public function getClient(){
|
36 |
+
$res = $this -> compare_php_version();
|
37 |
+
if($res['result'] == WPVIVID_FAILED)
|
38 |
+
return $res;
|
39 |
+
|
40 |
$path_temp = str_replace('s3generic://','',$this->options['s3directory'].$this -> options['path']);
|
41 |
if (preg_match("#^/*([^/]+)/(.*)$#", $path_temp, $bmatches))
|
42 |
{
|
78 |
public function test_connect()
|
79 |
{
|
80 |
$s3compat = $this -> getClient();
|
81 |
+
if(is_array($s3compat) && $s3compat['result'] == WPVIVID_FAILED){
|
82 |
+
return $s3compat;
|
83 |
+
}
|
84 |
+
|
85 |
$temp_file = md5(rand());
|
86 |
try{
|
87 |
$result = $s3compat -> putObject(
|
95 |
if(!isset($etag)){
|
96 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, but create test file failed.');
|
97 |
}
|
98 |
+
$result = $s3compat ->deleteObject(array(
|
99 |
+
'Bucket' => $this -> bucket,
|
100 |
+
'Key' => $this->options['s3directory'].$this -> options['path'].$temp_file,
|
101 |
+
));
|
102 |
if(empty($result)){
|
103 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, and create test file succeed, but delete test file failed.');
|
104 |
}
|
114 |
{
|
115 |
global $wpvivid_pulgin;
|
116 |
$s3compat = $this -> getClient();
|
117 |
+
if(is_array($s3compat) && $s3compat['result'] == WPVIVID_FAILED){
|
118 |
+
return $s3compat;
|
119 |
+
}
|
120 |
+
|
121 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
122 |
if(empty($upload_job))
|
123 |
{
|
129 |
$job_data[basename($file)]=$file_data;
|
130 |
}
|
131 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,'0','Start uploading',$job_data);
|
132 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
133 |
}
|
134 |
|
135 |
foreach ($files as $file){
|
136 |
+
if(is_array($upload_job['job_data'])&&array_key_exists(basename($file),$upload_job['job_data']))
|
137 |
{
|
138 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
139 |
continue;
|
162 |
|
163 |
try{
|
164 |
if($this->current_file_size > $this -> upload_chunk_size){
|
165 |
+
$result = $s3compat ->createMultipartUpload(array(
|
166 |
'Bucket' => $this -> bucket,
|
167 |
'Key' => $path,
|
168 |
+
));
|
169 |
if(!isset($result['UploadId']))
|
170 |
return array('result' => WPVIVID_FAILED, 'error' => 'Creating upload task failed. Please try again.');
|
171 |
|
233 |
}
|
234 |
public function _upload_loop($s3compat,$uploadId,$path,$data,$partNumber,&$parts){
|
235 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES;$i ++){
|
236 |
+
$ret = $s3compat ->uploadPart(array(
|
237 |
'Bucket' => $this ->bucket,
|
238 |
'Key' => $path,
|
239 |
'UploadId' => $uploadId,
|
240 |
'PartNumber' => $partNumber,
|
241 |
'Body' => $data,
|
242 |
+
));
|
243 |
if(isset($ret['ETag'])){
|
244 |
+
$parts[] = array(
|
245 |
'ETag' => $ret['ETag'],
|
246 |
'PartNumber' => $partNumber,
|
247 |
+
);
|
248 |
return array('result' => WPVIVID_SUCCESS);
|
249 |
}
|
250 |
}
|
258 |
$file_path = trailingslashit($local_path).$this -> current_file_name;
|
259 |
$file_md5 = $file['md5'];
|
260 |
$s3compat = $this -> getClient();
|
261 |
+
if(is_array($s3compat) && $s3compat['result'] == WPVIVID_FAILED){
|
262 |
+
return $s3compat;
|
263 |
+
}
|
264 |
|
265 |
$start_offset = file_exists($file_path)?filesize($file_path):0;
|
266 |
$fh = fopen($file_path, 'a');
|
302 |
public function _download_loop($s3compat,$range,$fh){
|
303 |
try{
|
304 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES;$i ++){
|
305 |
+
$response = $s3compat -> getObject(array(
|
306 |
'Bucket' => $this -> bucket,
|
307 |
'Key' => $this -> options['path'].$this -> current_file_name,
|
308 |
'Range' => $range
|
309 |
+
));
|
310 |
if(isset($response['Body']) && fwrite($fh,$response['Body'])) {
|
311 |
return array('result' => WPVIVID_SUCCESS);
|
312 |
}
|
322 |
public function cleanup($files)
|
323 |
{
|
324 |
$s3compat = $this -> getClient(true);
|
325 |
+
if(is_array($s3compat) && $s3compat['result'] == WPVIVID_FAILED){
|
326 |
+
return $s3compat;
|
327 |
+
}
|
328 |
+
|
329 |
$keys = array();
|
330 |
foreach ($files as $file){
|
331 |
$keys[] = array('Key' => $this -> options['path'].basename($file));
|
369 |
<div class="storage-account-form">
|
370 |
<input type="text" autocomplete="off" option="s3compat" name="endpoint" placeholder="region.digitaloceanspaces.com" class="regular-text"/>
|
371 |
</div>
|
372 |
+
<div style="padding-left: 10px; margin-bottom: -16px;">
|
373 |
+
<p><span>DigitalOcean Spaces storage path:</span><span id="wpvivid_dos_root_path">*<?php _e(WPVIVID_S3COMPAT_DEFAULT_FOLDER); ?></span></p>
|
374 |
+
</div>
|
375 |
<div class="remote-storage-set-default-block">
|
376 |
<label>
|
377 |
<input type="checkbox" option="s3compat" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid'); ?>
|
380 |
<div id="wpvivid_storage_account_notice"></div>
|
381 |
<div class=""><input class="button-primary storage-account-button" option="add-remote" id="storage_account_button" type="button" value="<?php _e( 'Test and Add', 'wpvivid' ); ?>" /></div>
|
382 |
</div>
|
383 |
+
<script>
|
384 |
+
jQuery("input:text[option=s3compat][name=s3directory]").keyup(function(){
|
385 |
+
var value = jQuery(this).val();
|
386 |
+
if(value == ''){
|
387 |
+
value = '*';
|
388 |
+
}
|
389 |
+
value = value + '/wpvivid_backup';
|
390 |
+
jQuery('#wpvivid_dos_root_path').html(value);
|
391 |
+
});
|
392 |
+
</script>
|
393 |
<?php
|
394 |
}
|
395 |
|
414 |
<div class="storage-account-form">
|
415 |
<input type="text" option="edit-s3compat" name="endpoint" placeholder="region.digitaloceanspaces.com" class="regular-text"/>
|
416 |
</div>
|
417 |
+
<div style="padding-left: 10px; margin-bottom: -16px;">
|
418 |
+
<p><span>DigitalOcean Spaces storage path:</span><span id="wpvivid_edit_dos_root_path"><?php _e(WPVIVID_S3COMPAT_DEFAULT_FOLDER); ?></span></p>
|
419 |
+
</div>
|
420 |
<div class=""><input class="button-primary storage-account-button" option="edit-remote" type="button" name="s3compat" value="<?php _e( 'Save Changes', 'wpvivid' ); ?>" /></div>
|
421 |
</div>
|
422 |
+
<script>
|
423 |
+
jQuery("input:text[option=edit-s3compat][name=s3directory]").keyup(function(){
|
424 |
+
var value = jQuery(this).val();
|
425 |
+
if(value == ''){
|
426 |
+
value = '*';
|
427 |
+
}
|
428 |
+
value = value + '/wpvivid_backup';
|
429 |
+
jQuery('#wpvivid_edit_dos_root_path').html(value);
|
430 |
+
});
|
431 |
+
</script>
|
432 |
<?php
|
433 |
}
|
434 |
|
532 |
public function wpvivid_get_out_of_date_s3compat($out_of_date_remote, $remote)
|
533 |
{
|
534 |
if($remote['type'] == WPVIVID_REMOTE_S3COMPAT){
|
535 |
+
$out_of_date_remote = $remote['s3directory'].$remote['path'];
|
536 |
}
|
537 |
return $out_of_date_remote;
|
538 |
}
|
544 |
}
|
545 |
return $storage_type;
|
546 |
}
|
547 |
+
private function compare_php_version(){
|
548 |
+
if(version_compare(WPVIVID_GOOGLE_NEED_PHP_VERSION,phpversion()) > 0){
|
549 |
+
return array('result' => WPVIVID_FAILED,error => 'The required PHP version is higher than '.WPVIVID_S3COMPAT_NEED_PHP_VERSION.'. After updating your PHP version, please try again.');
|
550 |
+
}
|
551 |
+
return array('result' => WPVIVID_SUCCESS);
|
552 |
+
}
|
553 |
}
|
includes/customclass/class-wpvivid-sftpclass.php
CHANGED
@@ -273,7 +273,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
|
|
273 |
return $result;
|
274 |
}
|
275 |
|
276 |
-
|
277 |
{
|
278 |
global $wpvivid_pulgin;
|
279 |
$this -> callback = $callback;
|
@@ -297,22 +297,24 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
|
|
297 |
$job_data[basename($file)]=$file_data;
|
298 |
}
|
299 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,'0','Start uploading',$job_data);
|
|
|
300 |
}
|
301 |
|
|
|
302 |
$conn = $this->do_connect($host,$username,$password,$port);
|
303 |
|
304 |
if(is_array($conn) && $conn['result'] ==WPVIVID_FAILED)
|
305 |
{
|
306 |
return $conn;
|
307 |
}
|
308 |
-
|
309 |
$str = $this->do_chdir($conn,$path);
|
310 |
if($str['result'] == WPVIVID_FAILED)
|
311 |
return $str;
|
312 |
|
313 |
foreach ($files as $key => $file)
|
314 |
{
|
315 |
-
if(array_key_exists(basename($file),$upload_job['job_data']))
|
316 |
{
|
317 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
318 |
continue;
|
273 |
return $result;
|
274 |
}
|
275 |
|
276 |
+
public function upload($task_id,$files,$callback='')
|
277 |
{
|
278 |
global $wpvivid_pulgin;
|
279 |
$this -> callback = $callback;
|
297 |
$job_data[basename($file)]=$file_data;
|
298 |
}
|
299 |
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,'0','Start uploading',$job_data);
|
300 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP);
|
301 |
}
|
302 |
|
303 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('Connecting to server '.$host,'notice');
|
304 |
$conn = $this->do_connect($host,$username,$password,$port);
|
305 |
|
306 |
if(is_array($conn) && $conn['result'] ==WPVIVID_FAILED)
|
307 |
{
|
308 |
return $conn;
|
309 |
}
|
310 |
+
$wpvivid_pulgin->wpvivid_log->WriteLog('chdir '.$path,'notice');
|
311 |
$str = $this->do_chdir($conn,$path);
|
312 |
if($str['result'] == WPVIVID_FAILED)
|
313 |
return $str;
|
314 |
|
315 |
foreach ($files as $key => $file)
|
316 |
{
|
317 |
+
if(is_array($upload_job['job_data']) &&array_key_exists(basename($file),$upload_job['job_data']))
|
318 |
{
|
319 |
if($upload_job['job_data'][basename($file)]['uploaded']==1)
|
320 |
continue;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: backup, cloud backup, automatic backup, restore, database backup, wordpres
|
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.1
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 0.9.
|
8 |
License: GPLv3 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
|
10 |
|
@@ -16,9 +16,9 @@ Automatically back up WordPress to Cloud Storage (Dropbox, Amazon S3, Microsoft
|
|
16 |
== Core Features ==
|
17 |
|
18 |
= 1. Automatic Backup =
|
19 |
-
|
20 |
= 2. One-Click Restore =
|
21 |
-
Restore a backup
|
22 |
= 3. Easy Site Migration =
|
23 |
Coming soon...
|
24 |
|
@@ -30,12 +30,12 @@ Dropbox, Google Drive, Microsoft OneDrive, Amazon S3, DigitalOcean Spaces, SFTP,
|
|
30 |
* Manual Backup
|
31 |
* Filter Large Files
|
32 |
* Large Database Support
|
33 |
-
*
|
34 |
* Backup Limits
|
35 |
* Backup Splitting
|
36 |
-
* No Limit
|
37 |
* Backup to Localhost
|
38 |
-
* Clean
|
39 |
* Schedule Automated Backups
|
40 |
* Customize Backup Content
|
41 |
* Download Backup
|
@@ -45,7 +45,7 @@ Dropbox, Google Drive, Microsoft OneDrive, Amazon S3, DigitalOcean Spaces, SFTP,
|
|
45 |
* WordPress MU Support
|
46 |
|
47 |
== Other Amazing Features ==
|
48 |
-
*
|
49 |
* Lock a backup to keep it safe from auto deletion
|
50 |
* Live progress
|
51 |
* More basic features will be continuously added
|
@@ -58,7 +58,7 @@ Dropbox, Google Drive, Microsoft OneDrive, Amazon S3, DigitalOcean Spaces, SFTP,
|
|
58 |
|
59 |
== Support ==
|
60 |
We offer free support in 3 channels:
|
61 |
-
= Forum Support: = Post questions
|
62 |
= Email Support: = Leave us a message at our [contact page](https://wpvivid.com/contact-us) and we will back to you soon.
|
63 |
= FAQs: = Check out our FAQs section on the page, you can easily find an answer for the most part.
|
64 |
|
@@ -96,21 +96,23 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
96 |
|
97 |
== Frequently Asked Questions ==
|
98 |
= What does Backup WordPress Site by WPvivid do? =
|
99 |
-
It enables you to perform manual and scheduled backups of your WordPress site, back up to cloud storage and restore backups directly from the site
|
100 |
= How many cloud options does it support? Are they free to access? =
|
101 |
-
Dropbox, Google Drive, Amazon S3, Microsoft OneDrive, DigitalOcean Spaces FTP, SFTP
|
102 |
|
103 |
Yes, all the cloud access is free.
|
104 |
-
= Is restore feature free? =
|
105 |
-
Yes, absolutely.
|
106 |
-
=
|
107 |
-
Yes.
|
108 |
= Does the plugin also migrate my site? =
|
109 |
-
|
110 |
= Do you provide support for the free version? Where? =
|
111 |
-
Yes, absolutely.
|
112 |
= Will the plugin work on my host? =
|
113 |
-
|
|
|
|
|
114 |
= What should I do if i get the backup error: An error has occurred. class:Error;msg:Call to undefined function curl_init();code:0;line:129 ? =
|
115 |
You should install cURL extension in your PHP installation and try again.
|
116 |
= What does the error "Error: Backup error: Allowed memory size of xxxxxxxxxx bytes exhausted (tried to allocate xxxxxxxxxx bytes), task id: wpvivid-xxxxxxxxxxxxx." mean? =
|
@@ -121,9 +123,19 @@ Please try to contact your web hosting provider for changing PHP memory limit, o
|
|
121 |
2. Upgrade your web hosting plan.
|
122 |
|
123 |
== Contact us ==
|
124 |
-
Feel free to let us know how we can help using the support forum for the plugin on WordPress.org or our [contact form](https://wpvivid.com/contact-us). You can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
|
125 |
|
126 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
= 0.9.11 =
|
128 |
- Added support for DigitalOcean Spaces.
|
129 |
- Added an HTML email template to backup reports.
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.1
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 0.9.12
|
8 |
License: GPLv3 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
|
10 |
|
16 |
== Core Features ==
|
17 |
|
18 |
= 1. Automatic Backup =
|
19 |
+
Setup and forget, the plugin will do the rest automatically backing up your website.
|
20 |
= 2. One-Click Restore =
|
21 |
+
Restore your WordPress site from a backup with a single click.
|
22 |
= 3. Easy Site Migration =
|
23 |
Coming soon...
|
24 |
|
30 |
* Manual Backup
|
31 |
* Filter Large Files
|
32 |
* Large Database Support
|
33 |
+
* Optimized for any host
|
34 |
* Backup Limits
|
35 |
* Backup Splitting
|
36 |
+
* No Limit of Backup Size
|
37 |
* Backup to Localhost
|
38 |
+
* Clean Temp Files
|
39 |
* Schedule Automated Backups
|
40 |
* Customize Backup Content
|
41 |
* Download Backup
|
45 |
* WordPress MU Support
|
46 |
|
47 |
== Other Amazing Features ==
|
48 |
+
* Rename local backup directory
|
49 |
* Lock a backup to keep it safe from auto deletion
|
50 |
* Live progress
|
51 |
* More basic features will be continuously added
|
58 |
|
59 |
== Support ==
|
60 |
We offer free support in 3 channels:
|
61 |
+
= Forum Support: = Post questions and get faster answers from the plugin [support forum](https://wordpress.org/support/plugin/wpvivid-backuprestore/) on WordPress.org.
|
62 |
= Email Support: = Leave us a message at our [contact page](https://wpvivid.com/contact-us) and we will back to you soon.
|
63 |
= FAQs: = Check out our FAQs section on the page, you can easily find an answer for the most part.
|
64 |
|
96 |
|
97 |
== Frequently Asked Questions ==
|
98 |
= What does Backup WordPress Site by WPvivid do? =
|
99 |
+
It enables you to perform manual and scheduled backups of your WordPress site, back up to cloud storage and restore backups directly from the site’s admin dashboard.
|
100 |
= How many cloud options does it support? Are they free to access? =
|
101 |
+
Out of the box we support Dropbox, Google Drive, Amazon S3, Microsoft OneDrive, DigitalOcean Spaces, we also support FTP, SFTP methods which you can use on any other remote storage provider supporting these methods. We are working hard to add more soon.
|
102 |
|
103 |
Yes, all the cloud access is free.
|
104 |
+
= Is the restore feature free? =
|
105 |
+
Yes, absolutely. With no limits, no strings attached.
|
106 |
+
= Will there be updates, will they be free and how can I update to the latest version? =
|
107 |
+
Yes, we are dedicated to creating a secure and robust solution and will regularly update the plugin. These will be available totally free and can be easily applied through your WP admin area once they are available.
|
108 |
= Does the plugin also migrate my site? =
|
109 |
+
Unfortunately NO. But we are tirelessly working to add this feature soon. You will be notified when it is released.
|
110 |
= Do you provide support for the free version? Where? =
|
111 |
+
Yes, absolutely. Whenever you need it, help can be found from the plugin [support forum](https://wordpress.org/support/plugin/wpvivid-backuprestore/) on WordPress.org, by [email](https://wpvivid.com/contact-us), on [Twitter](https://twitter.com/WPvividcom).
|
112 |
= Will the plugin work on my host? =
|
113 |
+
If your website is running on WordPress then yes it will.
|
114 |
+
|
115 |
+
The plugin has been extensively tested on the shared and dedicated hosting plans from the leading website hosting providers like Godaddy, Siteground, and many others.
|
116 |
= What should I do if i get the backup error: An error has occurred. class:Error;msg:Call to undefined function curl_init();code:0;line:129 ? =
|
117 |
You should install cURL extension in your PHP installation and try again.
|
118 |
= What does the error "Error: Backup error: Allowed memory size of xxxxxxxxxx bytes exhausted (tried to allocate xxxxxxxxxx bytes), task id: wpvivid-xxxxxxxxxxxxx." mean? =
|
123 |
2. Upgrade your web hosting plan.
|
124 |
|
125 |
== Contact us ==
|
126 |
+
Feel free to let us know how we can help using the [support forum](https://wordpress.org/support/plugin/wpvivid-backuprestore) for the plugin on WordPress.org or our [contact form](https://wpvivid.com/contact-us). You can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
|
127 |
|
128 |
== Changelog ==
|
129 |
+
= 0.9.12 =
|
130 |
+
- Added an 'Send Debug Information to Us' button in Website Info page.
|
131 |
+
- Improved the compatibility with PHP v5.3 to v5.5.
|
132 |
+
- Fixed the compatibility issue with MainWP plugin.
|
133 |
+
- Fixed: Could not correctly calculate files size when backing up.
|
134 |
+
- Fixed: Could not back up to SFTP server sometimes.
|
135 |
+
- Fixed: Database backup failure because of insufficient privileges.
|
136 |
+
- Enriched backup logs with more details.
|
137 |
+
- Refined some descriptions on user interface.
|
138 |
+
- Optimized code of the plugin.
|
139 |
= 0.9.11 =
|
140 |
- Added support for DigitalOcean Spaces.
|
141 |
- Added an HTML email template to backup reports.
|
vendor/composer/autoload_files.php
CHANGED
@@ -5,11 +5,23 @@
|
|
5 |
$vendorDir = dirname(dirname(__FILE__));
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
$vendorDir = dirname(dirname(__FILE__));
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
+
if (PHP_VERSION_ID < 50500)
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
|
12 |
+
'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
|
13 |
+
'3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
|
14 |
+
);
|
15 |
+
}
|
16 |
+
else
|
17 |
+
{
|
18 |
+
return array(
|
19 |
+
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
|
20 |
+
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
|
21 |
+
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
|
22 |
+
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
|
23 |
+
'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
|
24 |
+
'3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
vendor/google/apiclient-services/README.md
CHANGED
@@ -3,25 +3,18 @@ Google PHP API Client Services
|
|
3 |
|
4 |
## Requirements
|
5 |
|
6 |
-
[Google API PHP Client](https://github.com/
|
7 |
|
8 |
## Usage in v2 of Google API PHP Client
|
9 |
|
10 |
-
This library
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
If you'd like to always be up-to-date with the latest release, rather than
|
16 |
-
wait for monthly tagged releases, request the `dev-master` version in composer:
|
17 |
-
|
18 |
-
```sh
|
19 |
-
composer require google/apiclient-services:dev-master
|
20 |
-
```
|
21 |
|
22 |
## Usage in v1
|
23 |
|
24 |
-
If you are currently using the [`v1-master`](https://github.com/
|
25 |
branch of the client library, but want to use the latest API services, you can
|
26 |
do so by requiring this library directly into your project via the same composer command:
|
27 |
|
3 |
|
4 |
## Requirements
|
5 |
|
6 |
+
[Google API PHP Client](https://github.com/googleapis/google-api-php-client/releases)
|
7 |
|
8 |
## Usage in v2 of Google API PHP Client
|
9 |
|
10 |
+
This library is automatically updated daily with new API changes, and tagged weekly.
|
11 |
+
It is installed as part of the
|
12 |
+
[Google API PHP Client](https://github.com/googleapis/google-api-php-client/releases)
|
13 |
+
library via Composer, which will pull down the most recent tag.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
## Usage in v1
|
16 |
|
17 |
+
If you are currently using the [`v1-master`](https://github.com/googleapis/google-api-php-client/tree/v1-master)
|
18 |
branch of the client library, but want to use the latest API services, you can
|
19 |
do so by requiring this library directly into your project via the same composer command:
|
20 |
|
vendor/google/apiclient-services/src/Google/Service/Drive.php
CHANGED
@@ -31,7 +31,7 @@
|
|
31 |
*/
|
32 |
class Google_Service_Drive extends Google_Service
|
33 |
{
|
34 |
-
/**
|
35 |
const DRIVE =
|
36 |
"https://www.googleapis.com/auth/drive";
|
37 |
/** View and manage its own configuration data in your Google Drive. */
|
@@ -49,7 +49,7 @@ class Google_Service_Drive extends Google_Service
|
|
49 |
/** View the photos, videos and albums in your Google Photos. */
|
50 |
const DRIVE_PHOTOS_READONLY =
|
51 |
"https://www.googleapis.com/auth/drive.photos.readonly";
|
52 |
-
/**
|
53 |
const DRIVE_READONLY =
|
54 |
"https://www.googleapis.com/auth/drive.readonly";
|
55 |
/** Modify your Google Apps Script scripts' behavior. */
|
@@ -562,6 +562,10 @@ class Google_Service_Drive extends Google_Service
|
|
562 |
'location' => 'query',
|
563 |
'type' => 'boolean',
|
564 |
),
|
|
|
|
|
|
|
|
|
565 |
),
|
566 |
),'delete' => array(
|
567 |
'path' => 'files/{fileId}/permissions/{permissionId}',
|
@@ -581,6 +585,10 @@ class Google_Service_Drive extends Google_Service
|
|
581 |
'location' => 'query',
|
582 |
'type' => 'boolean',
|
583 |
),
|
|
|
|
|
|
|
|
|
584 |
),
|
585 |
),'get' => array(
|
586 |
'path' => 'files/{fileId}/permissions/{permissionId}',
|
@@ -600,6 +608,10 @@ class Google_Service_Drive extends Google_Service
|
|
600 |
'location' => 'query',
|
601 |
'type' => 'boolean',
|
602 |
),
|
|
|
|
|
|
|
|
|
603 |
),
|
604 |
),'list' => array(
|
605 |
'path' => 'files/{fileId}/permissions',
|
@@ -622,6 +634,10 @@ class Google_Service_Drive extends Google_Service
|
|
622 |
'location' => 'query',
|
623 |
'type' => 'boolean',
|
624 |
),
|
|
|
|
|
|
|
|
|
625 |
),
|
626 |
),'update' => array(
|
627 |
'path' => 'files/{fileId}/permissions/{permissionId}',
|
@@ -649,6 +665,10 @@ class Google_Service_Drive extends Google_Service
|
|
649 |
'location' => 'query',
|
650 |
'type' => 'boolean',
|
651 |
),
|
|
|
|
|
|
|
|
|
652 |
),
|
653 |
),
|
654 |
)
|
@@ -882,6 +902,10 @@ class Google_Service_Drive extends Google_Service
|
|
882 |
'type' => 'string',
|
883 |
'required' => true,
|
884 |
),
|
|
|
|
|
|
|
|
|
885 |
),
|
886 |
),'list' => array(
|
887 |
'path' => 'teamdrives',
|
@@ -895,6 +919,14 @@ class Google_Service_Drive extends Google_Service
|
|
895 |
'location' => 'query',
|
896 |
'type' => 'string',
|
897 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
898 |
),
|
899 |
),'update' => array(
|
900 |
'path' => 'teamdrives/{teamDriveId}',
|
@@ -905,6 +937,10 @@ class Google_Service_Drive extends Google_Service
|
|
905 |
'type' => 'string',
|
906 |
'required' => true,
|
907 |
),
|
|
|
|
|
|
|
|
|
908 |
),
|
909 |
),
|
910 |
)
|
31 |
*/
|
32 |
class Google_Service_Drive extends Google_Service
|
33 |
{
|
34 |
+
/** See, edit, create, and delete all of your Google Drive files. */
|
35 |
const DRIVE =
|
36 |
"https://www.googleapis.com/auth/drive";
|
37 |
/** View and manage its own configuration data in your Google Drive. */
|
49 |
/** View the photos, videos and albums in your Google Photos. */
|
50 |
const DRIVE_PHOTOS_READONLY =
|
51 |
"https://www.googleapis.com/auth/drive.photos.readonly";
|
52 |
+
/** See and download all your Google Drive files. */
|
53 |
const DRIVE_READONLY =
|
54 |
"https://www.googleapis.com/auth/drive.readonly";
|
55 |
/** Modify your Google Apps Script scripts' behavior. */
|
562 |
'location' => 'query',
|
563 |
'type' => 'boolean',
|
564 |
),
|
565 |
+
'useDomainAdminAccess' => array(
|
566 |
+
'location' => 'query',
|
567 |
+
'type' => 'boolean',
|
568 |
+
),
|
569 |
),
|
570 |
),'delete' => array(
|
571 |
'path' => 'files/{fileId}/permissions/{permissionId}',
|
585 |
'location' => 'query',
|
586 |
'type' => 'boolean',
|
587 |
),
|
588 |
+
'useDomainAdminAccess' => array(
|
589 |
+
'location' => 'query',
|
590 |
+
'type' => 'boolean',
|
591 |
+
),
|
592 |
),
|
593 |
),'get' => array(
|
594 |
'path' => 'files/{fileId}/permissions/{permissionId}',
|
608 |
'location' => 'query',
|
609 |
'type' => 'boolean',
|
610 |
),
|
611 |
+
'useDomainAdminAccess' => array(
|
612 |
+
'location' => 'query',
|
613 |
+
'type' => 'boolean',
|
614 |
+
),
|
615 |
),
|
616 |
),'list' => array(
|
617 |
'path' => 'files/{fileId}/permissions',
|
634 |
'location' => 'query',
|
635 |
'type' => 'boolean',
|
636 |
),
|
637 |
+
'useDomainAdminAccess' => array(
|
638 |
+
'location' => 'query',
|
639 |
+
'type' => 'boolean',
|
640 |
+
),
|
641 |
),
|
642 |
),'update' => array(
|
643 |
'path' => 'files/{fileId}/permissions/{permissionId}',
|
665 |
'location' => 'query',
|
666 |
'type' => 'boolean',
|
667 |
),
|
668 |
+
'useDomainAdminAccess' => array(
|
669 |
+
'location' => 'query',
|
670 |
+
'type' => 'boolean',
|
671 |
+
),
|
672 |
),
|
673 |
),
|
674 |
)
|
902 |
'type' => 'string',
|
903 |
'required' => true,
|
904 |
),
|
905 |
+
'useDomainAdminAccess' => array(
|
906 |
+
'location' => 'query',
|
907 |
+
'type' => 'boolean',
|
908 |
+
),
|
909 |
),
|
910 |
),'list' => array(
|
911 |
'path' => 'teamdrives',
|
919 |
'location' => 'query',
|
920 |
'type' => 'string',
|
921 |
),
|
922 |
+
'q' => array(
|
923 |
+
'location' => 'query',
|
924 |
+
'type' => 'string',
|
925 |
+
),
|
926 |
+
'useDomainAdminAccess' => array(
|
927 |
+
'location' => 'query',
|
928 |
+
'type' => 'boolean',
|
929 |
+
),
|
930 |
),
|
931 |
),'update' => array(
|
932 |
'path' => 'teamdrives/{teamDriveId}',
|
937 |
'type' => 'string',
|
938 |
'required' => true,
|
939 |
),
|
940 |
+
'useDomainAdminAccess' => array(
|
941 |
+
'location' => 'query',
|
942 |
+
'type' => 'boolean',
|
943 |
+
),
|
944 |
),
|
945 |
),
|
946 |
)
|
vendor/google/apiclient-services/src/Google/Service/Drive/About.php
CHANGED
@@ -19,6 +19,7 @@ class Google_Service_Drive_About extends Google_Collection
|
|
19 |
{
|
20 |
protected $collection_key = 'teamDriveThemes';
|
21 |
public $appInstalled;
|
|
|
22 |
public $exportFormats;
|
23 |
public $folderColorPalette;
|
24 |
public $importFormats;
|
@@ -40,6 +41,14 @@ class Google_Service_Drive_About extends Google_Collection
|
|
40 |
{
|
41 |
return $this->appInstalled;
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
public function setExportFormats($exportFormats)
|
44 |
{
|
45 |
$this->exportFormats = $exportFormats;
|
19 |
{
|
20 |
protected $collection_key = 'teamDriveThemes';
|
21 |
public $appInstalled;
|
22 |
+
public $canCreateTeamDrives;
|
23 |
public $exportFormats;
|
24 |
public $folderColorPalette;
|
25 |
public $importFormats;
|
41 |
{
|
42 |
return $this->appInstalled;
|
43 |
}
|
44 |
+
public function setCanCreateTeamDrives($canCreateTeamDrives)
|
45 |
+
{
|
46 |
+
$this->canCreateTeamDrives = $canCreateTeamDrives;
|
47 |
+
}
|
48 |
+
public function getCanCreateTeamDrives()
|
49 |
+
{
|
50 |
+
return $this->canCreateTeamDrives;
|
51 |
+
}
|
52 |
public function setExportFormats($exportFormats)
|
53 |
{
|
54 |
$this->exportFormats = $exportFormats;
|
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFile.php
CHANGED
@@ -23,9 +23,11 @@ class Google_Service_Drive_DriveFile extends Google_Collection
|
|
23 |
protected $capabilitiesDataType = '';
|
24 |
protected $contentHintsType = 'Google_Service_Drive_DriveFileContentHints';
|
25 |
protected $contentHintsDataType = '';
|
|
|
26 |
public $createdTime;
|
27 |
public $description;
|
28 |
public $explicitlyTrashed;
|
|
|
29 |
public $fileExtension;
|
30 |
public $folderColorRgb;
|
31 |
public $fullFileExtension;
|
@@ -51,6 +53,7 @@ class Google_Service_Drive_DriveFile extends Google_Collection
|
|
51 |
protected $ownersType = 'Google_Service_Drive_User';
|
52 |
protected $ownersDataType = 'array';
|
53 |
public $parents;
|
|
|
54 |
protected $permissionsType = 'Google_Service_Drive_Permission';
|
55 |
protected $permissionsDataType = 'array';
|
56 |
public $properties;
|
@@ -115,6 +118,14 @@ class Google_Service_Drive_DriveFile extends Google_Collection
|
|
115 |
{
|
116 |
return $this->contentHints;
|
117 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
public function setCreatedTime($createdTime)
|
119 |
{
|
120 |
$this->createdTime = $createdTime;
|
@@ -139,6 +150,14 @@ class Google_Service_Drive_DriveFile extends Google_Collection
|
|
139 |
{
|
140 |
return $this->explicitlyTrashed;
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
public function setFileExtension($fileExtension)
|
143 |
{
|
144 |
$this->fileExtension = $fileExtension;
|
@@ -333,6 +352,14 @@ class Google_Service_Drive_DriveFile extends Google_Collection
|
|
333 |
{
|
334 |
return $this->parents;
|
335 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
/**
|
337 |
* @param Google_Service_Drive_Permission
|
338 |
*/
|
23 |
protected $capabilitiesDataType = '';
|
24 |
protected $contentHintsType = 'Google_Service_Drive_DriveFileContentHints';
|
25 |
protected $contentHintsDataType = '';
|
26 |
+
public $copyRequiresWriterPermission;
|
27 |
public $createdTime;
|
28 |
public $description;
|
29 |
public $explicitlyTrashed;
|
30 |
+
public $exportLinks;
|
31 |
public $fileExtension;
|
32 |
public $folderColorRgb;
|
33 |
public $fullFileExtension;
|
53 |
protected $ownersType = 'Google_Service_Drive_User';
|
54 |
protected $ownersDataType = 'array';
|
55 |
public $parents;
|
56 |
+
public $permissionIds;
|
57 |
protected $permissionsType = 'Google_Service_Drive_Permission';
|
58 |
protected $permissionsDataType = 'array';
|
59 |
public $properties;
|
118 |
{
|
119 |
return $this->contentHints;
|
120 |
}
|
121 |
+
public function setCopyRequiresWriterPermission($copyRequiresWriterPermission)
|
122 |
+
{
|
123 |
+
$this->copyRequiresWriterPermission = $copyRequiresWriterPermission;
|
124 |
+
}
|
125 |
+
public function getCopyRequiresWriterPermission()
|
126 |
+
{
|
127 |
+
return $this->copyRequiresWriterPermission;
|
128 |
+
}
|
129 |
public function setCreatedTime($createdTime)
|
130 |
{
|
131 |
$this->createdTime = $createdTime;
|
150 |
{
|
151 |
return $this->explicitlyTrashed;
|
152 |
}
|
153 |
+
public function setExportLinks($exportLinks)
|
154 |
+
{
|
155 |
+
$this->exportLinks = $exportLinks;
|
156 |
+
}
|
157 |
+
public function getExportLinks()
|
158 |
+
{
|
159 |
+
return $this->exportLinks;
|
160 |
+
}
|
161 |
public function setFileExtension($fileExtension)
|
162 |
{
|
163 |
$this->fileExtension = $fileExtension;
|
352 |
{
|
353 |
return $this->parents;
|
354 |
}
|
355 |
+
public function setPermissionIds($permissionIds)
|
356 |
+
{
|
357 |
+
$this->permissionIds = $permissionIds;
|
358 |
+
}
|
359 |
+
public function getPermissionIds()
|
360 |
+
{
|
361 |
+
return $this->permissionIds;
|
362 |
+
}
|
363 |
/**
|
364 |
* @param Google_Service_Drive_Permission
|
365 |
*/
|
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileCapabilities.php
CHANGED
@@ -18,14 +18,20 @@
|
|
18 |
class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
19 |
{
|
20 |
public $canAddChildren;
|
|
|
21 |
public $canChangeViewersCanCopyContent;
|
22 |
public $canComment;
|
23 |
public $canCopy;
|
24 |
public $canDelete;
|
|
|
25 |
public $canDownload;
|
26 |
public $canEdit;
|
27 |
public $canListChildren;
|
|
|
|
|
28 |
public $canMoveItemIntoTeamDrive;
|
|
|
|
|
29 |
public $canMoveTeamDriveItem;
|
30 |
public $canReadRevisions;
|
31 |
public $canReadTeamDrive;
|
@@ -33,6 +39,7 @@ class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
|
33 |
public $canRename;
|
34 |
public $canShare;
|
35 |
public $canTrash;
|
|
|
36 |
public $canUntrash;
|
37 |
|
38 |
public function setCanAddChildren($canAddChildren)
|
@@ -43,6 +50,14 @@ class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
|
43 |
{
|
44 |
return $this->canAddChildren;
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
public function setCanChangeViewersCanCopyContent($canChangeViewersCanCopyContent)
|
47 |
{
|
48 |
$this->canChangeViewersCanCopyContent = $canChangeViewersCanCopyContent;
|
@@ -75,6 +90,14 @@ class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
|
75 |
{
|
76 |
return $this->canDelete;
|
77 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
public function setCanDownload($canDownload)
|
79 |
{
|
80 |
$this->canDownload = $canDownload;
|
@@ -99,6 +122,22 @@ class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
|
99 |
{
|
100 |
return $this->canListChildren;
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
public function setCanMoveItemIntoTeamDrive($canMoveItemIntoTeamDrive)
|
103 |
{
|
104 |
$this->canMoveItemIntoTeamDrive = $canMoveItemIntoTeamDrive;
|
@@ -107,6 +146,22 @@ class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
|
107 |
{
|
108 |
return $this->canMoveItemIntoTeamDrive;
|
109 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
public function setCanMoveTeamDriveItem($canMoveTeamDriveItem)
|
111 |
{
|
112 |
$this->canMoveTeamDriveItem = $canMoveTeamDriveItem;
|
@@ -163,6 +218,14 @@ class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
|
163 |
{
|
164 |
return $this->canTrash;
|
165 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
public function setCanUntrash($canUntrash)
|
167 |
{
|
168 |
$this->canUntrash = $canUntrash;
|
18 |
class Google_Service_Drive_DriveFileCapabilities extends Google_Model
|
19 |
{
|
20 |
public $canAddChildren;
|
21 |
+
public $canChangeCopyRequiresWriterPermission;
|
22 |
public $canChangeViewersCanCopyContent;
|
23 |
public $canComment;
|
24 |
public $canCopy;
|
25 |
public $canDelete;
|
26 |
+
public $canDeleteChildren;
|
27 |
public $canDownload;
|
28 |
public $canEdit;
|
29 |
public $canListChildren;
|
30 |
+
public $canMoveChildrenOutOfTeamDrive;
|
31 |
+
public $canMoveChildrenWithinTeamDrive;
|
32 |
public $canMoveItemIntoTeamDrive;
|
33 |
+
public $canMoveItemOutOfTeamDrive;
|
34 |
+
public $canMoveItemWithinTeamDrive;
|
35 |
public $canMoveTeamDriveItem;
|
36 |
public $canReadRevisions;
|
37 |
public $canReadTeamDrive;
|
39 |
public $canRename;
|
40 |
public $canShare;
|
41 |
public $canTrash;
|
42 |
+
public $canTrashChildren;
|
43 |
public $canUntrash;
|
44 |
|
45 |
public function setCanAddChildren($canAddChildren)
|
50 |
{
|
51 |
return $this->canAddChildren;
|
52 |
}
|
53 |
+
public function setCanChangeCopyRequiresWriterPermission($canChangeCopyRequiresWriterPermission)
|
54 |
+
{
|
55 |
+
$this->canChangeCopyRequiresWriterPermission = $canChangeCopyRequiresWriterPermission;
|
56 |
+
}
|
57 |
+
public function getCanChangeCopyRequiresWriterPermission()
|
58 |
+
{
|
59 |
+
return $this->canChangeCopyRequiresWriterPermission;
|
60 |
+
}
|
61 |
public function setCanChangeViewersCanCopyContent($canChangeViewersCanCopyContent)
|
62 |
{
|
63 |
$this->canChangeViewersCanCopyContent = $canChangeViewersCanCopyContent;
|
90 |
{
|
91 |
return $this->canDelete;
|
92 |
}
|
93 |
+
public function setCanDeleteChildren($canDeleteChildren)
|
94 |
+
{
|
95 |
+
$this->canDeleteChildren = $canDeleteChildren;
|
96 |
+
}
|
97 |
+
public function getCanDeleteChildren()
|
98 |
+
{
|
99 |
+
return $this->canDeleteChildren;
|
100 |
+
}
|
101 |
public function setCanDownload($canDownload)
|
102 |
{
|
103 |
$this->canDownload = $canDownload;
|
122 |
{
|
123 |
return $this->canListChildren;
|
124 |
}
|
125 |
+
public function setCanMoveChildrenOutOfTeamDrive($canMoveChildrenOutOfTeamDrive)
|
126 |
+
{
|
127 |
+
$this->canMoveChildrenOutOfTeamDrive = $canMoveChildrenOutOfTeamDrive;
|
128 |
+
}
|
129 |
+
public function getCanMoveChildrenOutOfTeamDrive()
|
130 |
+
{
|
131 |
+
return $this->canMoveChildrenOutOfTeamDrive;
|
132 |
+
}
|
133 |
+
public function setCanMoveChildrenWithinTeamDrive($canMoveChildrenWithinTeamDrive)
|
134 |
+
{
|
135 |
+
$this->canMoveChildrenWithinTeamDrive = $canMoveChildrenWithinTeamDrive;
|
136 |
+
}
|
137 |
+
public function getCanMoveChildrenWithinTeamDrive()
|
138 |
+
{
|
139 |
+
return $this->canMoveChildrenWithinTeamDrive;
|
140 |
+
}
|
141 |
public function setCanMoveItemIntoTeamDrive($canMoveItemIntoTeamDrive)
|
142 |
{
|
143 |
$this->canMoveItemIntoTeamDrive = $canMoveItemIntoTeamDrive;
|
146 |
{
|
147 |
return $this->canMoveItemIntoTeamDrive;
|
148 |
}
|
149 |
+
public function setCanMoveItemOutOfTeamDrive($canMoveItemOutOfTeamDrive)
|
150 |
+
{
|
151 |
+
$this->canMoveItemOutOfTeamDrive = $canMoveItemOutOfTeamDrive;
|
152 |
+
}
|
153 |
+
public function getCanMoveItemOutOfTeamDrive()
|
154 |
+
{
|
155 |
+
return $this->canMoveItemOutOfTeamDrive;
|
156 |
+
}
|
157 |
+
public function setCanMoveItemWithinTeamDrive($canMoveItemWithinTeamDrive)
|
158 |
+
{
|
159 |
+
$this->canMoveItemWithinTeamDrive = $canMoveItemWithinTeamDrive;
|
160 |
+
}
|
161 |
+
public function getCanMoveItemWithinTeamDrive()
|
162 |
+
{
|
163 |
+
return $this->canMoveItemWithinTeamDrive;
|
164 |
+
}
|
165 |
public function setCanMoveTeamDriveItem($canMoveTeamDriveItem)
|
166 |
{
|
167 |
$this->canMoveTeamDriveItem = $canMoveTeamDriveItem;
|
218 |
{
|
219 |
return $this->canTrash;
|
220 |
}
|
221 |
+
public function setCanTrashChildren($canTrashChildren)
|
222 |
+
{
|
223 |
+
$this->canTrashChildren = $canTrashChildren;
|
224 |
+
}
|
225 |
+
public function getCanTrashChildren()
|
226 |
+
{
|
227 |
+
return $this->canTrashChildren;
|
228 |
+
}
|
229 |
public function setCanUntrash($canUntrash)
|
230 |
{
|
231 |
$this->canUntrash = $canUntrash;
|
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Files.php
CHANGED
@@ -178,11 +178,12 @@ class Google_Service_Drive_Resource_Files extends Google_Service_Resource
|
|
178 |
* included in results.
|
179 |
* @opt_param string orderBy A comma-separated list of sort keys. Valid keys are
|
180 |
* 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name',
|
181 |
-
* 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred',
|
182 |
-
* 'viewedByMeTime'. Each key sorts ascending by default, but may be
|
183 |
-
* with the 'desc' modifier. Example usage:
|
184 |
-
* desc,name. Please note that there is a current
|
185 |
-
* approximately one million files in which the
|
|
|
186 |
* @opt_param int pageSize The maximum number of files to return per page.
|
187 |
* Partial or empty result pages are possible even before the end of the files
|
188 |
* list has been reached.
|
178 |
* included in results.
|
179 |
* @opt_param string orderBy A comma-separated list of sort keys. Valid keys are
|
180 |
* 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name',
|
181 |
+
* 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred',
|
182 |
+
* and 'viewedByMeTime'. Each key sorts ascending by default, but may be
|
183 |
+
* reversed with the 'desc' modifier. Example usage:
|
184 |
+
* ?orderBy=folder,modifiedTime desc,name. Please note that there is a current
|
185 |
+
* limitation for users with approximately one million files in which the
|
186 |
+
* requested sort order is ignored.
|
187 |
* @opt_param int pageSize The maximum number of files to return per page.
|
188 |
* Partial or empty result pages are possible even before the end of the files
|
189 |
* list has been reached.
|
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Permissions.php
CHANGED
@@ -32,7 +32,7 @@ class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
|
|
32 |
* @param Google_Service_Drive_Permission $postBody
|
33 |
* @param array $optParams Optional parameters.
|
34 |
*
|
35 |
-
* @opt_param string emailMessage A custom message to include in the
|
36 |
* notification email.
|
37 |
* @opt_param bool sendNotificationEmail Whether to send a notification email
|
38 |
* when sharing to users or groups. This defaults to true for users and groups,
|
@@ -43,6 +43,9 @@ class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
|
|
43 |
* @opt_param bool transferOwnership Whether to transfer ownership to the
|
44 |
* specified user and downgrade the current owner to a writer. This parameter is
|
45 |
* required as an acknowledgement of the side effect.
|
|
|
|
|
|
|
46 |
* @return Google_Service_Drive_Permission
|
47 |
*/
|
48 |
public function create($fileId, Google_Service_Drive_Permission $postBody, $optParams = array())
|
@@ -60,6 +63,9 @@ class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
|
|
60 |
*
|
61 |
* @opt_param bool supportsTeamDrives Whether the requesting application
|
62 |
* supports Team Drives.
|
|
|
|
|
|
|
63 |
*/
|
64 |
public function delete($fileId, $permissionId, $optParams = array())
|
65 |
{
|
@@ -76,6 +82,9 @@ class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
|
|
76 |
*
|
77 |
* @opt_param bool supportsTeamDrives Whether the requesting application
|
78 |
* supports Team Drives.
|
|
|
|
|
|
|
79 |
* @return Google_Service_Drive_Permission
|
80 |
*/
|
81 |
public function get($fileId, $permissionId, $optParams = array())
|
@@ -99,6 +108,9 @@ class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
|
|
99 |
* previous response.
|
100 |
* @opt_param bool supportsTeamDrives Whether the requesting application
|
101 |
* supports Team Drives.
|
|
|
|
|
|
|
102 |
* @return Google_Service_Drive_PermissionList
|
103 |
*/
|
104 |
public function listPermissions($fileId, $optParams = array())
|
@@ -121,6 +133,9 @@ class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
|
|
121 |
* @opt_param bool transferOwnership Whether to transfer ownership to the
|
122 |
* specified user and downgrade the current owner to a writer. This parameter is
|
123 |
* required as an acknowledgement of the side effect.
|
|
|
|
|
|
|
124 |
* @return Google_Service_Drive_Permission
|
125 |
*/
|
126 |
public function update($fileId, $permissionId, Google_Service_Drive_Permission $postBody, $optParams = array())
|
32 |
* @param Google_Service_Drive_Permission $postBody
|
33 |
* @param array $optParams Optional parameters.
|
34 |
*
|
35 |
+
* @opt_param string emailMessage A plain text custom message to include in the
|
36 |
* notification email.
|
37 |
* @opt_param bool sendNotificationEmail Whether to send a notification email
|
38 |
* when sharing to users or groups. This defaults to true for users and groups,
|
43 |
* @opt_param bool transferOwnership Whether to transfer ownership to the
|
44 |
* specified user and downgrade the current owner to a writer. This parameter is
|
45 |
* required as an acknowledgement of the side effect.
|
46 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
47 |
+
* administrator; if set to true, then the requester will be granted access if
|
48 |
+
* they are an administrator of the domain to which the item belongs.
|
49 |
* @return Google_Service_Drive_Permission
|
50 |
*/
|
51 |
public function create($fileId, Google_Service_Drive_Permission $postBody, $optParams = array())
|
63 |
*
|
64 |
* @opt_param bool supportsTeamDrives Whether the requesting application
|
65 |
* supports Team Drives.
|
66 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
67 |
+
* administrator; if set to true, then the requester will be granted access if
|
68 |
+
* they are an administrator of the domain to which the item belongs.
|
69 |
*/
|
70 |
public function delete($fileId, $permissionId, $optParams = array())
|
71 |
{
|
82 |
*
|
83 |
* @opt_param bool supportsTeamDrives Whether the requesting application
|
84 |
* supports Team Drives.
|
85 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
86 |
+
* administrator; if set to true, then the requester will be granted access if
|
87 |
+
* they are an administrator of the domain to which the item belongs.
|
88 |
* @return Google_Service_Drive_Permission
|
89 |
*/
|
90 |
public function get($fileId, $permissionId, $optParams = array())
|
108 |
* previous response.
|
109 |
* @opt_param bool supportsTeamDrives Whether the requesting application
|
110 |
* supports Team Drives.
|
111 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
112 |
+
* administrator; if set to true, then the requester will be granted access if
|
113 |
+
* they are an administrator of the domain to which the item belongs.
|
114 |
* @return Google_Service_Drive_PermissionList
|
115 |
*/
|
116 |
public function listPermissions($fileId, $optParams = array())
|
133 |
* @opt_param bool transferOwnership Whether to transfer ownership to the
|
134 |
* specified user and downgrade the current owner to a writer. This parameter is
|
135 |
* required as an acknowledgement of the side effect.
|
136 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
137 |
+
* administrator; if set to true, then the requester will be granted access if
|
138 |
+
* they are an administrator of the domain to which the item belongs.
|
139 |
* @return Google_Service_Drive_Permission
|
140 |
*/
|
141 |
public function update($fileId, $permissionId, Google_Service_Drive_Permission $postBody, $optParams = array())
|
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Teamdrives.php
CHANGED
@@ -61,6 +61,10 @@ class Google_Service_Drive_Resource_Teamdrives extends Google_Service_Resource
|
|
61 |
*
|
62 |
* @param string $teamDriveId The ID of the Team Drive
|
63 |
* @param array $optParams Optional parameters.
|
|
|
|
|
|
|
|
|
64 |
* @return Google_Service_Drive_TeamDrive
|
65 |
*/
|
66 |
public function get($teamDriveId, $optParams = array())
|
@@ -76,6 +80,10 @@ class Google_Service_Drive_Resource_Teamdrives extends Google_Service_Resource
|
|
76 |
*
|
77 |
* @opt_param int pageSize Maximum number of Team Drives to return.
|
78 |
* @opt_param string pageToken Page token for Team Drives.
|
|
|
|
|
|
|
|
|
79 |
* @return Google_Service_Drive_TeamDriveList
|
80 |
*/
|
81 |
public function listTeamdrives($optParams = array())
|
@@ -90,6 +98,10 @@ class Google_Service_Drive_Resource_Teamdrives extends Google_Service_Resource
|
|
90 |
* @param string $teamDriveId The ID of the Team Drive
|
91 |
* @param Google_Service_Drive_TeamDrive $postBody
|
92 |
* @param array $optParams Optional parameters.
|
|
|
|
|
|
|
|
|
93 |
* @return Google_Service_Drive_TeamDrive
|
94 |
*/
|
95 |
public function update($teamDriveId, Google_Service_Drive_TeamDrive $postBody, $optParams = array())
|
61 |
*
|
62 |
* @param string $teamDriveId The ID of the Team Drive
|
63 |
* @param array $optParams Optional parameters.
|
64 |
+
*
|
65 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
66 |
+
* administrator; if set to true, then the requester will be granted access if
|
67 |
+
* they are an administrator of the domain to which the Team Drive belongs.
|
68 |
* @return Google_Service_Drive_TeamDrive
|
69 |
*/
|
70 |
public function get($teamDriveId, $optParams = array())
|
80 |
*
|
81 |
* @opt_param int pageSize Maximum number of Team Drives to return.
|
82 |
* @opt_param string pageToken Page token for Team Drives.
|
83 |
+
* @opt_param string q Query string for searching Team Drives.
|
84 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
85 |
+
* administrator; if set to true, then all Team Drives of the domain in which
|
86 |
+
* the requester is an administrator are returned.
|
87 |
* @return Google_Service_Drive_TeamDriveList
|
88 |
*/
|
89 |
public function listTeamdrives($optParams = array())
|
98 |
* @param string $teamDriveId The ID of the Team Drive
|
99 |
* @param Google_Service_Drive_TeamDrive $postBody
|
100 |
* @param array $optParams Optional parameters.
|
101 |
+
*
|
102 |
+
* @opt_param bool useDomainAdminAccess Issue the request as a domain
|
103 |
+
* administrator; if set to true, then the requester will be granted access if
|
104 |
+
* they are an administrator of the domain to which the Team Drive belongs.
|
105 |
* @return Google_Service_Drive_TeamDrive
|
106 |
*/
|
107 |
public function update($teamDriveId, Google_Service_Drive_TeamDrive $postBody, $optParams = array())
|
vendor/google/apiclient-services/src/Google/Service/Drive/Revision.php
CHANGED
@@ -17,6 +17,7 @@
|
|
17 |
|
18 |
class Google_Service_Drive_Revision extends Google_Model
|
19 |
{
|
|
|
20 |
public $id;
|
21 |
public $keepForever;
|
22 |
public $kind;
|
@@ -31,6 +32,14 @@ class Google_Service_Drive_Revision extends Google_Model
|
|
31 |
public $publishedOutsideDomain;
|
32 |
public $size;
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
public function setId($id)
|
35 |
{
|
36 |
$this->id = $id;
|
17 |
|
18 |
class Google_Service_Drive_Revision extends Google_Model
|
19 |
{
|
20 |
+
public $exportLinks;
|
21 |
public $id;
|
22 |
public $keepForever;
|
23 |
public $kind;
|
32 |
public $publishedOutsideDomain;
|
33 |
public $size;
|
34 |
|
35 |
+
public function setExportLinks($exportLinks)
|
36 |
+
{
|
37 |
+
$this->exportLinks = $exportLinks;
|
38 |
+
}
|
39 |
+
public function getExportLinks()
|
40 |
+
{
|
41 |
+
return $this->exportLinks;
|
42 |
+
}
|
43 |
public function setId($id)
|
44 |
{
|
45 |
$this->id = $id;
|
vendor/google/apiclient-services/src/Google/Service/Drive/TeamDrive.php
CHANGED
@@ -23,9 +23,12 @@ class Google_Service_Drive_TeamDrive extends Google_Model
|
|
23 |
protected $capabilitiesType = 'Google_Service_Drive_TeamDriveCapabilities';
|
24 |
protected $capabilitiesDataType = '';
|
25 |
public $colorRgb;
|
|
|
26 |
public $id;
|
27 |
public $kind;
|
28 |
public $name;
|
|
|
|
|
29 |
public $themeId;
|
30 |
|
31 |
/**
|
@@ -72,6 +75,14 @@ class Google_Service_Drive_TeamDrive extends Google_Model
|
|
72 |
{
|
73 |
return $this->colorRgb;
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
public function setId($id)
|
76 |
{
|
77 |
$this->id = $id;
|
@@ -96,6 +107,20 @@ class Google_Service_Drive_TeamDrive extends Google_Model
|
|
96 |
{
|
97 |
return $this->name;
|
98 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
public function setThemeId($themeId)
|
100 |
{
|
101 |
$this->themeId = $themeId;
|
23 |
protected $capabilitiesType = 'Google_Service_Drive_TeamDriveCapabilities';
|
24 |
protected $capabilitiesDataType = '';
|
25 |
public $colorRgb;
|
26 |
+
public $createdTime;
|
27 |
public $id;
|
28 |
public $kind;
|
29 |
public $name;
|
30 |
+
protected $restrictionsType = 'Google_Service_Drive_TeamDriveRestrictions';
|
31 |
+
protected $restrictionsDataType = '';
|
32 |
public $themeId;
|
33 |
|
34 |
/**
|
75 |
{
|
76 |
return $this->colorRgb;
|
77 |
}
|
78 |
+
public function setCreatedTime($createdTime)
|
79 |
+
{
|
80 |
+
$this->createdTime = $createdTime;
|
81 |
+
}
|
82 |
+
public function getCreatedTime()
|
83 |
+
{
|
84 |
+
return $this->createdTime;
|
85 |
+
}
|
86 |
public function setId($id)
|
87 |
{
|
88 |
$this->id = $id;
|
107 |
{
|
108 |
return $this->name;
|
109 |
}
|
110 |
+
/**
|
111 |
+
* @param Google_Service_Drive_TeamDriveRestrictions
|
112 |
+
*/
|
113 |
+
public function setRestrictions(Google_Service_Drive_TeamDriveRestrictions $restrictions)
|
114 |
+
{
|
115 |
+
$this->restrictions = $restrictions;
|
116 |
+
}
|
117 |
+
/**
|
118 |
+
* @return Google_Service_Drive_TeamDriveRestrictions
|
119 |
+
*/
|
120 |
+
public function getRestrictions()
|
121 |
+
{
|
122 |
+
return $this->restrictions;
|
123 |
+
}
|
124 |
public function setThemeId($themeId)
|
125 |
{
|
126 |
$this->themeId = $themeId;
|
vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveCapabilities.php
CHANGED
@@ -18,9 +18,13 @@
|
|
18 |
class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
|
19 |
{
|
20 |
public $canAddChildren;
|
|
|
|
|
21 |
public $canChangeTeamDriveBackground;
|
|
|
22 |
public $canComment;
|
23 |
public $canCopy;
|
|
|
24 |
public $canDeleteTeamDrive;
|
25 |
public $canDownload;
|
26 |
public $canEdit;
|
@@ -31,6 +35,7 @@ class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
|
|
31 |
public $canRename;
|
32 |
public $canRenameTeamDrive;
|
33 |
public $canShare;
|
|
|
34 |
|
35 |
public function setCanAddChildren($canAddChildren)
|
36 |
{
|
@@ -40,6 +45,22 @@ class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
|
|
40 |
{
|
41 |
return $this->canAddChildren;
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
public function setCanChangeTeamDriveBackground($canChangeTeamDriveBackground)
|
44 |
{
|
45 |
$this->canChangeTeamDriveBackground = $canChangeTeamDriveBackground;
|
@@ -48,6 +69,14 @@ class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
|
|
48 |
{
|
49 |
return $this->canChangeTeamDriveBackground;
|
50 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
public function setCanComment($canComment)
|
52 |
{
|
53 |
$this->canComment = $canComment;
|
@@ -64,6 +93,14 @@ class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
|
|
64 |
{
|
65 |
return $this->canCopy;
|
66 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
public function setCanDeleteTeamDrive($canDeleteTeamDrive)
|
68 |
{
|
69 |
$this->canDeleteTeamDrive = $canDeleteTeamDrive;
|
@@ -144,4 +181,12 @@ class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
|
|
144 |
{
|
145 |
return $this->canShare;
|
146 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
18 |
class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
|
19 |
{
|
20 |
public $canAddChildren;
|
21 |
+
public $canChangeCopyRequiresWriterPermissionRestriction;
|
22 |
+
public $canChangeDomainUsersOnlyRestriction;
|
23 |
public $canChangeTeamDriveBackground;
|
24 |
+
public $canChangeTeamMembersOnlyRestriction;
|
25 |
public $canComment;
|
26 |
public $canCopy;
|
27 |
+
public $canDeleteChildren;
|
28 |
public $canDeleteTeamDrive;
|
29 |
public $canDownload;
|
30 |
public $canEdit;
|
35 |
public $canRename;
|
36 |
public $canRenameTeamDrive;
|
37 |
public $canShare;
|
38 |
+
public $canTrashChildren;
|
39 |
|
40 |
public function setCanAddChildren($canAddChildren)
|
41 |
{
|
45 |
{
|
46 |
return $this->canAddChildren;
|
47 |
}
|
48 |
+
public function setCanChangeCopyRequiresWriterPermissionRestriction($canChangeCopyRequiresWriterPermissionRestriction)
|
49 |
+
{
|
50 |
+
$this->canChangeCopyRequiresWriterPermissionRestriction = $canChangeCopyRequiresWriterPermissionRestriction;
|
51 |
+
}
|
52 |
+
public function getCanChangeCopyRequiresWriterPermissionRestriction()
|
53 |
+
{
|
54 |
+
return $this->canChangeCopyRequiresWriterPermissionRestriction;
|
55 |
+
}
|
56 |
+
public function setCanChangeDomainUsersOnlyRestriction($canChangeDomainUsersOnlyRestriction)
|
57 |
+
{
|
58 |
+
$this->canChangeDomainUsersOnlyRestriction = $canChangeDomainUsersOnlyRestriction;
|
59 |
+
}
|
60 |
+
public function getCanChangeDomainUsersOnlyRestriction()
|
61 |
+
{
|
62 |
+
return $this->canChangeDomainUsersOnlyRestriction;
|
63 |
+
}
|
64 |
public function setCanChangeTeamDriveBackground($canChangeTeamDriveBackground)
|
65 |
{
|
66 |
$this->canChangeTeamDriveBackground = $canChangeTeamDriveBackground;
|
69 |
{
|
70 |
return $this->canChangeTeamDriveBackground;
|
71 |
}
|
72 |
+
public function setCanChangeTeamMembersOnlyRestriction($canChangeTeamMembersOnlyRestriction)
|
73 |
+
{
|
74 |
+
$this->canChangeTeamMembersOnlyRestriction = $canChangeTeamMembersOnlyRestriction;
|
75 |
+
}
|
76 |
+
public function getCanChangeTeamMembersOnlyRestriction()
|
77 |
+
{
|
78 |
+
return $this->canChangeTeamMembersOnlyRestriction;
|
79 |
+
}
|
80 |
public function setCanComment($canComment)
|
81 |
{
|
82 |
$this->canComment = $canComment;
|
93 |
{
|
94 |
return $this->canCopy;
|
95 |
}
|
96 |
+
public function setCanDeleteChildren($canDeleteChildren)
|
97 |
+
{
|
98 |
+
$this->canDeleteChildren = $canDeleteChildren;
|
99 |
+
}
|
100 |
+
public function getCanDeleteChildren()
|
101 |
+
{
|
102 |
+
return $this->canDeleteChildren;
|
103 |
+
}
|
104 |
public function setCanDeleteTeamDrive($canDeleteTeamDrive)
|
105 |
{
|
106 |
$this->canDeleteTeamDrive = $canDeleteTeamDrive;
|
181 |
{
|
182 |
return $this->canShare;
|
183 |
}
|
184 |
+
public function setCanTrashChildren($canTrashChildren)
|
185 |
+
{
|
186 |
+
$this->canTrashChildren = $canTrashChildren;
|
187 |
+
}
|
188 |
+
public function getCanTrashChildren()
|
189 |
+
{
|
190 |
+
return $this->canTrashChildren;
|
191 |
+
}
|
192 |
}
|
wpvivid-backuprestore.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @wordpress-plugin
|
8 |
* Plugin Name: Backup WordPress Site by WPvivid
|
9 |
* Description: Automatically back up WordPress to Cloud Storage (Dropbox, Amazon S3, Microsoft OneDrive, Google Drive etc), one-click restore. All free.
|
10 |
-
* Version: 0.9.
|
11 |
* Author: wpvivid.com
|
12 |
* Author URI: https://wpvivid.com
|
13 |
* License: GPL-3.0+
|
@@ -21,7 +21,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
21 |
die;
|
22 |
}
|
23 |
|
24 |
-
define( 'WPVIVID_PLUGIN_VERSION', '0.9.
|
25 |
//
|
26 |
define('WPVIVID_RESTORE_INIT','init');
|
27 |
define('WPVIVID_RESTORE_READY','ready');
|
@@ -37,7 +37,7 @@ define('WPVIVID_PLUGIN_NAME',plugin_basename(__FILE__));
|
|
37 |
define('WPVIVID_PLUGIN_URL',plugins_url('',__FILE__));
|
38 |
define('WPVIVID_PLUGIN_DIR',dirname(__FILE__));
|
39 |
//We set a long enough default execution time (10 min) to ensure that the backup process can be completed.
|
40 |
-
define('WPVIVID_MAX_EXECUTION_TIME',
|
41 |
//If the server uses fastcgi then default execution time should be set to 2 min for more efficient.
|
42 |
define('WPVIVID_MAX_EXECUTION_TIME_FCGI',120);
|
43 |
//Default number of reserved backups
|
@@ -45,13 +45,13 @@ define('WPVIVID_MAX_BACKUP_COUNT',7);
|
|
45 |
define('WPVIVID_DEFAULT_BACKUP_COUNT',3);
|
46 |
define('WPVIVID_DEFAULT_COMPRESS_TYPE','zip');
|
47 |
//Max zip file size.
|
48 |
-
define('WPVIVID_DEFAULT_MAX_FILE_SIZE',
|
49 |
//Instruct PclZip to use all the time temporary files to create the zip archive or not.The default value is 1.
|
50 |
define('WPVIVID_DEFAULT_USE_TEMP',1);
|
51 |
//Instruct PclZip to use temporary files for files with size greater than.The default value is 16M.
|
52 |
define('WPVIVID_DEFAULT_USE_TEMP_SIZE',16);
|
53 |
//Exclude the files which is larger than.The default value is 0 means unlimited.
|
54 |
-
define('WPVIVID_DEFAULT_EXCLUDE_FILE_SIZE',
|
55 |
//Add a file in an archive without compressing the file.The default value is 200.
|
56 |
define('WPVIVID_DEFAULT_NO_COMPRESS',true);
|
57 |
//Backup save folder under WP_CONTENT_DIR
|
7 |
* @wordpress-plugin
|
8 |
* Plugin Name: Backup WordPress Site by WPvivid
|
9 |
* Description: Automatically back up WordPress to Cloud Storage (Dropbox, Amazon S3, Microsoft OneDrive, Google Drive etc), one-click restore. All free.
|
10 |
+
* Version: 0.9.12
|
11 |
* Author: wpvivid.com
|
12 |
* Author URI: https://wpvivid.com
|
13 |
* License: GPL-3.0+
|
21 |
die;
|
22 |
}
|
23 |
|
24 |
+
define( 'WPVIVID_PLUGIN_VERSION', '0.9.12' );
|
25 |
//
|
26 |
define('WPVIVID_RESTORE_INIT','init');
|
27 |
define('WPVIVID_RESTORE_READY','ready');
|
37 |
define('WPVIVID_PLUGIN_URL',plugins_url('',__FILE__));
|
38 |
define('WPVIVID_PLUGIN_DIR',dirname(__FILE__));
|
39 |
//We set a long enough default execution time (10 min) to ensure that the backup process can be completed.
|
40 |
+
define('WPVIVID_MAX_EXECUTION_TIME',900);
|
41 |
//If the server uses fastcgi then default execution time should be set to 2 min for more efficient.
|
42 |
define('WPVIVID_MAX_EXECUTION_TIME_FCGI',120);
|
43 |
//Default number of reserved backups
|
45 |
define('WPVIVID_DEFAULT_BACKUP_COUNT',3);
|
46 |
define('WPVIVID_DEFAULT_COMPRESS_TYPE','zip');
|
47 |
//Max zip file size.
|
48 |
+
define('WPVIVID_DEFAULT_MAX_FILE_SIZE',0);
|
49 |
//Instruct PclZip to use all the time temporary files to create the zip archive or not.The default value is 1.
|
50 |
define('WPVIVID_DEFAULT_USE_TEMP',1);
|
51 |
//Instruct PclZip to use temporary files for files with size greater than.The default value is 16M.
|
52 |
define('WPVIVID_DEFAULT_USE_TEMP_SIZE',16);
|
53 |
//Exclude the files which is larger than.The default value is 0 means unlimited.
|
54 |
+
define('WPVIVID_DEFAULT_EXCLUDE_FILE_SIZE',0);
|
55 |
//Add a file in an archive without compressing the file.The default value is 200.
|
56 |
define('WPVIVID_DEFAULT_NO_COMPRESS',true);
|
57 |
//Backup save folder under WP_CONTENT_DIR
|