Version Description
- Fixed: Special data in some database tables could not be replaced during a restore, which would cause failure of the restore.
- Fixed: Migration between sites that have different backup storage directories would fail.
- Fixed: The error establishing database connection occurred in some cases while loading the plugin page.
- Optimized the plugin code.
Download this release
Release Info
Developer | wpvivid |
Plugin | Migration, Backup, Staging – WPvivid |
Version | 0.9.21 |
Comparing to | |
See all releases |
Code changes from version 0.9.20 to 0.9.21
- admin/class-wpvivid-admin.php +2 -1
- admin/js/wpvivid-admin.js +129 -140
- admin/partials/wpvivid-admin-display.php +2 -0
- admin/partials/wpvivid-backup-restore-page-display.php +20 -18
- admin/partials/wpvivid-remote-storage-page-display.php +79 -12
- admin/partials/wpvivid-website-info-page-display.php +0 -2
- includes/class-wpvivid-backup-database.php +6 -1
- includes/class-wpvivid-backup-uploader.php +11 -5
- includes/class-wpvivid-backup.php +213 -337
- includes/class-wpvivid-compress-default.php +1 -0
- includes/class-wpvivid-db-method.php +22 -15
- includes/class-wpvivid-downloader.php +38 -417
- includes/class-wpvivid-migrate.php +3 -114
- includes/class-wpvivid-mysqldump-method.php +9 -1
- includes/class-wpvivid-mysqldump.php +2 -2
- includes/class-wpvivid-restore-data.php +46 -19
- includes/class-wpvivid-restore-database.php +42 -15
- includes/class-wpvivid-restore-db-pdo-mysql-method.php +10 -2
- includes/class-wpvivid-restore-site.php +12 -7
- includes/class-wpvivid-restore.php +8 -5
- includes/class-wpvivid-schedule.php +9 -3
- includes/class-wpvivid-setting.php +11 -7
- includes/class-wpvivid-taskmanager.php +12 -227
- includes/class-wpvivid-upload.php +56 -15
- includes/class-wpvivid-zipclass.php +1 -5
- includes/class-wpvivid.php +345 -546
- includes/customclass/class-wpvivid-amazons3-plus.php +84 -50
- includes/customclass/class-wpvivid-dropbox.php +60 -41
- includes/customclass/class-wpvivid-ftpclass.php +66 -47
- includes/customclass/class-wpvivid-google-drive.php +12 -9
- includes/customclass/class-wpvivid-one-drive.php +49 -51
- includes/customclass/class-wpvivid-remote-default.php +15 -0
- includes/customclass/class-wpvivid-s3compat.php +64 -40
- includes/customclass/class-wpvivid-send-to-site.php +14 -6
- includes/customclass/class-wpvivid-sftpclass.php +57 -36
- readme.txt +14 -3
- wpvivid-backuprestore.php +4 -4
admin/class-wpvivid-admin.php
CHANGED
@@ -404,7 +404,8 @@ class WPvivid_Admin {
|
|
404 |
$need_php_extensions[$need_extensions_count] = 'PDO';
|
405 |
$need_extensions_count++;
|
406 |
}
|
407 |
-
if(!function_exists("gzopen"))
|
|
|
408 |
$need_php_extensions[$need_extensions_count] = 'zlib';
|
409 |
$need_extensions_count++;
|
410 |
}
|
404 |
$need_php_extensions[$need_extensions_count] = 'PDO';
|
405 |
$need_extensions_count++;
|
406 |
}
|
407 |
+
if(!function_exists("gzopen"))
|
408 |
+
{
|
409 |
$need_php_extensions[$need_extensions_count] = 'zlib';
|
410 |
$need_extensions_count++;
|
411 |
}
|
admin/js/wpvivid-admin.js
CHANGED
@@ -19,12 +19,11 @@ var wpvivid_restore_download_index = 0;
|
|
19 |
var wpvivid_get_download_restore_progress_retry = 0;
|
20 |
var wpvivid_restore_timeout = false;
|
21 |
var wpvivid_restore_need_download = false;
|
22 |
-
var wpvivid_restore_backup_old_site = false;
|
23 |
var wpvivid_display_restore_backup = false;
|
24 |
var wpvivid_restore_backup_type = '';
|
25 |
var wpvivid_display_restore_check = false;
|
26 |
var wpvivid_restore_sure = false;
|
27 |
-
|
28 |
(function ($) {
|
29 |
'use strict';
|
30 |
|
@@ -204,7 +203,7 @@ function wpvivid_click_how_to_restore_backup(){
|
|
204 |
var top = jQuery('#wpvivid_how_to_restore_backup_describe').offset().top-jQuery('#wpvivid_how_to_restore_backup_describe').height();
|
205 |
jQuery('html, body').animate({scrollTop:top}, 'slow');
|
206 |
var div = "<div class='notice notice-info is-dismissible inline'>" +
|
207 |
-
"<p>Step One:
|
208 |
"<p>Step Two: Choose an option to complete restore, if any</p>" +
|
209 |
"<p>Step Three: Click 'Restore' button</p>" +
|
210 |
"<button type='button' class='notice-dismiss' onclick='click_dismiss_restore_notice(this);'>" +
|
@@ -370,12 +369,13 @@ function wpvivid_check_runningtask(){
|
|
370 |
}
|
371 |
}
|
372 |
if (jsonarray.download.length !== 0) {
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
376 |
var file_name = '';
|
377 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).html("");
|
378 |
-
var b_download_finish=false;
|
379 |
jQuery.each(jsonarray.download.files, function (index, value) {
|
380 |
i++;
|
381 |
file_name = index;
|
@@ -393,7 +393,7 @@ function wpvivid_check_runningtask(){
|
|
393 |
}
|
394 |
m_need_update = true;
|
395 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
396 |
-
b_download_finish=false;
|
397 |
}
|
398 |
else if (value.status === 'completed') {
|
399 |
if (m_downloading_file_name === file_name) {
|
@@ -402,7 +402,7 @@ function wpvivid_check_runningtask(){
|
|
402 |
m_downloading_file_name = '';
|
403 |
}
|
404 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
405 |
-
b_download_finish=true;
|
406 |
}
|
407 |
else if (value.status === 'error') {
|
408 |
if (m_downloading_file_name === file_name) {
|
@@ -412,7 +412,7 @@ function wpvivid_check_runningtask(){
|
|
412 |
}
|
413 |
alert(value.error);
|
414 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
415 |
-
b_download_finish=true;
|
416 |
}
|
417 |
else if (value.status === 'timeout') {
|
418 |
if (m_downloading_file_name === file_name) {
|
@@ -422,13 +422,18 @@ function wpvivid_check_runningtask(){
|
|
422 |
}
|
423 |
alert('Download timeout, please retry.');
|
424 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
425 |
-
b_download_finish=true;
|
426 |
}
|
427 |
});
|
428 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(jsonarray.download.place_html);
|
429 |
-
if(b_download_finish==true){
|
430 |
tmp_current_click_backupid = '';
|
431 |
}
|
|
|
|
|
|
|
|
|
|
|
432 |
}
|
433 |
if (!b_has_data) {
|
434 |
task_retry_times++;
|
@@ -767,6 +772,7 @@ function wpvivid_add_remote_storage(storage_type)
|
|
767 |
'type': storage_type
|
768 |
};
|
769 |
jQuery('input[option=add-remote]').css({'pointer-events': 'nano', 'opacity': '0.4'});
|
|
|
770 |
wpvivid_post_request(ajax_data, function (data)
|
771 |
{
|
772 |
try
|
@@ -785,7 +791,7 @@ function wpvivid_add_remote_storage(storage_type)
|
|
785 |
}
|
786 |
else if (jsonarray.result === 'failed')
|
787 |
{
|
788 |
-
|
789 |
jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
|
790 |
}
|
791 |
}
|
@@ -816,9 +822,10 @@ function wpvivid_handle_remote_storage_data(data){
|
|
816 |
jQuery('#wpvivid_schedule_backup_local_remote').html(jsonarray.local_remote);
|
817 |
wpvivid_control_remote_storage(jsonarray.remote_storage);
|
818 |
wpvivid_interface_flow_control();
|
|
|
819 |
}
|
820 |
else if(jsonarray.result === 'failed'){
|
821 |
-
|
822 |
}
|
823 |
}
|
824 |
catch(err){
|
@@ -927,6 +934,7 @@ function wpvivid_edit_remote_storage() {
|
|
927 |
'id': wpvivid_editing_storage_id,
|
928 |
'type': wpvivid_editing_storage_type
|
929 |
};
|
|
|
930 |
wpvivid_post_request(ajax_data, function(data){
|
931 |
try {
|
932 |
var jsonarray = jQuery.parseJSON(data);
|
@@ -936,7 +944,7 @@ function wpvivid_edit_remote_storage() {
|
|
936 |
wpvivid_handle_remote_storage_data(data);
|
937 |
}
|
938 |
else if (jsonarray.result === 'failed') {
|
939 |
-
|
940 |
}
|
941 |
}
|
942 |
catch(err){
|
@@ -1176,7 +1184,7 @@ function wpvivid_interface_flow_control(){
|
|
1176 |
}
|
1177 |
});
|
1178 |
|
1179 |
-
jQuery('input[name="remote_storage"]').on("click", function(){
|
1180 |
var check_status = true;
|
1181 |
if(jQuery(this).prop('checked') === true){
|
1182 |
check_status = true;
|
@@ -1191,7 +1199,7 @@ function wpvivid_interface_flow_control(){
|
|
1191 |
else {
|
1192 |
jQuery(this).prop('checked', false);
|
1193 |
}
|
1194 |
-
})
|
1195 |
|
1196 |
jQuery("input[name='schedule-backup-files']").bind("click",function(){
|
1197 |
if(jQuery(this).val() === "custom"){
|
@@ -1675,11 +1683,17 @@ function wpvivid_retrieve_log_list(){
|
|
1675 |
*/
|
1676 |
function wpvivid_set_default_remote_storage(){
|
1677 |
var remote_storage = new Array();
|
1678 |
-
remote_storage[0] = jQuery("input[name='remote_storage']:checked").val();
|
|
|
|
|
|
|
|
|
|
|
1679 |
var ajax_data = {
|
1680 |
'action': 'wpvivid_set_default_remote_storage',
|
1681 |
'remote_storage': remote_storage
|
1682 |
};
|
|
|
1683 |
wpvivid_post_request(ajax_data, function(data){
|
1684 |
wpvivid_handle_remote_storage_data(data);
|
1685 |
}, function(XMLHttpRequest, textStatus, errorThrown) {
|
@@ -1791,7 +1805,9 @@ function click_dismiss_restore_check_notice(obj){
|
|
1791 |
*
|
1792 |
* @param backup_id - The unique ID for the backup
|
1793 |
*/
|
1794 |
-
function wpvivid_init_restore_data(restore_type)
|
|
|
|
|
1795 |
var restore_method = '';
|
1796 |
if(restore_type == 'backup'){
|
1797 |
restore_method = '';
|
@@ -1815,7 +1831,6 @@ function wpvivid_init_restore_data(restore_type){
|
|
1815 |
jQuery('#wpvivid_restore_is_migrate').hide();
|
1816 |
}
|
1817 |
jQuery('#wpvivid_init_restore_data').addClass('is-active');
|
1818 |
-
jQuery('#wpvivid_restore_backup_old_site').hide();
|
1819 |
var ajax_data = {
|
1820 |
'action':'wpvivid_init_restore_page',
|
1821 |
'backup_id':m_restore_backup_id
|
@@ -1831,7 +1846,6 @@ function wpvivid_init_restore_data(restore_type){
|
|
1831 |
init_status = true;
|
1832 |
wpvivid_restore_download_array = new Array();
|
1833 |
var download_num = 0;
|
1834 |
-
//wpvivid_display_restore_msg("Backup is not found on web server. Prepare to download it from remote storage.", restore_type);
|
1835 |
jQuery.each(jsonarray.files, function (index, value)
|
1836 |
{
|
1837 |
if (value.status === "need_download")
|
@@ -1845,6 +1859,7 @@ function wpvivid_init_restore_data(restore_type){
|
|
1845 |
});
|
1846 |
wpvivid_restore_download_index=0;
|
1847 |
wpvivid_restore_need_download = true;
|
|
|
1848 |
}
|
1849 |
else if (jsonarray.result === "failed") {
|
1850 |
jQuery('#wpvivid_init_restore_data').removeClass('is-active');
|
@@ -1873,31 +1888,33 @@ function wpvivid_init_restore_data(restore_type){
|
|
1873 |
}
|
1874 |
jQuery('#wpvivid_init_restore_data').removeClass('is-active');
|
1875 |
if (jsonarray.has_exist_restore === 0) {
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
jQuery('#wpvivid_restore_is_migrate').show();
|
1886 |
-
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1887 |
-
jQuery('#wpvivid_replace_domain').prop('checked', false);
|
1888 |
-
jQuery('#wpvivid_keep_domain').prop('checked', false);
|
1889 |
-
}
|
1890 |
-
else {
|
1891 |
jQuery('#wpvivid_restore_is_migrate').hide();
|
1892 |
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1893 |
}
|
1894 |
-
if (jsonarray.skip_backup_old_site === 1) {
|
1895 |
-
jQuery('#wpvivid_restore_backup_old_site input').prop('checked', false);
|
1896 |
-
}
|
1897 |
-
else {
|
1898 |
-
jQuery('#wpvivid_restore_backup_old_site input').prop('checked', true);
|
1899 |
-
}
|
1900 |
-
wpvivid_interface_flow_control();
|
1901 |
}
|
1902 |
else if (jsonarray.has_exist_restore === 1) {
|
1903 |
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
@@ -1907,7 +1924,6 @@ function wpvivid_init_restore_data(restore_type){
|
|
1907 |
jQuery('#wpvivid_clean_'+restore_method+'part').show();
|
1908 |
jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
|
1909 |
jQuery('#wpvivid_restore_is_migrate').hide();
|
1910 |
-
jQuery('#wpvivid_restore_backup_old_site').hide();
|
1911 |
wpvivid_display_restore_msg("An uncompleted restore task exists, please terminate it first.", restore_type);
|
1912 |
}
|
1913 |
}
|
@@ -1922,6 +1938,48 @@ function wpvivid_init_restore_data(restore_type){
|
|
1922 |
});
|
1923 |
}
|
1924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1925 |
/**
|
1926 |
* This function will start the process of restoring a backup
|
1927 |
*/
|
@@ -1956,89 +2014,24 @@ function wpvivid_start_restore(restore_type = 'backup'){
|
|
1956 |
}
|
1957 |
else {
|
1958 |
wpvivid_monitor_restore_task(restore_type);
|
1959 |
-
|
1960 |
-
}
|
1961 |
-
}
|
1962 |
-
}
|
1963 |
-
|
1964 |
-
function wpvivid_prepare_restore(restore_type){
|
1965 |
-
var restore_method = '';
|
1966 |
-
if(restore_type == 'backup'){
|
1967 |
-
restore_method = '';
|
1968 |
-
}
|
1969 |
-
else if(restore_type == 'transfer'){
|
1970 |
-
restore_method = 'transfer_';
|
1971 |
-
}
|
1972 |
-
var restore_options = {
|
1973 |
-
0:'backup_db',
|
1974 |
-
1:'backup_themes',
|
1975 |
-
2:'backup_plugin',
|
1976 |
-
3:'backup_uploads',
|
1977 |
-
4:'backup_content',
|
1978 |
-
5:'backup_core'
|
1979 |
-
};
|
1980 |
-
var json = JSON.stringify(restore_options);
|
1981 |
-
|
1982 |
-
var ajax_data={
|
1983 |
-
'action':'wpvivid_prepare_restore',
|
1984 |
-
'backup_id':m_restore_backup_id,
|
1985 |
-
'restore_options':json
|
1986 |
-
};
|
1987 |
-
jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1988 |
-
jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1989 |
-
jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1990 |
-
jQuery('#wpvivid_restore_'+restore_method+'part').show();
|
1991 |
-
jQuery('#wpvivid_clean_'+restore_method+'part').hide();
|
1992 |
-
jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
|
1993 |
-
wpvivid_restoring = true;
|
1994 |
-
wpvivid_post_request(ajax_data, function(data)
|
1995 |
-
{
|
1996 |
-
try
|
1997 |
-
{
|
1998 |
-
var jsonarray = jQuery.parseJSON(data);
|
1999 |
-
if (jsonarray.result === "success")
|
2000 |
{
|
2001 |
-
|
2002 |
-
wpvivid_restore_lock();
|
2003 |
-
wpvivid_monitor_restore_task(restore_type);
|
2004 |
-
wpvivid_restore(restore_type);
|
2005 |
-
}
|
2006 |
-
else if (jsonarray.result === "need_download")
|
2007 |
-
{
|
2008 |
-
wpvivid_restore_lock();
|
2009 |
-
wpvivid_restore_download_array = new Array();
|
2010 |
-
var download_num = 0;
|
2011 |
-
wpvivid_display_restore_msg("Backup is not found on web server. Prepare to download it from remote storage.", restore_type);
|
2012 |
-
jQuery.each(jsonarray.files, function (index, value)
|
2013 |
{
|
2014 |
-
if
|
2015 |
{
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
}
|
2022 |
});
|
2023 |
-
wpvivid_restore_download_index=0;
|
2024 |
-
wpvivid_download_restore_file(restore_type);
|
2025 |
-
}
|
2026 |
-
else if (jsonarray.result === "failed")
|
2027 |
-
{
|
2028 |
-
wpvivid_display_restore_msg(jsonarray.error, restore_type);
|
2029 |
}
|
|
|
|
|
2030 |
}
|
2031 |
-
|
2032 |
-
{
|
2033 |
-
alert(err);
|
2034 |
-
jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
2035 |
-
}
|
2036 |
-
}, function(XMLHttpRequest, textStatus, errorThrown)
|
2037 |
-
{
|
2038 |
-
var error_message = wpvivid_output_ajaxerror('preparing to restore', textStatus, errorThrown);
|
2039 |
-
wpvivid_display_restore_msg(error_message, restore_type);
|
2040 |
-
jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
2041 |
-
});
|
2042 |
}
|
2043 |
|
2044 |
function wpvivid_download_restore_file(restore_type)
|
@@ -2061,9 +2054,15 @@ function wpvivid_download_restore_file(restore_type)
|
|
2061 |
if(wpvivid_restore_download_index+1>wpvivid_restore_download_array.length)
|
2062 |
{
|
2063 |
wpvivid_display_restore_msg("Download succeeded.", restore_type);
|
2064 |
-
|
2065 |
wpvivid_restore_need_download = false;
|
2066 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2067 |
}
|
2068 |
else
|
2069 |
{
|
@@ -2246,7 +2245,6 @@ function wpvivid_monitor_restore_task(restore_type){
|
|
2246 |
wpvivid_post_request(ajax_data, function (data) {
|
2247 |
try {
|
2248 |
var jsonarray = jQuery.parseJSON(data);
|
2249 |
-
|
2250 |
if (typeof jsonarray === 'object') {
|
2251 |
if (jsonarray.result === "success") {
|
2252 |
jQuery('#wpvivid_restore_' + restore_method + 'log').html("");
|
@@ -2341,19 +2339,10 @@ function wpvivid_restore(restore_type){
|
|
2341 |
'skip_backup_old_database':skip_old_site
|
2342 |
};
|
2343 |
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
if(value == '1'){
|
2349 |
-
var is_migrate = '1';
|
2350 |
-
var migrate_option = {
|
2351 |
-
'is_migrate':is_migrate,
|
2352 |
-
};
|
2353 |
-
jQuery.extend(extend_option, migrate_option);
|
2354 |
-
}
|
2355 |
-
}
|
2356 |
-
});
|
2357 |
|
2358 |
var restore_options = {
|
2359 |
0:'backup_db',
|
@@ -2614,8 +2603,8 @@ function wpvivid_restore_lock(){
|
|
2614 |
jQuery('#wpvivid_add_tab_log').css({'pointer-events': 'none', 'opacity': '1'});
|
2615 |
jQuery('#wpvivid_add_tab_restore').css({'pointer-events': 'none', 'opacity': '1'});
|
2616 |
jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'none', 'opacity': '1'});
|
2617 |
-
|
2618 |
-
|
2619 |
}
|
2620 |
|
2621 |
/**
|
@@ -2641,8 +2630,8 @@ function wpvivid_restore_unlock(){
|
|
2641 |
jQuery('#wpvivid_add_tab_log').css({'pointer-events': 'auto', 'opacity': '1'});
|
2642 |
jQuery('#wpvivid_add_tab_restore').css({'pointer-events': 'auto', 'opacity': '1'});
|
2643 |
jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'auto', 'opacity': '1'});
|
2644 |
-
|
2645 |
-
|
2646 |
}
|
2647 |
|
2648 |
/**
|
19 |
var wpvivid_get_download_restore_progress_retry = 0;
|
20 |
var wpvivid_restore_timeout = false;
|
21 |
var wpvivid_restore_need_download = false;
|
|
|
22 |
var wpvivid_display_restore_backup = false;
|
23 |
var wpvivid_restore_backup_type = '';
|
24 |
var wpvivid_display_restore_check = false;
|
25 |
var wpvivid_restore_sure = false;
|
26 |
+
var wpvivid_resotre_is_migrate=0;
|
27 |
(function ($) {
|
28 |
'use strict';
|
29 |
|
203 |
var top = jQuery('#wpvivid_how_to_restore_backup_describe').offset().top-jQuery('#wpvivid_how_to_restore_backup_describe').height();
|
204 |
jQuery('html, body').animate({scrollTop:top}, 'slow');
|
205 |
var div = "<div class='notice notice-info is-dismissible inline'>" +
|
206 |
+
"<p>Step One: In the backup list, click the 'Restore' button on the backup you want to restore. This will bring up the restore tab</p>" +
|
207 |
"<p>Step Two: Choose an option to complete restore, if any</p>" +
|
208 |
"<p>Step Three: Click 'Restore' button</p>" +
|
209 |
"<button type='button' class='notice-dismiss' onclick='click_dismiss_restore_notice(this);'>" +
|
369 |
}
|
370 |
}
|
371 |
if (jsonarray.download.length !== 0) {
|
372 |
+
if(jsonarray.download.result === 'success') {
|
373 |
+
b_has_data = true;
|
374 |
+
task_retry_times = 0;
|
375 |
+
var i = 0;
|
376 |
var file_name = '';
|
377 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).html("");
|
378 |
+
var b_download_finish = false;
|
379 |
jQuery.each(jsonarray.download.files, function (index, value) {
|
380 |
i++;
|
381 |
file_name = index;
|
393 |
}
|
394 |
m_need_update = true;
|
395 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
396 |
+
b_download_finish = false;
|
397 |
}
|
398 |
else if (value.status === 'completed') {
|
399 |
if (m_downloading_file_name === file_name) {
|
402 |
m_downloading_file_name = '';
|
403 |
}
|
404 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
405 |
+
b_download_finish = true;
|
406 |
}
|
407 |
else if (value.status === 'error') {
|
408 |
if (m_downloading_file_name === file_name) {
|
412 |
}
|
413 |
alert(value.error);
|
414 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
415 |
+
b_download_finish = true;
|
416 |
}
|
417 |
else if (value.status === 'timeout') {
|
418 |
if (m_downloading_file_name === file_name) {
|
422 |
}
|
423 |
alert('Download timeout, please retry.');
|
424 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.html);
|
425 |
+
b_download_finish = true;
|
426 |
}
|
427 |
});
|
428 |
jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(jsonarray.download.place_html);
|
429 |
+
if (b_download_finish == true) {
|
430 |
tmp_current_click_backupid = '';
|
431 |
}
|
432 |
+
}
|
433 |
+
else{
|
434 |
+
b_has_data = true;
|
435 |
+
alert(jsonarray.download.error);
|
436 |
+
}
|
437 |
}
|
438 |
if (!b_has_data) {
|
439 |
task_retry_times++;
|
772 |
'type': storage_type
|
773 |
};
|
774 |
jQuery('input[option=add-remote]').css({'pointer-events': 'nano', 'opacity': '0.4'});
|
775 |
+
jQuery('#wpvivid_remote_notice').html('');
|
776 |
wpvivid_post_request(ajax_data, function (data)
|
777 |
{
|
778 |
try
|
791 |
}
|
792 |
else if (jsonarray.result === 'failed')
|
793 |
{
|
794 |
+
jQuery('#wpvivid_remote_notice').html(jsonarray.notice);
|
795 |
jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
|
796 |
}
|
797 |
}
|
822 |
jQuery('#wpvivid_schedule_backup_local_remote').html(jsonarray.local_remote);
|
823 |
wpvivid_control_remote_storage(jsonarray.remote_storage);
|
824 |
wpvivid_interface_flow_control();
|
825 |
+
jQuery('#wpvivid_remote_notice').html(jsonarray.notice);
|
826 |
}
|
827 |
else if(jsonarray.result === 'failed'){
|
828 |
+
jQuery('#wpvivid_remote_notice').html(jsonarray.notice);
|
829 |
}
|
830 |
}
|
831 |
catch(err){
|
934 |
'id': wpvivid_editing_storage_id,
|
935 |
'type': wpvivid_editing_storage_type
|
936 |
};
|
937 |
+
jQuery('#wpvivid_remote_notice').html('');
|
938 |
wpvivid_post_request(ajax_data, function(data){
|
939 |
try {
|
940 |
var jsonarray = jQuery.parseJSON(data);
|
944 |
wpvivid_handle_remote_storage_data(data);
|
945 |
}
|
946 |
else if (jsonarray.result === 'failed') {
|
947 |
+
jQuery('#wpvivid_remote_notice').html(jsonarray.notice);
|
948 |
}
|
949 |
}
|
950 |
catch(err){
|
1184 |
}
|
1185 |
});
|
1186 |
|
1187 |
+
/*jQuery('input[name="remote_storage"]').on("click", function(){
|
1188 |
var check_status = true;
|
1189 |
if(jQuery(this).prop('checked') === true){
|
1190 |
check_status = true;
|
1199 |
else {
|
1200 |
jQuery(this).prop('checked', false);
|
1201 |
}
|
1202 |
+
});*/
|
1203 |
|
1204 |
jQuery("input[name='schedule-backup-files']").bind("click",function(){
|
1205 |
if(jQuery(this).val() === "custom"){
|
1683 |
*/
|
1684 |
function wpvivid_set_default_remote_storage(){
|
1685 |
var remote_storage = new Array();
|
1686 |
+
//remote_storage[0] = jQuery("input[name='remote_storage']:checked").val();
|
1687 |
+
jQuery.each(jQuery("input[name='remote_storage']:checked"), function()
|
1688 |
+
{
|
1689 |
+
remote_storage.push(jQuery(this).val());
|
1690 |
+
});
|
1691 |
+
|
1692 |
var ajax_data = {
|
1693 |
'action': 'wpvivid_set_default_remote_storage',
|
1694 |
'remote_storage': remote_storage
|
1695 |
};
|
1696 |
+
jQuery('#wpvivid_remote_notice').html('');
|
1697 |
wpvivid_post_request(ajax_data, function(data){
|
1698 |
wpvivid_handle_remote_storage_data(data);
|
1699 |
}, function(XMLHttpRequest, textStatus, errorThrown) {
|
1805 |
*
|
1806 |
* @param backup_id - The unique ID for the backup
|
1807 |
*/
|
1808 |
+
function wpvivid_init_restore_data(restore_type)
|
1809 |
+
{
|
1810 |
+
wpvivid_resotre_is_migrate=0;
|
1811 |
var restore_method = '';
|
1812 |
if(restore_type == 'backup'){
|
1813 |
restore_method = '';
|
1831 |
jQuery('#wpvivid_restore_is_migrate').hide();
|
1832 |
}
|
1833 |
jQuery('#wpvivid_init_restore_data').addClass('is-active');
|
|
|
1834 |
var ajax_data = {
|
1835 |
'action':'wpvivid_init_restore_page',
|
1836 |
'backup_id':m_restore_backup_id
|
1846 |
init_status = true;
|
1847 |
wpvivid_restore_download_array = new Array();
|
1848 |
var download_num = 0;
|
|
|
1849 |
jQuery.each(jsonarray.files, function (index, value)
|
1850 |
{
|
1851 |
if (value.status === "need_download")
|
1859 |
});
|
1860 |
wpvivid_restore_download_index=0;
|
1861 |
wpvivid_restore_need_download = true;
|
1862 |
+
wpvivid_download_restore_file(restore_type);
|
1863 |
}
|
1864 |
else if (jsonarray.result === "failed") {
|
1865 |
jQuery('#wpvivid_init_restore_data').removeClass('is-active');
|
1888 |
}
|
1889 |
jQuery('#wpvivid_init_restore_data').removeClass('is-active');
|
1890 |
if (jsonarray.has_exist_restore === 0) {
|
1891 |
+
if(wpvivid_restore_need_download == false) {
|
1892 |
+
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1893 |
+
jQuery('#wpvivid_clean_' + restore_method + 'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1894 |
+
jQuery('#wpvivid_rollback_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1895 |
+
jQuery('#wpvivid_restore_' + restore_method + 'part').show();
|
1896 |
+
jQuery('#wpvivid_clean_' + restore_method + 'part').hide();
|
1897 |
+
jQuery('#wpvivid_rollback_' + restore_method + 'part').hide();
|
1898 |
+
jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'auto', 'opacity': '1'});
|
1899 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
1900 |
jQuery('#wpvivid_restore_is_migrate').hide();
|
1901 |
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1902 |
+
|
1903 |
+
wpvivid_resotre_is_migrate = jsonarray.is_migrate;
|
1904 |
+
|
1905 |
+
if (jsonarray.is_migrate_ui === 1) {
|
1906 |
+
jQuery('#wpvivid_restore_is_migrate').show();
|
1907 |
+
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1908 |
+
jQuery('#wpvivid_replace_domain').prop('checked', false);
|
1909 |
+
jQuery('#wpvivid_keep_domain').prop('checked', false);
|
1910 |
+
}
|
1911 |
+
else {
|
1912 |
+
jQuery('#wpvivid_restore_is_migrate').hide();
|
1913 |
+
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
wpvivid_interface_flow_control();
|
1917 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1918 |
}
|
1919 |
else if (jsonarray.has_exist_restore === 1) {
|
1920 |
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1924 |
jQuery('#wpvivid_clean_'+restore_method+'part').show();
|
1925 |
jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
|
1926 |
jQuery('#wpvivid_restore_is_migrate').hide();
|
|
|
1927 |
wpvivid_display_restore_msg("An uncompleted restore task exists, please terminate it first.", restore_type);
|
1928 |
}
|
1929 |
}
|
1938 |
});
|
1939 |
}
|
1940 |
|
1941 |
+
function wpvivid_restore_is_migrate(restore_type){
|
1942 |
+
var ajax_data = {
|
1943 |
+
'action': 'wpvivid_get_restore_file_is_migrate',
|
1944 |
+
'backup_id': m_restore_backup_id
|
1945 |
+
};
|
1946 |
+
var restore_method = '';
|
1947 |
+
wpvivid_post_request(ajax_data, function(data)
|
1948 |
+
{
|
1949 |
+
try
|
1950 |
+
{
|
1951 |
+
var jsonarray = jQuery.parseJSON(data);
|
1952 |
+
if(jsonarray.result === "success")
|
1953 |
+
{
|
1954 |
+
if (jsonarray.is_migrate_ui === 1)
|
1955 |
+
{
|
1956 |
+
jQuery('#wpvivid_restore_is_migrate').show();
|
1957 |
+
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
1958 |
+
jQuery('#wpvivid_replace_domain').prop('checked', false);
|
1959 |
+
jQuery('#wpvivid_keep_domain').prop('checked', false);
|
1960 |
+
}
|
1961 |
+
else {
|
1962 |
+
jQuery('#wpvivid_restore_is_migrate').hide();
|
1963 |
+
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
1964 |
+
}
|
1965 |
+
}
|
1966 |
+
else if (jsonarray.result === "failed") {
|
1967 |
+
jQuery('#wpvivid_init_restore_data').removeClass('is-active');
|
1968 |
+
wpvivid_display_restore_msg(jsonarray.error, restore_type);
|
1969 |
+
}
|
1970 |
+
}
|
1971 |
+
catch(err){
|
1972 |
+
alert(err);
|
1973 |
+
}
|
1974 |
+
}, function(XMLHttpRequest, textStatus, errorThrown)
|
1975 |
+
{
|
1976 |
+
setTimeout(function()
|
1977 |
+
{
|
1978 |
+
wpvivid_restore_is_migrate(restore_type);
|
1979 |
+
}, 3000);
|
1980 |
+
});
|
1981 |
+
}
|
1982 |
+
|
1983 |
/**
|
1984 |
* This function will start the process of restoring a backup
|
1985 |
*/
|
2014 |
}
|
2015 |
else {
|
2016 |
wpvivid_monitor_restore_task(restore_type);
|
2017 |
+
if(wpvivid_resotre_is_migrate==0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018 |
{
|
2019 |
+
jQuery('input:radio[option=restore]').each(function()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020 |
{
|
2021 |
+
if(jQuery(this).prop('checked'))
|
2022 |
{
|
2023 |
+
var value = jQuery(this).prop('value');
|
2024 |
+
if(value == '1')
|
2025 |
+
{
|
2026 |
+
wpvivid_resotre_is_migrate = '1';
|
2027 |
+
}
|
2028 |
}
|
2029 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2030 |
}
|
2031 |
+
|
2032 |
+
wpvivid_restore(restore_type);
|
2033 |
}
|
2034 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2035 |
}
|
2036 |
|
2037 |
function wpvivid_download_restore_file(restore_type)
|
2054 |
if(wpvivid_restore_download_index+1>wpvivid_restore_download_array.length)
|
2055 |
{
|
2056 |
wpvivid_display_restore_msg("Download succeeded.", restore_type);
|
2057 |
+
wpvivid_restore_is_migrate(restore_type);
|
2058 |
wpvivid_restore_need_download = false;
|
2059 |
+
jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
|
2060 |
+
jQuery('#wpvivid_clean_' + restore_method + 'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
|
2061 |
+
jQuery('#wpvivid_rollback_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
|
2062 |
+
jQuery('#wpvivid_restore_' + restore_method + 'part').show();
|
2063 |
+
jQuery('#wpvivid_clean_' + restore_method + 'part').hide();
|
2064 |
+
jQuery('#wpvivid_rollback_' + restore_method + 'part').hide();
|
2065 |
+
//wpvivid_start_restore(restore_type);
|
2066 |
}
|
2067 |
else
|
2068 |
{
|
2245 |
wpvivid_post_request(ajax_data, function (data) {
|
2246 |
try {
|
2247 |
var jsonarray = jQuery.parseJSON(data);
|
|
|
2248 |
if (typeof jsonarray === 'object') {
|
2249 |
if (jsonarray.result === "success") {
|
2250 |
jQuery('#wpvivid_restore_' + restore_method + 'log').html("");
|
2339 |
'skip_backup_old_database':skip_old_site
|
2340 |
};
|
2341 |
|
2342 |
+
var migrate_option = {
|
2343 |
+
'is_migrate':wpvivid_resotre_is_migrate,
|
2344 |
+
};
|
2345 |
+
jQuery.extend(extend_option, migrate_option);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2346 |
|
2347 |
var restore_options = {
|
2348 |
0:'backup_db',
|
2603 |
jQuery('#wpvivid_add_tab_log').css({'pointer-events': 'none', 'opacity': '1'});
|
2604 |
jQuery('#wpvivid_add_tab_restore').css({'pointer-events': 'none', 'opacity': '1'});
|
2605 |
jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'none', 'opacity': '1'});
|
2606 |
+
jQuery('#wpvivid_replace_domain').css({'pointer-events': 'none', 'opacity': '1'});
|
2607 |
+
jQuery('#wpvivid_keep_domain').css({'pointer-events': 'none', 'opacity': '1'});
|
2608 |
}
|
2609 |
|
2610 |
/**
|
2630 |
jQuery('#wpvivid_add_tab_log').css({'pointer-events': 'auto', 'opacity': '1'});
|
2631 |
jQuery('#wpvivid_add_tab_restore').css({'pointer-events': 'auto', 'opacity': '1'});
|
2632 |
jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'auto', 'opacity': '1'});
|
2633 |
+
jQuery('#wpvivid_replace_domain').css({'pointer-events': 'auto', 'opacity': '1'});
|
2634 |
+
jQuery('#wpvivid_keep_domain').css({'pointer-events': 'auto', 'opacity': '1'});
|
2635 |
}
|
2636 |
|
2637 |
/**
|
admin/partials/wpvivid-admin-display.php
CHANGED
@@ -19,6 +19,7 @@ if (!defined('WPVIVID_PLUGIN_DIR'))
|
|
19 |
global $wpvivid_pulgin;
|
20 |
$backuplist=WPvivid_Backuplist::get_backuplist();
|
21 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
|
|
22 |
$schedule=WPvivid_Schedule::get_schedule();
|
23 |
$backupdir=WPvivid_Setting::get_backupdir();
|
24 |
$general_setting=WPvivid_Setting::get_setting(true, "");
|
@@ -110,6 +111,7 @@ add_action('wpvivid_backuprestore_add_tab', 'add_tab_read_log', 18);
|
|
110 |
}
|
111 |
?>
|
112 |
</div>
|
|
|
113 |
</div>
|
114 |
<h2 class="nav-tab-wrapper">
|
115 |
<?php do_action('wpvivid_backuprestore_add_tab');?>
|
19 |
global $wpvivid_pulgin;
|
20 |
$backuplist=WPvivid_Backuplist::get_backuplist();
|
21 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
22 |
+
$select=WPvivid_Setting::get_user_history('remote_selected');
|
23 |
$schedule=WPvivid_Schedule::get_schedule();
|
24 |
$backupdir=WPvivid_Setting::get_backupdir();
|
25 |
$general_setting=WPvivid_Setting::get_setting(true, "");
|
111 |
}
|
112 |
?>
|
113 |
</div>
|
114 |
+
<div id="wpvivid_remote_notice"></div>
|
115 |
</div>
|
116 |
<h2 class="nav-tab-wrapper">
|
117 |
<?php do_action('wpvivid_backuprestore_add_tab');?>
|
admin/partials/wpvivid-backup-restore-page-display.php
CHANGED
@@ -44,19 +44,7 @@ function wpvivid_backup_manual(){
|
|
44 |
<div class="quickstart-archive-block">
|
45 |
<fieldset>
|
46 |
<legend class="screen-reader-text"><span>input type="radio"</span></legend>
|
47 |
-
|
48 |
-
<input type="radio" option="backup" name="backup_files" value="files+db" checked />
|
49 |
-
<span><?php _e( 'Database + Files (Entire website)', 'wpvivid' ); ?></span>
|
50 |
-
</label><br>
|
51 |
-
<label>
|
52 |
-
<input type="radio" option="backup" name="backup_files" value="files" />
|
53 |
-
<span><?php _e( 'All Files (Exclude Database)', 'wpvivid' ); ?></span>
|
54 |
-
</label><br>
|
55 |
-
<label>
|
56 |
-
<input type="radio" option="backup" name="backup_files" value="db" />
|
57 |
-
<span><?php _e( 'Only Database', 'wpvivid' ); ?></span>
|
58 |
-
</label><br>
|
59 |
-
<?php do_action('wpvivid_backuprestore_add_custom'); ?>
|
60 |
<label style="display: none;">
|
61 |
<input type="checkbox" option="backup" name="ismerge" value="1" checked />
|
62 |
</label><br>
|
@@ -102,6 +90,24 @@ function wpvivid_backup_manual(){
|
|
102 |
<?php
|
103 |
}
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
function wpvivid_backup_schedule(){
|
106 |
?>
|
107 |
<div class="postbox qucikbackup-schedule" id="wpvivid_postbox_backup_schedule">
|
@@ -341,11 +347,6 @@ function wpvivid_add_page_restore(){
|
|
341 |
<input type="radio" id="wpvivid_keep_domain" option="restore" name="restore_domain" value="0" /><?php _e('Restore and keep the original domain(URL) unchanged', 'wpvivid'); ?>
|
342 |
</label><br>
|
343 |
</div>
|
344 |
-
<div id="wpvivid_restore_backup_old_site">
|
345 |
-
<!--<label >
|
346 |
-
<input type="checkbox" option="restore" name="skip_backup_old_site" /><?php _e('Checking this option will create a backup for this site before website restoration, which will help you stand a chance to rollback your site', 'wpvivid'); ?>
|
347 |
-
</label><br>-->
|
348 |
-
</div>
|
349 |
<div id="wpvivid_restore_check"></div>
|
350 |
<div class="restore-button-position" id="wpvivid_restore_part"><input class="button-primary" id="wpvivid_restore_btn" type="submit" name="restore" value="<?php esc_attr_e( 'Restore', 'wpvivid' ); ?>" onclick="wpvivid_start_restore();" /></div>
|
351 |
<div class="restore-button-position" id="wpvivid_clean_part"><input class="button-primary" id="wpvivid_clean_restore" type="submit" name="clear_restore" value="<?php esc_attr_e( 'Terminate', 'wpvivid' ); ?>" /></div>
|
@@ -441,6 +442,7 @@ add_action('wpvivid_backup_add_tab', 'wpvivid_add_tab_restore', 16);
|
|
441 |
add_action('wpvivid_backup_add_page', 'wpvivid_add_page_backup', 13);
|
442 |
add_action('wpvivid_backup_add_page', 'wpvivid_add_page_log', 15);
|
443 |
add_action('wpvivid_backup_add_page', 'wpvivid_add_page_restore', 16);
|
|
|
444 |
add_action('wpvivid_backup_do_js', 'wpvivid_backup_do_js', 10);
|
445 |
add_filter('wpvivid_download_backup_descript', 'wpvivid_download_backup_descript', 10);
|
446 |
add_filter('wpvivid_restore_website_dexcript', 'wpvivid_restore_website_dexcript', 10);
|
44 |
<div class="quickstart-archive-block">
|
45 |
<fieldset>
|
46 |
<legend class="screen-reader-text"><span>input type="radio"</span></legend>
|
47 |
+
<?php do_action('wpvivid_add_backup_type'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
<label style="display: none;">
|
49 |
<input type="checkbox" option="backup" name="ismerge" value="1" checked />
|
50 |
</label><br>
|
90 |
<?php
|
91 |
}
|
92 |
|
93 |
+
function wpvivid_add_backup_type()
|
94 |
+
{
|
95 |
+
?>
|
96 |
+
<label>
|
97 |
+
<input type="radio" option="backup" name="backup_files" value="files+db" checked />
|
98 |
+
<span><?php _e( 'Database + Files (Entire website)', 'wpvivid' ); ?></span>
|
99 |
+
</label><br>
|
100 |
+
<label>
|
101 |
+
<input type="radio" option="backup" name="backup_files" value="files" />
|
102 |
+
<span><?php _e( 'All Files (Exclude Database)', 'wpvivid' ); ?></span>
|
103 |
+
</label><br>
|
104 |
+
<label>
|
105 |
+
<input type="radio" option="backup" name="backup_files" value="db" />
|
106 |
+
<span><?php _e( 'Only Database', 'wpvivid' ); ?></span>
|
107 |
+
</label><br>
|
108 |
+
<?php
|
109 |
+
}
|
110 |
+
|
111 |
function wpvivid_backup_schedule(){
|
112 |
?>
|
113 |
<div class="postbox qucikbackup-schedule" id="wpvivid_postbox_backup_schedule">
|
347 |
<input type="radio" id="wpvivid_keep_domain" option="restore" name="restore_domain" value="0" /><?php _e('Restore and keep the original domain(URL) unchanged', 'wpvivid'); ?>
|
348 |
</label><br>
|
349 |
</div>
|
|
|
|
|
|
|
|
|
|
|
350 |
<div id="wpvivid_restore_check"></div>
|
351 |
<div class="restore-button-position" id="wpvivid_restore_part"><input class="button-primary" id="wpvivid_restore_btn" type="submit" name="restore" value="<?php esc_attr_e( 'Restore', 'wpvivid' ); ?>" onclick="wpvivid_start_restore();" /></div>
|
352 |
<div class="restore-button-position" id="wpvivid_clean_part"><input class="button-primary" id="wpvivid_clean_restore" type="submit" name="clear_restore" value="<?php esc_attr_e( 'Terminate', 'wpvivid' ); ?>" /></div>
|
442 |
add_action('wpvivid_backup_add_page', 'wpvivid_add_page_backup', 13);
|
443 |
add_action('wpvivid_backup_add_page', 'wpvivid_add_page_log', 15);
|
444 |
add_action('wpvivid_backup_add_page', 'wpvivid_add_page_restore', 16);
|
445 |
+
add_action('wpvivid_add_backup_type', 'wpvivid_add_backup_type', 11);
|
446 |
add_action('wpvivid_backup_do_js', 'wpvivid_backup_do_js', 10);
|
447 |
add_filter('wpvivid_download_backup_descript', 'wpvivid_download_backup_descript', 10);
|
448 |
add_filter('wpvivid_restore_website_dexcript', 'wpvivid_restore_website_dexcript', 10);
|
admin/partials/wpvivid-remote-storage-page-display.php
CHANGED
@@ -1,12 +1,14 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
function wpvivid_add_tab_storage_list()
|
|
|
4 |
?>
|
5 |
<a href="#" id="wpvivid_tab_storage_list" class="nav-tab storage-nav-tab nav-tab-active" onclick="switchstorageTabs(event,'page-storage-list','page-storage-list')"><?php _e('Storages', 'wpvivid'); ?></a>
|
6 |
<?php
|
7 |
}
|
8 |
|
9 |
-
function wpvivid_add_tab_storage_edit()
|
|
|
10 |
?>
|
11 |
<a href="#" id="wpvivid_tab_storage_edit" class="nav-tab storage-nav-tab delete" onclick="switchstorageTabs(event,'page-storage_edit','page-storage_edit')" style="display: none;">
|
12 |
<div id="wpvivid_tab_storage_edit_text" style="margin-right: 15px;"><?php _e('Storage Edit', 'wpvivid'); ?></div>
|
@@ -17,7 +19,8 @@ function wpvivid_add_tab_storage_edit(){
|
|
17 |
<?php
|
18 |
}
|
19 |
|
20 |
-
function wpvivid_add_page_storage_list()
|
|
|
21 |
?>
|
22 |
<div class="storage-tab-content wpvivid_tab_storage_list" id="page-storage-list">
|
23 |
<div style="margin-top:10px;"><p><strong><?php _e('Please choose one storage to save your backups (remote storage)', 'wpvivid'); ?></strong></p></div>
|
@@ -51,7 +54,8 @@ function wpvivid_add_page_storage_list(){
|
|
51 |
<?php
|
52 |
}
|
53 |
|
54 |
-
function wpvivid_add_page_storage_edit()
|
|
|
55 |
?>
|
56 |
<div class="storage-tab-content wpvivid_tab_storage_edit" id="page-storage_edit" style="display:none;">
|
57 |
<div><?php do_action('wpvivid_edit_remote_page'); ?></div>
|
@@ -59,10 +63,69 @@ function wpvivid_add_page_storage_edit(){
|
|
59 |
<?php
|
60 |
}
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
?>
|
67 |
|
68 |
<div>
|
@@ -73,10 +136,14 @@ add_action('wpvivid_storage_add_page', 'wpvivid_add_page_storage_edit', 11);
|
|
73 |
<div class="postbox storage-account-block" id="wpvivid_storage_account_block">
|
74 |
<?php do_action('wpvivid_add_storage_page'); ?>
|
75 |
</div>
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
</div>
|
81 |
</div>
|
82 |
|
1 |
<?php
|
2 |
|
3 |
+
function wpvivid_add_tab_storage_list()
|
4 |
+
{
|
5 |
?>
|
6 |
<a href="#" id="wpvivid_tab_storage_list" class="nav-tab storage-nav-tab nav-tab-active" onclick="switchstorageTabs(event,'page-storage-list','page-storage-list')"><?php _e('Storages', 'wpvivid'); ?></a>
|
7 |
<?php
|
8 |
}
|
9 |
|
10 |
+
function wpvivid_add_tab_storage_edit()
|
11 |
+
{
|
12 |
?>
|
13 |
<a href="#" id="wpvivid_tab_storage_edit" class="nav-tab storage-nav-tab delete" onclick="switchstorageTabs(event,'page-storage_edit','page-storage_edit')" style="display: none;">
|
14 |
<div id="wpvivid_tab_storage_edit_text" style="margin-right: 15px;"><?php _e('Storage Edit', 'wpvivid'); ?></div>
|
19 |
<?php
|
20 |
}
|
21 |
|
22 |
+
function wpvivid_add_page_storage_list()
|
23 |
+
{
|
24 |
?>
|
25 |
<div class="storage-tab-content wpvivid_tab_storage_list" id="page-storage-list">
|
26 |
<div style="margin-top:10px;"><p><strong><?php _e('Please choose one storage to save your backups (remote storage)', 'wpvivid'); ?></strong></p></div>
|
54 |
<?php
|
55 |
}
|
56 |
|
57 |
+
function wpvivid_add_page_storage_edit()
|
58 |
+
{
|
59 |
?>
|
60 |
<div class="storage-tab-content wpvivid_tab_storage_edit" id="page-storage_edit" style="display:none;">
|
61 |
<div><?php do_action('wpvivid_edit_remote_page'); ?></div>
|
63 |
<?php
|
64 |
}
|
65 |
|
66 |
+
function wpvivid_storage_list($html)
|
67 |
+
{
|
68 |
+
$html='<h2 class="nav-tab-wrapper" style="padding-bottom:0!important;">';
|
69 |
+
$html.='<a href="#" id="wpvivid_tab_storage_list" class="nav-tab storage-nav-tab nav-tab-active" onclick="switchstorageTabs(event,\'page-storage-list\',\'page-storage-list\')">'. __('Storages', 'wpvivid').'</a>';
|
70 |
+
$html.='<a href="#" id="wpvivid_tab_storage_edit" class="nav-tab storage-nav-tab delete" onclick="switchstorageTabs(event,\'page-storage_edit\',\'page-storage_edit\')" style="display: none;">
|
71 |
+
<div id="wpvivid_tab_storage_edit_text" style="margin-right: 15px;">'.__('Storage Edit', 'wpvivid').'</div>
|
72 |
+
<div class="nav-tab-delete-img">
|
73 |
+
<img src="'.esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )).'" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, \'wpvivid_tab_storage_edit\', \'storage\', \'wpvivid_tab_storage_list\');" />
|
74 |
+
</div>
|
75 |
+
</a>';
|
76 |
+
$html.='</h2>';
|
77 |
+
$html.='<div class="storage-tab-content wpvivid_tab_storage_list" id="page-storage-list">
|
78 |
+
<div style="margin-top:10px;"><p><strong>'.__('Please choose one storage to save your backups (remote storage)', 'wpvivid').'</strong></p></div>
|
79 |
+
<div class="schedule-tab-block"></div>
|
80 |
+
<div class="">
|
81 |
+
<table class="widefat">
|
82 |
+
<thead>
|
83 |
+
<tr>
|
84 |
+
<th></th>
|
85 |
+
<th></th>
|
86 |
+
<th>'. __( 'Storage Provider', 'wpvivid' ).'</th>
|
87 |
+
<th class="row-title">'. __( 'Remote Storage Alias', 'wpvivid' ).'</th>
|
88 |
+
<th>'. __( 'Actions', 'wpvivid' ).'</th>
|
89 |
+
</tr>
|
90 |
+
</thead>
|
91 |
+
<tbody class="wpvivid-remote-storage-list" id="wpvivid_remote_storage_list">
|
92 |
+
';
|
93 |
+
$html_list='';
|
94 |
+
$html.= apply_filters('wpvivid_add_remote_storage_list', $html_list);
|
95 |
+
$html.='</tbody><tfoot><tr>
|
96 |
+
<th colspan="5" class="row-title"><input class="button-primary" id="wpvivid_set_default_remote_storage" type="submit" name="choose-remote-storage" value="'.esc_attr__( 'Save Changes', 'wpvivid' ).'" /></th>
|
97 |
+
</tr></tfoot></table></div></div>';
|
98 |
+
|
99 |
+
$html .= '<script>
|
100 |
+
jQuery(\'#wpvivid_remote_storage_list\').on("click", "input", function(){
|
101 |
+
var check_status = true;
|
102 |
+
if(jQuery(this).prop(\'checked\') === true){
|
103 |
+
check_status = true;
|
104 |
+
}
|
105 |
+
else {
|
106 |
+
check_status = false;
|
107 |
+
}
|
108 |
+
jQuery(\'input[name = "remote_storage"]\').prop(\'checked\', false);
|
109 |
+
if(check_status === true){
|
110 |
+
jQuery(this).prop(\'checked\', true);
|
111 |
+
}
|
112 |
+
else {
|
113 |
+
jQuery(this).prop(\'checked\', false);
|
114 |
+
}
|
115 |
+
});
|
116 |
+
</script>';
|
117 |
+
return $html;
|
118 |
+
}
|
119 |
+
// <h2 class="nav-tab-wrapper" style="padding-bottom:0!important;">
|
120 |
+
// <?php do_action('wpvivid_storage_add_tab');
|
121 |
+
// </h2>
|
122 |
+
// <?php do_action('wpvivid_storage_add_page');
|
123 |
+
|
124 |
+
//add_action('wpvivid_storage_add_tab', 'wpvivid_add_tab_storage_list', 10);
|
125 |
+
//add_action('wpvivid_storage_add_tab', 'wpvivid_add_tab_storage_edit', 11);
|
126 |
+
//add_action('wpvivid_storage_add_page', 'wpvivid_add_page_storage_list', 10);
|
127 |
+
//add_action('wpvivid_storage_add_page', 'wpvivid_add_page_storage_edit', 11);
|
128 |
+
add_filter('wpvivid_storage_list','wpvivid_storage_list',10);
|
129 |
?>
|
130 |
|
131 |
<div>
|
136 |
<div class="postbox storage-account-block" id="wpvivid_storage_account_block">
|
137 |
<?php do_action('wpvivid_add_storage_page'); ?>
|
138 |
</div>
|
139 |
+
<?php
|
140 |
+
$html = '';
|
141 |
+
$html = apply_filters('wpvivid_storage_list', $html);
|
142 |
+
echo $html;
|
143 |
+
?>
|
144 |
+
<div class="storage-tab-content wpvivid_tab_storage_edit" id="page-storage_edit" style="display:none;">
|
145 |
+
<div><?php do_action('wpvivid_edit_remote_page'); ?></div>
|
146 |
+
</div>
|
147 |
</div>
|
148 |
</div>
|
149 |
|
admin/partials/wpvivid-website-info-page-display.php
CHANGED
@@ -70,8 +70,6 @@
|
|
70 |
jQuery(this).children('td').each(function (j) {
|
71 |
if (j == 0) {
|
72 |
if (jQuery(this).html().indexOf('memory_limit') >= 0) {
|
73 |
-
//var wp_mem_limit = jQuery(this).next().html() + '<span title="This is the value in php.ini" style="cursor: pointer;"> (' + data + ') </span>';
|
74 |
-
//jQuery(this).next().html(wp_mem_limit);
|
75 |
jQuery(this).next().html(data);
|
76 |
}
|
77 |
}
|
70 |
jQuery(this).children('td').each(function (j) {
|
71 |
if (j == 0) {
|
72 |
if (jQuery(this).html().indexOf('memory_limit') >= 0) {
|
|
|
|
|
73 |
jQuery(this).next().html(data);
|
74 |
}
|
75 |
}
|
includes/class-wpvivid-backup-database.php
CHANGED
@@ -71,7 +71,12 @@ class WPvivid_Backup_Database
|
|
71 |
|
72 |
$db_method->check_max_allowed_packet();
|
73 |
|
74 |
-
$
|
|
|
|
|
|
|
|
|
|
|
75 |
//$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
|
76 |
$dump = new WPvivid_Mysqldump(DB_HOST,DB_NAME, DB_USER, DB_PASSWORD , array('exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
|
77 |
|
71 |
|
72 |
$db_method->check_max_allowed_packet();
|
73 |
|
74 |
+
if($data['key'] == WPVIVID_BACKUP_TYPE_DB) {
|
75 |
+
$exclude = array('/^(?!' . $prefix . ')/');
|
76 |
+
}
|
77 |
+
else{
|
78 |
+
$exclude = apply_filters('wpvivid_exclude_db_table', $data);
|
79 |
+
}
|
80 |
//$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
|
81 |
$dump = new WPvivid_Mysqldump(DB_HOST,DB_NAME, DB_USER, DB_PASSWORD , array('exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
|
82 |
|
includes/class-wpvivid-backup-uploader.php
CHANGED
@@ -172,7 +172,6 @@ class Wpvivid_BackupUploader
|
|
172 |
{
|
173 |
$add_file['file_name']=$file['name'];
|
174 |
$add_file['size']=filesize($path.$file['name']);
|
175 |
-
$add_file['md5']=md5_file($path.$file['name']);
|
176 |
$backup_data['files'][]=$add_file;
|
177 |
}
|
178 |
else
|
@@ -224,14 +223,17 @@ class Wpvivid_BackupUploader
|
|
224 |
{
|
225 |
$count++;
|
226 |
|
227 |
-
if (is_dir($path
|
228 |
{
|
229 |
continue;
|
230 |
} else {
|
231 |
if($this->check_file_is_a_wpvivid_backup($filename,$backup_id))
|
232 |
{
|
233 |
-
if($this->
|
234 |
-
|
|
|
|
|
|
|
235 |
}
|
236 |
}
|
237 |
}
|
@@ -250,7 +252,6 @@ class Wpvivid_BackupUploader
|
|
250 |
{
|
251 |
$add_file['file_name']=$file;
|
252 |
$add_file['size']=filesize($path.$file);
|
253 |
-
$add_file['md5']=md5_file($path.$file);
|
254 |
$backup_data['files'][]=$add_file;
|
255 |
}
|
256 |
global $wpvivid_pulgin;
|
@@ -574,4 +575,9 @@ class Wpvivid_BackupUploader
|
|
574 |
return true;
|
575 |
}
|
576 |
}
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
172 |
{
|
173 |
$add_file['file_name']=$file['name'];
|
174 |
$add_file['size']=filesize($path.$file['name']);
|
|
|
175 |
$backup_data['files'][]=$add_file;
|
176 |
}
|
177 |
else
|
223 |
{
|
224 |
$count++;
|
225 |
|
226 |
+
if (is_dir($path . $filename))
|
227 |
{
|
228 |
continue;
|
229 |
} else {
|
230 |
if($this->check_file_is_a_wpvivid_backup($filename,$backup_id))
|
231 |
{
|
232 |
+
if($this->zip_check_sum($path . $filename))
|
233 |
+
{
|
234 |
+
if($this->check_is_a_wpvivid_backup($path.$filename))
|
235 |
+
$backups[$backup_id]['files'][]=$filename;
|
236 |
+
}
|
237 |
}
|
238 |
}
|
239 |
}
|
252 |
{
|
253 |
$add_file['file_name']=$file;
|
254 |
$add_file['size']=filesize($path.$file);
|
|
|
255 |
$backup_data['files'][]=$add_file;
|
256 |
}
|
257 |
global $wpvivid_pulgin;
|
575 |
return true;
|
576 |
}
|
577 |
}
|
578 |
+
|
579 |
+
private function zip_check_sum($file_name)
|
580 |
+
{
|
581 |
+
return true;
|
582 |
+
}
|
583 |
}
|
includes/class-wpvivid-backup.php
CHANGED
@@ -186,23 +186,26 @@ class WPvivid_Backup_Task
|
|
186 |
$this->set_backup(WPVIVID_BACKUP_TYPE_DB);
|
187 |
}
|
188 |
else{
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
206 |
}
|
207 |
}
|
208 |
}
|
@@ -320,7 +323,8 @@ class WPvivid_Backup_Task
|
|
320 |
$exclude_regex[]='#^'.preg_quote($this -> transfer_path(WP_CONTENT_DIR).DIRECTORY_SEPARATOR.'plugins', '/').'#';
|
321 |
$exclude_regex[]='#^'.preg_quote($this -> transfer_path(WP_CONTENT_DIR).DIRECTORY_SEPARATOR.'cache', '/').'#';
|
322 |
$upload_dir = wp_upload_dir();
|
323 |
-
$exclude_regex[]='#^'.preg_quote($this -> transfer_path($upload_dir['basedir']), '/').'#'
|
|
|
324 |
$backup_data['exclude_regex']=$exclude_regex;
|
325 |
$backup_data['include_regex']=array();
|
326 |
}
|
@@ -332,6 +336,7 @@ class WPvivid_Backup_Task
|
|
332 |
$backup_data['json_info']['include_path'][]='wp-includes';
|
333 |
$backup_data['json_info']['include_path'][]='wp-admin';
|
334 |
$backup_data['json_info']['wp_core']=1;
|
|
|
335 |
$include_regex[]='#^'.preg_quote($this -> transfer_path(get_home_path().DIRECTORY_SEPARATOR.'wp-admin'), '/').'#';
|
336 |
$include_regex[]='#^'.preg_quote($this->transfer_path(get_home_path().DIRECTORY_SEPARATOR.'wp-includes'), '/').'#';
|
337 |
$exclude_regex[]='#^'.preg_quote($this->transfer_path(get_home_path().DIRECTORY_SEPARATOR.'wp-admin'.DIRECTORY_SEPARATOR), '/').'pclzip-.*\.tmp#';
|
@@ -349,6 +354,7 @@ class WPvivid_Backup_Task
|
|
349 |
$backup_data['files']=array_merge($backup_data['files'],$this->get_backup_file($backup_finished_data['key']));
|
350 |
}
|
351 |
$backup_data['json_info']['has_child']=1;
|
|
|
352 |
}
|
353 |
else
|
354 |
{
|
@@ -906,22 +912,30 @@ class WPvivid_Backup_Task
|
|
906 |
{
|
907 |
if($list_tasks['data']['type'] == 'upload')
|
908 |
{
|
909 |
-
$
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
|
|
|
|
|
|
|
|
921 |
}
|
922 |
-
|
923 |
-
$
|
|
|
|
|
|
|
924 |
}
|
|
|
925 |
$list_tasks['task_info']['speed'] = $speed;
|
926 |
$list_tasks['task_info']['descript'] = $descript.__(' Progress: ', 'wpvivid') . $list_tasks['task_info']['backup_percent'] . __(', running time: ', 'wpvivid') . $list_tasks['data']['running_time'];
|
927 |
|
@@ -1276,7 +1290,9 @@ class WPvivid_Backup_Item
|
|
1276 |
|
1277 |
public function check_backup_files()
|
1278 |
{
|
|
|
1279 |
$ret['result']=WPVIVID_FAILED;
|
|
|
1280 |
|
1281 |
$b_has_data=false;
|
1282 |
$tmp_data=array();
|
@@ -1293,22 +1309,33 @@ class WPvivid_Backup_Item
|
|
1293 |
if($b_has_data){
|
1294 |
$b_need_download=false;
|
1295 |
$b_not_found=false;
|
1296 |
-
|
1297 |
foreach ($tmp_data as $file)
|
1298 |
{
|
1299 |
$need_download=false;
|
1300 |
$path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
|
1301 |
if(file_exists($path))
|
1302 |
{
|
1303 |
-
|
1304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1305 |
{
|
1306 |
$need_download=true;
|
1307 |
-
//@unlink($path);
|
1308 |
}
|
1309 |
}
|
1310 |
else
|
1311 |
{
|
|
|
|
|
1312 |
$need_download=true;
|
1313 |
}
|
1314 |
|
@@ -1335,7 +1362,10 @@ class WPvivid_Backup_Item
|
|
1335 |
if($b_not_found)
|
1336 |
{
|
1337 |
$ret['result']=WPVIVID_FAILED;
|
1338 |
-
$
|
|
|
|
|
|
|
1339 |
}
|
1340 |
else if($b_need_download)
|
1341 |
{
|
@@ -1350,32 +1380,38 @@ class WPvivid_Backup_Item
|
|
1350 |
return $ret;
|
1351 |
}
|
1352 |
|
1353 |
-
|
1354 |
{
|
1355 |
-
$
|
1356 |
-
$json=$zip->get_json_data($file_name);
|
1357 |
-
|
1358 |
-
if(!$json)
|
1359 |
-
{
|
1360 |
-
return '';
|
1361 |
-
}
|
1362 |
-
else
|
1363 |
{
|
|
|
|
|
1364 |
|
1365 |
-
|
1366 |
-
if(!is_null($data))
|
1367 |
-
{
|
1368 |
-
if(isset($data['md5']))
|
1369 |
-
return $data['md5'];
|
1370 |
-
else
|
1371 |
-
return '';
|
1372 |
-
}
|
1373 |
-
else
|
1374 |
{
|
1375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1376 |
}
|
|
|
|
|
1377 |
}
|
1378 |
-
|
|
|
|
|
|
|
|
|
|
|
1379 |
|
1380 |
public function get_local_path()
|
1381 |
{
|
@@ -1599,174 +1635,191 @@ class WPvivid_Backup_Item
|
|
1599 |
return $files[0]['file_name'];
|
1600 |
}
|
1601 |
|
1602 |
-
public function
|
1603 |
-
$ret['result']=WPVIVID_FAILED;
|
1604 |
-
$data=array();
|
1605 |
-
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
1606 |
-
if(!$backup)
|
1607 |
-
{
|
1608 |
-
return $ret;
|
1609 |
-
}
|
1610 |
-
$b_data_type_true=false;
|
1611 |
$files=array();
|
1612 |
if(isset($backup['backup']['files'])){
|
1613 |
-
$b_data_type_true=true;
|
1614 |
$files=$backup['backup']['files'];
|
1615 |
}
|
1616 |
else{
|
1617 |
if(isset($backup['backup']['ismerge'])) {
|
1618 |
if ($backup['backup']['ismerge'] == 1) {
|
1619 |
if(isset($backup['backup']['data']['meta']['files'])){
|
1620 |
-
$b_data_type_true=true;
|
1621 |
$files=$backup['backup']['data']['meta']['files'];
|
1622 |
}
|
1623 |
}
|
1624 |
}
|
1625 |
}
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1641 |
}
|
1642 |
}
|
1643 |
-
else
|
|
|
|
|
|
|
|
|
1644 |
$need_download=true;
|
1645 |
}
|
1646 |
-
|
1647 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1648 |
}
|
1649 |
else{
|
1650 |
-
$
|
1651 |
-
|
1652 |
-
if($need_download) {
|
1653 |
-
if(empty($backup['remote'])) {
|
1654 |
-
$b_not_found=true;
|
1655 |
$ret['result'] = WPVIVID_SUCCESS;
|
1656 |
-
$ret['files'][$file['file_name']]['status']='
|
1657 |
-
|
1658 |
-
else{
|
1659 |
-
$task = WPvivid_taskmanager::get_download_task_v2($file['file_name']);
|
1660 |
-
if ($task === false) {
|
1661 |
-
$ret['result'] = WPVIVID_SUCCESS;
|
1662 |
-
$ret['files'][$file['file_name']]['status']='need_download';
|
1663 |
-
$ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
1664 |
<span>Part'.$format_part.'</span></br>
|
1665 |
<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>
|
1666 |
<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>
|
1667 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1668 |
</div>';
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
<span>Part'.$format_part.'</span></br>
|
1675 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
1676 |
<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>
|
1677 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1678 |
</div>';
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
<span>Part'.$format_part.'</span></br>
|
1685 |
<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>
|
1686 |
<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>
|
1687 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1688 |
</div>';
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
<span>Part'.$format_part.'</span></br>
|
1696 |
<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>
|
1697 |
<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>
|
1698 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1699 |
</div>';
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
<span>Part'.$format_part.'</span></br>
|
1706 |
<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>
|
1707 |
<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>
|
1708 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1709 |
</div>';
|
1710 |
-
|
1711 |
-
|
1712 |
-
}
|
1713 |
}
|
1714 |
}
|
1715 |
}
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
$
|
1721 |
-
|
1722 |
-
|
|
|
1723 |
<span>Part'.$format_part.'</span></br>
|
1724 |
<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>
|
1725 |
<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>
|
1726 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1727 |
</div>';
|
1728 |
-
}
|
1729 |
-
$ret['files'][$file['file_name']]['size']=$wpvivid_pulgin->formatBytes($file['size']);
|
1730 |
-
$file_count++;
|
1731 |
-
$file_part_num++;
|
1732 |
}
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
|
|
|
|
|
|
|
|
1742 |
<span>Part'.$format_part.'</span></br>
|
1743 |
<span>Download</span></br>
|
1744 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
1745 |
<span>size:</span><span>0</span>
|
1746 |
</div>';
|
1747 |
-
}
|
1748 |
-
else{
|
1749 |
-
$ret['place_html']='';
|
1750 |
-
}
|
1751 |
-
return $ret;
|
1752 |
}
|
1753 |
-
|
|
|
|
|
|
|
1754 |
}
|
1755 |
|
1756 |
public function update_download_page($backup_id){
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
{
|
1761 |
-
return $wpvivid_pulgin->init_download($backup_id);
|
1762 |
-
}
|
1763 |
-
else
|
1764 |
-
{
|
1765 |
-
$ret=$cache;
|
1766 |
-
$ret=$this->get_download_backup_files($backup_id);
|
1767 |
WPvivid_taskmanager::update_download_cache($backup_id,$ret);
|
1768 |
-
return $ret;
|
1769 |
}
|
|
|
1770 |
}
|
1771 |
}
|
1772 |
|
@@ -1807,7 +1860,6 @@ class WPvivid_Backup
|
|
1807 |
global $wpvivid_pulgin;
|
1808 |
$wpvivid_pulgin->set_time_limit($this->task->get_id());
|
1809 |
$this->task->update_sub_task_progress($next_backup['key'],0,'Start backing up '.$next_backup['key'].'.');
|
1810 |
-
//WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'backup', $next_backup['key'],0,'Start backing up '.$next_backup['key'].'.');
|
1811 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Prepare to backup '.$next_backup['key'].' files.','notice');
|
1812 |
if(isset($next_backup['files'])) {
|
1813 |
$wpvivid_pulgin->wpvivid_log->WriteLog('File number: ' . sizeof($next_backup['files']), 'notice');
|
@@ -1815,7 +1867,6 @@ class WPvivid_Backup
|
|
1815 |
$result = $this->_backup($next_backup);
|
1816 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Backing up '.$next_backup['key'].' completed.','notice');
|
1817 |
$this->task->update_sub_task_progress($next_backup['key'],1,'Backing up '.$next_backup['key'].' finished.');
|
1818 |
-
//WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'backup', $next_backup['key'],1,'Backing up '.$next_backup['key'].' finished.',$result);
|
1819 |
$this->task->update_backup_result($next_backup,$result);
|
1820 |
$wpvivid_pulgin->check_cancel_backup($task_id);
|
1821 |
unset($next_backup);
|
@@ -2055,144 +2106,6 @@ class WPvivid_Backup
|
|
2055 |
WPvivid_tools::clearcache($this->task->get_prefix());
|
2056 |
}
|
2057 |
|
2058 |
-
public function get_default_exclude_regex($type_name = '')
|
2059 |
-
{
|
2060 |
-
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
2061 |
-
if(!isset($options['log_save_location']))
|
2062 |
-
{
|
2063 |
-
WPvivid_Setting::set_default_common_option();
|
2064 |
-
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
2065 |
-
}
|
2066 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'updraft', '/').'#'; // Updraft Plus backup directory
|
2067 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS).DIRECTORY_SEPARATOR.'backwpup', '/').'#'; // BackWPup backup directory
|
2068 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS).DIRECTORY_SEPARATOR.'backup-guard', '/').'#'; // Wordpress Backup and Migrate Plugin backup directory
|
2069 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'ai1wm-backups', '/').'#'; // All-in-one WP migration backup directory
|
2070 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'backups', '/').'#'; // Xcloner backup directory
|
2071 |
-
|
2072 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'upgrade', '/').'#';
|
2073 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.'wpvivid', '/').'#';
|
2074 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir(), '/').'#';
|
2075 |
-
$regex['directory'][]='#^'.preg_quote(WPVIVID_PLUGIN_DIR, '/').'#';
|
2076 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT).DIRECTORY_SEPARATOR.$options['log_save_location'], '/').'#';
|
2077 |
-
switch ($type_name)
|
2078 |
-
{
|
2079 |
-
case WPVIVID_BACKUP_TYPE_CONTENT:
|
2080 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_PLUGIN), '/').'#';
|
2081 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_THEMES), '/').'#';
|
2082 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_UPLOADS), '/').'#';
|
2083 |
-
break;
|
2084 |
-
case WPVIVID_BACKUP_TYPE_CORE:
|
2085 |
-
$abs_path = $this ->get_default_directory(WPVIVID_BACKUP_TYPE_CORE).DIRECTORY_SEPARATOR;
|
2086 |
-
$regex['directory'][]='#^'.preg_quote($this->get_default_directory(WPVIVID_BACKUP_TYPE_CONTENT), '/').'#';
|
2087 |
-
$regex['directory'][]='#^'.preg_quote($abs_path.'wp-snapshots', '/').'#'; // Duplicator backup directory
|
2088 |
-
$regex['file'][]='#^'.preg_quote($abs_path.'.maintenance', '/').'#';
|
2089 |
-
break;
|
2090 |
-
}
|
2091 |
-
return $regex;
|
2092 |
-
}
|
2093 |
-
|
2094 |
-
public function get_default_directory($type_name = ''){
|
2095 |
-
$upload_dir = wp_upload_dir();
|
2096 |
-
$paths = array(
|
2097 |
-
WPVIVID_BACKUP_TYPE_CORE => $this -> transfer_path(dirname(WP_CONTENT_DIR)),
|
2098 |
-
WPVIVID_BACKUP_TYPE_CONTENT => $this -> transfer_path(WP_CONTENT_DIR),
|
2099 |
-
WPVIVID_BACKUP_TYPE_PLUGIN => $this -> transfer_path(WP_PLUGIN_DIR),
|
2100 |
-
WPVIVID_BACKUP_TYPE_THEMES => $this -> transfer_path(get_theme_root()),
|
2101 |
-
WPVIVID_BACKUP_TYPE_UPLOADS => $this -> transfer_path($upload_dir['basedir']),
|
2102 |
-
);
|
2103 |
-
|
2104 |
-
if(empty($type_name) || empty($paths[$type_name])){
|
2105 |
-
return '';
|
2106 |
-
}else{
|
2107 |
-
return $paths[$type_name];
|
2108 |
-
}
|
2109 |
-
}
|
2110 |
-
private function transfer_path($path){
|
2111 |
-
$path = str_replace('\\','/',$path);
|
2112 |
-
$values = explode('/',$path);
|
2113 |
-
return implode(DIRECTORY_SEPARATOR,$values);
|
2114 |
-
}
|
2115 |
-
|
2116 |
-
public function getFile($path ,$exclude_regex,$include_regex,$exclude_file_size,$log)
|
2117 |
-
{
|
2118 |
-
$log ->WriteLog('Start getting files.','notice');
|
2119 |
-
$files = array();
|
2120 |
-
$this->getFileLoop($files,$path,$exclude_regex,$include_regex,$exclude_file_size);
|
2121 |
-
$log ->WriteLog('Getting files completed.','notice');
|
2122 |
-
$log ->WriteLog('File number: '.sizeof($files),'notice');
|
2123 |
-
return $files;
|
2124 |
-
}
|
2125 |
-
private function getFileLoop(&$files,$path,$exclude_regex,$include_regex,$exclude_file_size,$include_dir = true){
|
2126 |
-
$count = 0;
|
2127 |
-
if(is_dir($path)) {
|
2128 |
-
$handler = opendir($path);
|
2129 |
-
while (($filename = readdir($handler)) !== false) {
|
2130 |
-
if ($filename != "." && $filename != "..") {
|
2131 |
-
$count++;
|
2132 |
-
|
2133 |
-
if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) {
|
2134 |
-
if ($this->regex_match($exclude_regex['directory'], $path . DIRECTORY_SEPARATOR . $filename, 0)) {
|
2135 |
-
if ($this->regex_match($include_regex, $path . DIRECTORY_SEPARATOR . $filename, 1)) {
|
2136 |
-
$this->getFileLoop($files, $path . DIRECTORY_SEPARATOR . $filename, $exclude_regex, $include_regex, $exclude_file_size, $include_dir);
|
2137 |
-
}
|
2138 |
-
}
|
2139 |
-
} else {
|
2140 |
-
if($this->regex_match($exclude_regex['file'], $path . DIRECTORY_SEPARATOR . $filename, 0)){
|
2141 |
-
if ($exclude_file_size == 0) {
|
2142 |
-
$files[] = $path . DIRECTORY_SEPARATOR . $filename;
|
2143 |
-
} else {
|
2144 |
-
if (filesize($path . DIRECTORY_SEPARATOR . $filename) < $exclude_file_size * 1024 * 1024) {
|
2145 |
-
$files[] = $path . DIRECTORY_SEPARATOR . $filename;
|
2146 |
-
}
|
2147 |
-
}
|
2148 |
-
}
|
2149 |
-
}
|
2150 |
-
}
|
2151 |
-
}
|
2152 |
-
if($handler)
|
2153 |
-
@closedir($handler);
|
2154 |
-
}
|
2155 |
-
if($include_dir && $count == 0){
|
2156 |
-
$files[] = $path;
|
2157 |
-
}
|
2158 |
-
}
|
2159 |
-
|
2160 |
-
private function regex_match($regex_array,$string,$mode)
|
2161 |
-
{
|
2162 |
-
if(empty($regex_array))
|
2163 |
-
{
|
2164 |
-
return true;
|
2165 |
-
}
|
2166 |
-
|
2167 |
-
if($mode==0)
|
2168 |
-
{
|
2169 |
-
foreach ($regex_array as $regex)
|
2170 |
-
{
|
2171 |
-
if(preg_match($regex,$string))
|
2172 |
-
{
|
2173 |
-
return false;
|
2174 |
-
}
|
2175 |
-
}
|
2176 |
-
|
2177 |
-
return true;
|
2178 |
-
}
|
2179 |
-
|
2180 |
-
if($mode==1)
|
2181 |
-
{
|
2182 |
-
foreach ($regex_array as $regex)
|
2183 |
-
{
|
2184 |
-
if(preg_match($regex,$string))
|
2185 |
-
{
|
2186 |
-
return true;
|
2187 |
-
}
|
2188 |
-
}
|
2189 |
-
|
2190 |
-
return false;
|
2191 |
-
}
|
2192 |
-
|
2193 |
-
return true;
|
2194 |
-
}
|
2195 |
-
|
2196 |
public function clean_remote_backup($remotes,$files)
|
2197 |
{
|
2198 |
$remote_option=array_shift($remotes);
|
@@ -2205,41 +2118,4 @@ class WPvivid_Backup
|
|
2205 |
$remote ->cleanup($files);
|
2206 |
}
|
2207 |
}
|
2208 |
-
|
2209 |
-
public function get_files_list($files,$data)
|
2210 |
-
{
|
2211 |
-
if($data['type'] === WPVIVID_BACKUP_TYPE_OTHERS){
|
2212 |
-
$file_path = $data['extra_data'];
|
2213 |
-
}
|
2214 |
-
else {
|
2215 |
-
$file_path = $this->get_default_directory($data['type']);
|
2216 |
-
$data['exclude_regex'] = $this->get_default_exclude_regex($data['type']);
|
2217 |
-
$data['include_regex'] = array();
|
2218 |
-
}
|
2219 |
-
|
2220 |
-
if($file_path=='')
|
2221 |
-
{
|
2222 |
-
$_files = array();
|
2223 |
-
}
|
2224 |
-
else
|
2225 |
-
{
|
2226 |
-
$_files = array();
|
2227 |
-
if( is_array($file_path) ) {
|
2228 |
-
foreach ($file_path as $file_path_custom) {
|
2229 |
-
if ($file_path_custom != '') {
|
2230 |
-
$_files[] = $this->getFile($file_path_custom, $data['exclude_regex'], $data['include_regex'], $data['compress']['exclude_file_size'], $data['log']);
|
2231 |
-
}
|
2232 |
-
}
|
2233 |
-
}
|
2234 |
-
else{
|
2235 |
-
$_files[] = $this->getFile($file_path, $data['exclude_regex'], $data['include_regex'], $data['compress']['exclude_file_size'], $data['log']);
|
2236 |
-
}
|
2237 |
-
}
|
2238 |
-
|
2239 |
-
foreach($_files as $_files_test) {
|
2240 |
-
$files = array_merge($_files_test, $files);
|
2241 |
-
}
|
2242 |
-
|
2243 |
-
return $files;
|
2244 |
-
}
|
2245 |
}
|
186 |
$this->set_backup(WPVIVID_BACKUP_TYPE_DB);
|
187 |
}
|
188 |
else{
|
189 |
+
$this->task['options']['backup_options']['backup'] = apply_filters('wpvivid_set_backup_type', $options, $this->task);
|
190 |
+
if(empty($this->task['options']['backup_options']['backup'])){
|
191 |
+
if($options['backup_files']['backup_db'] == '1'){
|
192 |
+
$this->set_backup(WPVIVID_BACKUP_TYPE_DB);
|
193 |
+
}
|
194 |
+
if($options['backup_files']['backup_themes'] == '1'){
|
195 |
+
$this->set_backup(WPVIVID_BACKUP_TYPE_THEMES);
|
196 |
+
}
|
197 |
+
if($options['backup_files']['backup_plugin'] == '1'){
|
198 |
+
$this->set_backup(WPVIVID_BACKUP_TYPE_PLUGIN);
|
199 |
+
}
|
200 |
+
if($options['backup_files']['backup_uploads'] == '1'){
|
201 |
+
$this->set_backup(WPVIVID_BACKUP_TYPE_UPLOADS);
|
202 |
+
}
|
203 |
+
if($options['backup_files']['backup_content'] == '1'){
|
204 |
+
$this->set_backup(WPVIVID_BACKUP_TYPE_CONTENT);
|
205 |
+
}
|
206 |
+
if($options['backup_files']['backup_core'] == '1'){
|
207 |
+
$this->set_backup(WPVIVID_BACKUP_TYPE_CORE);
|
208 |
+
}
|
209 |
}
|
210 |
}
|
211 |
}
|
323 |
$exclude_regex[]='#^'.preg_quote($this -> transfer_path(WP_CONTENT_DIR).DIRECTORY_SEPARATOR.'plugins', '/').'#';
|
324 |
$exclude_regex[]='#^'.preg_quote($this -> transfer_path(WP_CONTENT_DIR).DIRECTORY_SEPARATOR.'cache', '/').'#';
|
325 |
$upload_dir = wp_upload_dir();
|
326 |
+
$exclude_regex[]='#^'.preg_quote($this -> transfer_path($upload_dir['basedir']), '/').'#';
|
327 |
+
$exclude_regex[]='#^'.preg_quote($this->transfer_path(get_theme_root()), '/').'#';
|
328 |
$backup_data['exclude_regex']=$exclude_regex;
|
329 |
$backup_data['include_regex']=array();
|
330 |
}
|
336 |
$backup_data['json_info']['include_path'][]='wp-includes';
|
337 |
$backup_data['json_info']['include_path'][]='wp-admin';
|
338 |
$backup_data['json_info']['wp_core']=1;
|
339 |
+
$backup_data['json_info']['home_url']=home_url();
|
340 |
$include_regex[]='#^'.preg_quote($this -> transfer_path(get_home_path().DIRECTORY_SEPARATOR.'wp-admin'), '/').'#';
|
341 |
$include_regex[]='#^'.preg_quote($this->transfer_path(get_home_path().DIRECTORY_SEPARATOR.'wp-includes'), '/').'#';
|
342 |
$exclude_regex[]='#^'.preg_quote($this->transfer_path(get_home_path().DIRECTORY_SEPARATOR.'wp-admin'.DIRECTORY_SEPARATOR), '/').'pclzip-.*\.tmp#';
|
354 |
$backup_data['files']=array_merge($backup_data['files'],$this->get_backup_file($backup_finished_data['key']));
|
355 |
}
|
356 |
$backup_data['json_info']['has_child']=1;
|
357 |
+
$backup_data['json_info']['home_url']=home_url();
|
358 |
}
|
359 |
else
|
360 |
{
|
912 |
{
|
913 |
if($list_tasks['data']['type'] == 'upload')
|
914 |
{
|
915 |
+
if(isset($list_tasks['data']['upload_data']) && !empty($list_tasks['data']['upload_data'])) {
|
916 |
+
$descript = $list_tasks['data']['upload_data']['descript'];
|
917 |
+
$offset = $list_tasks['data']['upload_data']['offset'];
|
918 |
+
$current_size = $list_tasks['data']['upload_data']['current_size'];
|
919 |
+
$last_time = $list_tasks['data']['upload_data']['last_time'];
|
920 |
+
$last_size = $list_tasks['data']['upload_data']['last_size'];
|
921 |
+
$speed = ($offset - $last_size) / (time() - $last_time);
|
922 |
+
$speed /= 1000;
|
923 |
+
$speed = round($speed, 2);
|
924 |
+
$speed .= 'kb/s';
|
925 |
+
if(!empty($current_size)) {
|
926 |
+
$list_tasks['task_info']['total'] = size_format($current_size,2);
|
927 |
+
}
|
928 |
+
if(!empty($offset)) {
|
929 |
+
$list_tasks['task_info']['upload'] = size_format($offset, 2);
|
930 |
+
}
|
931 |
}
|
932 |
+
else{
|
933 |
+
$descript = 'Strat uploading.';
|
934 |
+
$speed = '0kb/s';
|
935 |
+
$list_tasks['task_info']['total'] = 'N/A';
|
936 |
+
$list_tasks['task_info']['upload'] = 'N/A';
|
937 |
}
|
938 |
+
|
939 |
$list_tasks['task_info']['speed'] = $speed;
|
940 |
$list_tasks['task_info']['descript'] = $descript.__(' Progress: ', 'wpvivid') . $list_tasks['task_info']['backup_percent'] . __(', running time: ', 'wpvivid') . $list_tasks['data']['running_time'];
|
941 |
|
1290 |
|
1291 |
public function check_backup_files()
|
1292 |
{
|
1293 |
+
global $wpvivid_pulgin;
|
1294 |
$ret['result']=WPVIVID_FAILED;
|
1295 |
+
$ret['error']='Unknown error.';
|
1296 |
|
1297 |
$b_has_data=false;
|
1298 |
$tmp_data=array();
|
1309 |
if($b_has_data){
|
1310 |
$b_need_download=false;
|
1311 |
$b_not_found=false;
|
1312 |
+
$b_test=false;
|
1313 |
foreach ($tmp_data as $file)
|
1314 |
{
|
1315 |
$need_download=false;
|
1316 |
$path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
|
1317 |
if(file_exists($path))
|
1318 |
{
|
1319 |
+
if(filesize($path) === $file['size']){
|
1320 |
+
if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
|
1321 |
+
$res = TRUE;
|
1322 |
+
}
|
1323 |
+
else{
|
1324 |
+
$res = FALSE;
|
1325 |
+
}
|
1326 |
+
}
|
1327 |
+
else{
|
1328 |
+
$res = FALSE;
|
1329 |
+
}
|
1330 |
+
if ($res !== TRUE)
|
1331 |
{
|
1332 |
$need_download=true;
|
|
|
1333 |
}
|
1334 |
}
|
1335 |
else
|
1336 |
{
|
1337 |
+
$b_test=true;
|
1338 |
+
$test_str=$path;
|
1339 |
$need_download=true;
|
1340 |
}
|
1341 |
|
1362 |
if($b_not_found)
|
1363 |
{
|
1364 |
$ret['result']=WPVIVID_FAILED;
|
1365 |
+
if($b_test)
|
1366 |
+
$ret['error']='Backup files doesn\'t exist. Restore failed.'.$test_str;
|
1367 |
+
else
|
1368 |
+
$ret['error']='Backup doesn\'t exist in both web server and remote storage. Restore failed.';
|
1369 |
}
|
1370 |
else if($b_need_download)
|
1371 |
{
|
1380 |
return $ret;
|
1381 |
}
|
1382 |
|
1383 |
+
public function check_migrate_file()
|
1384 |
{
|
1385 |
+
if(isset($this->config['backup']['files']))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1386 |
{
|
1387 |
+
$tmp_data = $this->config['backup']['files'];
|
1388 |
+
$zip=new WPvivid_ZipClass();
|
1389 |
|
1390 |
+
foreach ($tmp_data as $file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1391 |
{
|
1392 |
+
$path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
|
1393 |
+
if(file_exists($path))
|
1394 |
+
{
|
1395 |
+
$json=$zip->get_json_data($path);
|
1396 |
+
$json=json_decode($json,1);
|
1397 |
+
if(!is_null($json))
|
1398 |
+
{
|
1399 |
+
if(isset($json['home_url'])&&home_url()!=$json['home_url'])
|
1400 |
+
{
|
1401 |
+
return 1;
|
1402 |
+
}
|
1403 |
+
}
|
1404 |
+
}
|
1405 |
}
|
1406 |
+
|
1407 |
+
return 0;
|
1408 |
}
|
1409 |
+
else
|
1410 |
+
{
|
1411 |
+
return 0;
|
1412 |
+
}
|
1413 |
+
|
1414 |
+
}
|
1415 |
|
1416 |
public function get_local_path()
|
1417 |
{
|
1635 |
return $files[0]['file_name'];
|
1636 |
}
|
1637 |
|
1638 |
+
public static function get_backup_files($backup){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1639 |
$files=array();
|
1640 |
if(isset($backup['backup']['files'])){
|
|
|
1641 |
$files=$backup['backup']['files'];
|
1642 |
}
|
1643 |
else{
|
1644 |
if(isset($backup['backup']['ismerge'])) {
|
1645 |
if ($backup['backup']['ismerge'] == 1) {
|
1646 |
if(isset($backup['backup']['data']['meta']['files'])){
|
|
|
1647 |
$files=$backup['backup']['data']['meta']['files'];
|
1648 |
}
|
1649 |
}
|
1650 |
}
|
1651 |
}
|
1652 |
+
return $files;
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
public function get_download_backup_files($backup_id){
|
1656 |
+
$ret['result']=WPVIVID_FAILED;
|
1657 |
+
$data=array();
|
1658 |
+
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
1659 |
+
if(!$backup)
|
1660 |
+
{
|
1661 |
+
$ret['error']='Backup id not found.';
|
1662 |
+
return $ret;
|
1663 |
+
}
|
1664 |
+
|
1665 |
+
$files=array();
|
1666 |
+
$files = self::get_backup_files($backup);
|
1667 |
+
if(empty($files)){
|
1668 |
+
$ret['error']='Failed to get backup files.';
|
1669 |
+
}
|
1670 |
+
else{
|
1671 |
+
$ret['result']=WPVIVID_SUCCESS;
|
1672 |
+
$ret['files']=$files;
|
1673 |
+
}
|
1674 |
+
return $ret;
|
1675 |
+
}
|
1676 |
+
|
1677 |
+
public function get_download_progress($backup_id, $files){
|
1678 |
+
global $wpvivid_pulgin;
|
1679 |
+
$b_need_download=false;
|
1680 |
+
$b_not_found=false;
|
1681 |
+
$file_count=0;
|
1682 |
+
$file_part_num=1;
|
1683 |
+
$check_type='';
|
1684 |
+
foreach ($files as $file)
|
1685 |
+
{
|
1686 |
+
$need_download=false;
|
1687 |
+
$path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
|
1688 |
+
if(file_exists($path)) {
|
1689 |
+
if(filesize($path) === $file['size']){
|
1690 |
+
if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
|
1691 |
+
$res = TRUE;
|
1692 |
+
}
|
1693 |
+
else{
|
1694 |
+
$res = FALSE;
|
1695 |
}
|
1696 |
}
|
1697 |
+
else{
|
1698 |
+
$res = FALSE;
|
1699 |
+
}
|
1700 |
+
if ($res !== TRUE)
|
1701 |
+
{
|
1702 |
$need_download=true;
|
1703 |
}
|
1704 |
+
}
|
1705 |
+
else {
|
1706 |
+
$need_download=true;
|
1707 |
+
}
|
1708 |
+
if($file_part_num < 10){
|
1709 |
+
$format_part=sprintf("%02d", $file_part_num);
|
1710 |
+
}
|
1711 |
+
else{
|
1712 |
+
$format_part=$file_part_num;
|
1713 |
+
}
|
1714 |
+
if($need_download) {
|
1715 |
+
if(empty($this->config['remote'])) {
|
1716 |
+
$b_not_found=true;
|
1717 |
+
$ret['result'] = WPVIVID_SUCCESS;
|
1718 |
+
$ret['files'][$file['file_name']]['status']='file_not_found';
|
1719 |
}
|
1720 |
else{
|
1721 |
+
$task = WPvivid_taskmanager::get_download_task_v2($file['file_name']);
|
1722 |
+
if ($task === false) {
|
|
|
|
|
|
|
1723 |
$ret['result'] = WPVIVID_SUCCESS;
|
1724 |
+
$ret['files'][$file['file_name']]['status']='need_download';
|
1725 |
+
$ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
|
|
|
|
|
|
|
|
|
|
|
|
1726 |
<span>Part'.$format_part.'</span></br>
|
1727 |
<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>
|
1728 |
<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>
|
1729 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1730 |
</div>';
|
1731 |
+
} else {
|
1732 |
+
$ret['result'] = WPVIVID_SUCCESS;
|
1733 |
+
if($task['status'] === 'running'){
|
1734 |
+
$ret['files'][$file['file_name']]['status'] = 'running';
|
1735 |
+
$ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
1736 |
<span>Part'.$format_part.'</span></br>
|
1737 |
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
1738 |
<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>
|
1739 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1740 |
</div>';
|
1741 |
+
$ret['files'][$file['file_name']]['progress_text']=$task['progress_text'];
|
1742 |
+
}
|
1743 |
+
elseif($task['status'] === 'timeout'){
|
1744 |
+
$ret['files'][$file['file_name']]['status']='timeout';
|
1745 |
+
$ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
1746 |
<span>Part'.$format_part.'</span></br>
|
1747 |
<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>
|
1748 |
<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>
|
1749 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1750 |
</div>';
|
1751 |
+
$ret['files'][$file['file_name']]['progress_text']=$task['progress_text'];
|
1752 |
+
WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
|
1753 |
+
}
|
1754 |
+
elseif($task['status'] === 'completed'){
|
1755 |
+
$ret['files'][$file['file_name']]['status']='completed';
|
1756 |
+
$ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
1757 |
<span>Part'.$format_part.'</span></br>
|
1758 |
<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>
|
1759 |
<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>
|
1760 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1761 |
</div>';
|
1762 |
+
WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
|
1763 |
+
}
|
1764 |
+
elseif($task['status'] === 'error'){
|
1765 |
+
$ret['files'][$file['file_name']]['status']='error';
|
1766 |
+
$ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
1767 |
<span>Part'.$format_part.'</span></br>
|
1768 |
<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>
|
1769 |
<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>
|
1770 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1771 |
</div>';
|
1772 |
+
$ret['files'][$file['file_name']]['error'] = $task['error'];
|
1773 |
+
WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
|
|
|
1774 |
}
|
1775 |
}
|
1776 |
}
|
1777 |
+
}
|
1778 |
+
else{
|
1779 |
+
$ret['result'] = WPVIVID_SUCCESS;
|
1780 |
+
if(WPvivid_taskmanager::get_download_task_v2($file['file_name']))
|
1781 |
+
WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
|
1782 |
+
$ret['files'][$file['file_name']]['status']='completed';
|
1783 |
+
$ret['files'][$file['file_name']]['download_path']=$path;
|
1784 |
+
$ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
1785 |
<span>Part'.$format_part.'</span></br>
|
1786 |
<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>
|
1787 |
<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>
|
1788 |
<span>size:</span><span>'.$wpvivid_pulgin->formatBytes($file['size']).'</span>
|
1789 |
</div>';
|
|
|
|
|
|
|
|
|
1790 |
}
|
1791 |
+
$ret['files'][$file['file_name']]['size']=$wpvivid_pulgin->formatBytes($file['size']);
|
1792 |
+
$file_count++;
|
1793 |
+
$file_part_num++;
|
1794 |
+
}
|
1795 |
+
if ($file_count % 2 != 0) {
|
1796 |
+
$file_count++;
|
1797 |
+
if($file_count < 10){
|
1798 |
+
$format_part=sprintf("%02d", $file_count);
|
1799 |
+
}
|
1800 |
+
else{
|
1801 |
+
$format_part=$file_count;
|
1802 |
+
}
|
1803 |
+
$ret['place_html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px; color:#cccccc;">
|
1804 |
<span>Part'.$format_part.'</span></br>
|
1805 |
<span>Download</span></br>
|
1806 |
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
1807 |
<span>size:</span><span>0</span>
|
1808 |
</div>';
|
|
|
|
|
|
|
|
|
|
|
1809 |
}
|
1810 |
+
else{
|
1811 |
+
$ret['place_html']='';
|
1812 |
+
}
|
1813 |
+
return $ret;
|
1814 |
}
|
1815 |
|
1816 |
public function update_download_page($backup_id){
|
1817 |
+
$ret=$this->get_download_backup_files($backup_id);
|
1818 |
+
if($ret['result']==WPVIVID_SUCCESS){
|
1819 |
+
$ret=$this->get_download_progress($backup_id, $ret['files']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1820 |
WPvivid_taskmanager::update_download_cache($backup_id,$ret);
|
|
|
1821 |
}
|
1822 |
+
return $ret;
|
1823 |
}
|
1824 |
}
|
1825 |
|
1860 |
global $wpvivid_pulgin;
|
1861 |
$wpvivid_pulgin->set_time_limit($this->task->get_id());
|
1862 |
$this->task->update_sub_task_progress($next_backup['key'],0,'Start backing up '.$next_backup['key'].'.');
|
|
|
1863 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Prepare to backup '.$next_backup['key'].' files.','notice');
|
1864 |
if(isset($next_backup['files'])) {
|
1865 |
$wpvivid_pulgin->wpvivid_log->WriteLog('File number: ' . sizeof($next_backup['files']), 'notice');
|
1867 |
$result = $this->_backup($next_backup);
|
1868 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Backing up '.$next_backup['key'].' completed.','notice');
|
1869 |
$this->task->update_sub_task_progress($next_backup['key'],1,'Backing up '.$next_backup['key'].' finished.');
|
|
|
1870 |
$this->task->update_backup_result($next_backup,$result);
|
1871 |
$wpvivid_pulgin->check_cancel_backup($task_id);
|
1872 |
unset($next_backup);
|
2106 |
WPvivid_tools::clearcache($this->task->get_prefix());
|
2107 |
}
|
2108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2109 |
public function clean_remote_backup($remotes,$files)
|
2110 |
{
|
2111 |
$remote_option=array_shift($remotes);
|
2118 |
$remote ->cleanup($files);
|
2119 |
}
|
2120 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2121 |
}
|
includes/class-wpvivid-compress-default.php
CHANGED
@@ -31,6 +31,7 @@ abstract class Wpvivid_Compress_Default{
|
|
31 |
$packages[] = $files;
|
32 |
}else{
|
33 |
$sizenum = 0;
|
|
|
34 |
$size = $max_size * 1024 * 1024;
|
35 |
$package = array();
|
36 |
$flag = false;
|
31 |
$packages[] = $files;
|
32 |
}else{
|
33 |
$sizenum = 0;
|
34 |
+
$max_size = str_replace('M', '', $max_size);
|
35 |
$size = $max_size * 1024 * 1024;
|
36 |
$package = array();
|
37 |
$flag = false;
|
includes/class-wpvivid-db-method.php
CHANGED
@@ -18,7 +18,16 @@ class WPvivid_DB_Method
|
|
18 |
$extensions=get_loaded_extensions();
|
19 |
if(array_search('pdo_mysql',$extensions))
|
20 |
{
|
21 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
$this->type='pdo_mysql';
|
23 |
return;
|
24 |
}
|
@@ -220,23 +229,21 @@ class WPvivid_DB_Method
|
|
220 |
|
221 |
public function get_sql_mode()
|
222 |
{
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
{
|
227 |
-
return $ret;
|
228 |
-
}
|
229 |
-
$ret['result']=WPVIVID_SUCCESS;
|
230 |
-
$ret['mysql_mode']='';
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
$
|
235 |
-
|
236 |
-
{
|
237 |
-
$ret['mysql_mode']=$row["@@SESSION.sql_mode"];
|
238 |
}
|
239 |
}
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
return $ret;
|
242 |
}
|
18 |
$extensions=get_loaded_extensions();
|
19 |
if(array_search('pdo_mysql',$extensions))
|
20 |
{
|
21 |
+
$res = explode(':',DB_HOST);
|
22 |
+
$db_host = $res[0];
|
23 |
+
$db_port = empty($res[1])?'':$res[1];
|
24 |
+
if(!empty($db_port)) {
|
25 |
+
$dsn='mysql:host=' . $db_host . ';port=' . $db_port . ';dbname=' . DB_NAME;
|
26 |
+
}
|
27 |
+
else{
|
28 |
+
$dsn='mysql:host=' . $db_host . ';dbname=' . DB_NAME;
|
29 |
+
}
|
30 |
+
$this->db_handle=new PDO($dsn, DB_USER, DB_PASSWORD);
|
31 |
$this->type='pdo_mysql';
|
32 |
return;
|
33 |
}
|
229 |
|
230 |
public function get_sql_mode()
|
231 |
{
|
232 |
+
try {
|
233 |
+
$ret['result'] = WPVIVID_SUCCESS;
|
234 |
+
$ret['mysql_mode'] = '';
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
+
global $wpdb;
|
237 |
+
$result = $wpdb->get_results('SELECT @@SESSION.sql_mode', ARRAY_A);
|
238 |
+
foreach ($result as $row) {
|
239 |
+
$ret['mysql_mode'] = $row["@@SESSION.sql_mode"];
|
|
|
|
|
240 |
}
|
241 |
}
|
242 |
+
catch (Exception $error) {
|
243 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
244 |
+
error_log($message);
|
245 |
+
return array('result'=>'failed','error'=>$message);
|
246 |
+
}
|
247 |
|
248 |
return $ret;
|
249 |
}
|
includes/class-wpvivid-downloader.php
CHANGED
@@ -10,47 +10,6 @@ class WPvivid_downloader
|
|
10 |
{
|
11 |
private $task;
|
12 |
|
13 |
-
public function download_ex(&$task,$remotes,$file,$local_path)
|
14 |
-
{
|
15 |
-
$this->task=$task;
|
16 |
-
|
17 |
-
$remote_option=array_shift($remotes);
|
18 |
-
|
19 |
-
if(is_null($remote_option))
|
20 |
-
{
|
21 |
-
return array('result' => WPVIVID_FAILED ,'error'=>'Retrieving the cloud storage information failed while downloading backups. Please try again later.');
|
22 |
-
}
|
23 |
-
|
24 |
-
global $wpvivid_pulgin;
|
25 |
-
|
26 |
-
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote_option);
|
27 |
-
|
28 |
-
$ret=$remote->download($file,$local_path,array($this,'download_callback'));
|
29 |
-
|
30 |
-
if($ret['result']==WPVIVID_SUCCESS)
|
31 |
-
{
|
32 |
-
$progress=100;
|
33 |
-
//WPvivid_taskmanager::update_download_task( $task,$progress,$file['file_name'],'completed');
|
34 |
-
WPvivid_taskmanager::update_download_task_v2( $task,$progress,'completed');
|
35 |
-
return $ret;
|
36 |
-
}
|
37 |
-
else
|
38 |
-
{
|
39 |
-
$progress=0;
|
40 |
-
$message=$ret['error'];
|
41 |
-
//WPvivid_taskmanager::update_download_task($task,$progress,$file['file_name'],'error',$message);
|
42 |
-
WPvivid_taskmanager::update_download_task_v2($task,$progress,'error',$message);
|
43 |
-
return $ret;
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
public function download_callback($offset,$current_name,$current_size,$last_time,$last_size)
|
48 |
-
{
|
49 |
-
$progress= floor(($offset/$current_size)* 100) ;
|
50 |
-
//WPvivid_taskmanager::update_download_task( $this->task,$progress,$current_name,'running');
|
51 |
-
WPvivid_taskmanager::update_download_task_v2($this->task,$progress,'running');
|
52 |
-
}
|
53 |
-
|
54 |
public function ready_download($download_info)
|
55 |
{
|
56 |
$files=array();
|
@@ -137,7 +96,7 @@ class WPvivid_downloader
|
|
137 |
}
|
138 |
else
|
139 |
{
|
140 |
-
if(WPvivid_taskmanager::
|
141 |
{
|
142 |
global $wpvivid_pulgin;
|
143 |
$wpvivid_pulgin->wpvivid_log->WriteLog('has a downloading task,exit download.','test');
|
@@ -165,386 +124,17 @@ class WPvivid_downloader
|
|
165 |
return true;
|
166 |
}
|
167 |
|
168 |
-
public function
|
169 |
-
{
|
170 |
-
$files=array();
|
171 |
-
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
172 |
-
if(!$backup)
|
173 |
-
{
|
174 |
-
return array('result' => WPVIVID_FAILED ,'error'=>'backup not found');
|
175 |
-
}
|
176 |
-
$download_option='';
|
177 |
-
if($backup['backup']['ismerge']==1)
|
178 |
-
{
|
179 |
-
$backup_files=$backup['backup']['data']['meta']['files'];
|
180 |
-
foreach ($backup_files as $file)
|
181 |
-
{
|
182 |
-
if($file['file_name']==$file_name)
|
183 |
-
{
|
184 |
-
$download_option='all';
|
185 |
-
$files[]=$file;
|
186 |
-
break;
|
187 |
-
}
|
188 |
-
}
|
189 |
-
}
|
190 |
-
else
|
191 |
-
{
|
192 |
-
foreach ($backup['backup']['data']['type'] as $type)
|
193 |
-
{
|
194 |
-
$backup_files=$type['files'];
|
195 |
-
foreach ($backup_files as $file)
|
196 |
-
{
|
197 |
-
if($file['file_name']==$file_name)
|
198 |
-
{
|
199 |
-
$download_option=$type['type_name'];
|
200 |
-
$files[]=$file;
|
201 |
-
break;
|
202 |
-
}
|
203 |
-
}
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
if(empty($files))
|
208 |
-
return array('result' => WPVIVID_FAILED ,'error'=>'file not found');
|
209 |
-
|
210 |
-
$local_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backup['local']['path'].DIRECTORY_SEPARATOR;
|
211 |
-
$need_download_files=array();
|
212 |
-
foreach ($files as $file)
|
213 |
-
{
|
214 |
-
$local_file=$local_path.$file['file_name'];
|
215 |
-
if(file_exists($local_file))
|
216 |
-
{
|
217 |
-
if(filesize($local_file)==$file['size'])
|
218 |
-
{
|
219 |
-
$new_md5=md5_file($local_file);
|
220 |
-
if($file['md5']!=$new_md5)
|
221 |
-
{
|
222 |
-
$need_download_files[$file['file_name']]=$file;
|
223 |
-
unlink($local_file);
|
224 |
-
}
|
225 |
-
}
|
226 |
-
else
|
227 |
-
{
|
228 |
-
if(filesize($local_file)>$file['size'])
|
229 |
-
{
|
230 |
-
unlink($local_file);
|
231 |
-
}
|
232 |
-
$need_download_files[$file['file_name']]=$file;
|
233 |
-
}
|
234 |
-
}
|
235 |
-
else
|
236 |
-
{
|
237 |
-
$need_download_files[$file['file_name']]=$file;
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
if(empty($need_download_files))
|
242 |
-
{
|
243 |
-
return array('result' => WPVIVID_FAILED ,'error'=>'backup not found');
|
244 |
-
}
|
245 |
-
else
|
246 |
-
{
|
247 |
-
if(WPvivid_taskmanager::is_download_task_running($backup_id,$download_option,$file_name))
|
248 |
-
{
|
249 |
-
return array('result' => WPVIVID_FAILED ,'error'=>'download already started');
|
250 |
-
}
|
251 |
-
else
|
252 |
-
{
|
253 |
-
$task=WPvivid_taskmanager::new_download_task($backup_id,$download_option,$need_download_files);
|
254 |
-
}
|
255 |
-
|
256 |
-
return $this->download_ex($task,$backup['remote'],$need_download_files[$file_name],$local_path);
|
257 |
-
}
|
258 |
-
}
|
259 |
-
|
260 |
-
public static function delete($remote , $files)
|
261 |
-
{
|
262 |
-
global $wpvivid_pulgin;
|
263 |
-
|
264 |
-
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote);
|
265 |
-
|
266 |
-
$result =$remote->cleanup($files);
|
267 |
-
|
268 |
-
return $result;
|
269 |
-
}
|
270 |
-
|
271 |
-
public static function check_restore_file($backup_id,$restore_options)
|
272 |
-
{
|
273 |
-
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
274 |
-
if($backup===false)
|
275 |
-
{
|
276 |
-
$ret['result']='failed';
|
277 |
-
$ret['error']='Retrieving the backup information failed while downloading backups. Please try again later.';
|
278 |
-
|
279 |
-
return $ret;
|
280 |
-
}
|
281 |
-
|
282 |
-
$download_dir=$backup['local']['path'];
|
283 |
-
$remotes=$backup['remote'];
|
284 |
-
|
285 |
-
if($backup['backup']['data']['ismerge']==1)
|
286 |
-
{
|
287 |
-
$files=$backup['backup']['data']['meta']['files'];
|
288 |
-
$file_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR;
|
289 |
-
|
290 |
-
$ret=self::check_files_download_status($files,$file_path,$remotes);
|
291 |
-
if($ret['result']=='failed')
|
292 |
-
{
|
293 |
-
return $ret;
|
294 |
-
}
|
295 |
-
|
296 |
-
self::extract_package($files,$download_dir);
|
297 |
-
|
298 |
-
foreach ($restore_options as $type=>$option)
|
299 |
-
{
|
300 |
-
$files = array();
|
301 |
-
foreach ($backup['backup']['data']['type'] as $backup_type)
|
302 |
-
{
|
303 |
-
if ($backup_type['type_name'] == $option)
|
304 |
-
{
|
305 |
-
$files = $backup_type['files'];
|
306 |
-
break;
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
$ret=self::check_files_status($files,$file_path);
|
311 |
-
if($ret['result']=='failed')
|
312 |
-
{
|
313 |
-
return $ret;
|
314 |
-
}
|
315 |
-
}
|
316 |
-
}
|
317 |
-
else
|
318 |
-
{
|
319 |
-
foreach ($restore_options as $type=>$option)
|
320 |
-
{
|
321 |
-
$files = array();
|
322 |
-
foreach ($backup['backup']['data']['type'] as $backup_type)
|
323 |
-
{
|
324 |
-
if ($backup_type['type_name'] == $option)
|
325 |
-
{
|
326 |
-
$files = $backup_type['files'];
|
327 |
-
break;
|
328 |
-
}
|
329 |
-
}
|
330 |
-
|
331 |
-
$file_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR;
|
332 |
-
$ret=self::check_files_download_status($files,$file_path,$remotes);
|
333 |
-
if($ret['result']=='failed')
|
334 |
-
{
|
335 |
-
return $ret;
|
336 |
-
}
|
337 |
-
}
|
338 |
-
}
|
339 |
-
|
340 |
-
$ret['result']='success';
|
341 |
-
return $ret;
|
342 |
-
}
|
343 |
-
|
344 |
-
public static function extract_package($files,$path)
|
345 |
-
{
|
346 |
-
|
347 |
-
}
|
348 |
-
|
349 |
-
public static function check_files_download_status($files,$path,$remotes,$task_id='0')
|
350 |
-
{
|
351 |
-
foreach ($files as $file)
|
352 |
-
{
|
353 |
-
$need_download=false;
|
354 |
-
$download_path=$path.$file['file_name'];
|
355 |
-
if(file_exists($download_path))
|
356 |
-
{
|
357 |
-
if(filesize($download_path)==$file['size'])
|
358 |
-
{
|
359 |
-
$new_md5=md5_file($download_path);
|
360 |
-
if($file['md5']!=$new_md5)
|
361 |
-
{
|
362 |
-
$need_download=true;
|
363 |
-
unlink($download_path);
|
364 |
-
}
|
365 |
-
}
|
366 |
-
else
|
367 |
-
{
|
368 |
-
if(filesize($download_path)>$file['size'])
|
369 |
-
{
|
370 |
-
unlink($download_path);
|
371 |
-
}
|
372 |
-
$need_download=true;
|
373 |
-
}
|
374 |
-
}
|
375 |
-
else
|
376 |
-
{
|
377 |
-
$need_download=true;
|
378 |
-
}
|
379 |
-
|
380 |
-
if($need_download)
|
381 |
-
{
|
382 |
-
foreach ($remotes as $remote)
|
383 |
-
{
|
384 |
-
$download_ret=self::download($remote,$file,$download_path,$task_id);
|
385 |
-
if($download_ret['result']==WPVIVID_SUCCESS)
|
386 |
-
{
|
387 |
-
$need_download=false;
|
388 |
-
break;
|
389 |
-
}
|
390 |
-
}
|
391 |
-
}
|
392 |
-
|
393 |
-
if($need_download)
|
394 |
-
{
|
395 |
-
if(empty($download_ret))
|
396 |
-
{
|
397 |
-
$ret['result']='failed';
|
398 |
-
$ret['error']='Downloading '.$file.' from the remote storages failed. '.$file.' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.';
|
399 |
-
}
|
400 |
-
else
|
401 |
-
{
|
402 |
-
$ret=$download_ret;
|
403 |
-
}
|
404 |
-
return $ret;
|
405 |
-
}
|
406 |
-
}
|
407 |
-
|
408 |
-
$ret['result']='success';
|
409 |
-
return $ret;
|
410 |
-
}
|
411 |
-
|
412 |
-
public static function check_files_status($files,$path)
|
413 |
-
{
|
414 |
-
foreach ($files as $file)
|
415 |
-
{
|
416 |
-
$file_path=$path.$file['file_name'];
|
417 |
-
if(file_exists($file_path))
|
418 |
-
{
|
419 |
-
$new_md5=md5_file($file_path);
|
420 |
-
if($file['md5']!=$new_md5)
|
421 |
-
{
|
422 |
-
$ret['result']='failed';
|
423 |
-
$ret['error']='MD5 doesn\'t match. Please try to download the backup again.';
|
424 |
-
return $ret;
|
425 |
-
}
|
426 |
-
}
|
427 |
-
else
|
428 |
-
{
|
429 |
-
$ret['result']='failed';
|
430 |
-
$ret['error']='File is not found. Please try to download the backup again.';
|
431 |
-
return $ret;
|
432 |
-
}
|
433 |
-
}
|
434 |
-
$ret['result']='success';
|
435 |
-
return $ret;
|
436 |
-
}
|
437 |
-
|
438 |
-
public static function check_restore_files_status($files,$path,$remote)
|
439 |
-
{
|
440 |
-
$ret['files']=array();
|
441 |
-
foreach ($files as $file)
|
442 |
-
{
|
443 |
-
$need_download=false;
|
444 |
-
$download_path=$path.$file['file_name'];
|
445 |
-
if(file_exists($download_path))
|
446 |
-
{
|
447 |
-
$new_md5=md5_file($download_path);
|
448 |
-
if($file['md5']!=$new_md5)
|
449 |
-
{
|
450 |
-
$need_download=true;
|
451 |
-
@unlink($download_path);
|
452 |
-
}
|
453 |
-
}
|
454 |
-
else
|
455 |
-
{
|
456 |
-
$need_download=true;
|
457 |
-
}
|
458 |
-
|
459 |
-
if($need_download)
|
460 |
-
{
|
461 |
-
if($remote)
|
462 |
-
{
|
463 |
-
WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
|
464 |
-
$ret['files'][$file['file_name']]['status']='need_download';
|
465 |
-
$ret['files'][$file['file_name']]['size']=$file['size'];
|
466 |
-
$ret['files'][$file['file_name']]['md5']=$file['md5'];
|
467 |
-
}
|
468 |
-
else
|
469 |
-
{
|
470 |
-
$ret['files'][$file['file_name']]['status']='file_not_found';
|
471 |
-
$ret['files'][$file['file_name']]['size']=$file['size'];
|
472 |
-
$ret['files'][$file['file_name']]['md5']=$file['md5'];
|
473 |
-
}
|
474 |
-
}
|
475 |
-
else
|
476 |
-
{
|
477 |
-
$ret['files'][$file['file_name']]['status']='file_exist';
|
478 |
-
$ret['files'][$file['file_name']]['size']=$file['size'];
|
479 |
-
$ret['files'][$file['file_name']]['md5']=$file['md5'];
|
480 |
-
}
|
481 |
-
}
|
482 |
-
|
483 |
-
$b_need_download=false;
|
484 |
-
$b_not_found=false;
|
485 |
-
foreach ($ret['files'] as $file)
|
486 |
-
{
|
487 |
-
if($file['status']=='need_download')
|
488 |
-
{
|
489 |
-
$b_need_download=true;
|
490 |
-
}
|
491 |
-
else if($file['status']=='file_not_found')
|
492 |
-
{
|
493 |
-
$b_not_found=true;
|
494 |
-
break;
|
495 |
-
}
|
496 |
-
}
|
497 |
-
|
498 |
-
if($b_not_found)
|
499 |
-
{
|
500 |
-
$ret['result']='file_not_found';
|
501 |
-
}
|
502 |
-
else if($b_need_download)
|
503 |
-
{
|
504 |
-
$ret['result']='need_download';
|
505 |
-
}
|
506 |
-
else
|
507 |
-
{
|
508 |
-
$ret['result']='success';
|
509 |
-
}
|
510 |
-
|
511 |
-
return $ret;
|
512 |
-
}
|
513 |
-
|
514 |
-
public function download($file,$path,$remote_option)
|
515 |
{
|
516 |
-
$
|
517 |
-
|
518 |
-
$local_file=$local_path.$file['file_name'];
|
519 |
|
520 |
-
|
521 |
-
{
|
522 |
-
return array('result' => WPVIVID_FAILED ,'error'=>'download already started');
|
523 |
-
}
|
524 |
|
525 |
-
if(
|
526 |
{
|
527 |
-
|
528 |
-
{
|
529 |
-
$new_md5=md5_file($local_file);
|
530 |
-
if($file['md5']!=$new_md5)
|
531 |
-
{
|
532 |
-
@unlink($local_file);
|
533 |
-
}
|
534 |
-
else
|
535 |
-
{
|
536 |
-
return array('result' => WPVIVID_SUCCESS);
|
537 |
-
}
|
538 |
-
}
|
539 |
-
else
|
540 |
-
{
|
541 |
-
@unlink($local_file);
|
542 |
-
}
|
543 |
}
|
544 |
|
545 |
-
$task=WPvivid_taskmanager::new_download_task_v2($file['file_name']);
|
546 |
-
$this->task=$task;
|
547 |
-
|
548 |
global $wpvivid_pulgin;
|
549 |
|
550 |
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote_option);
|
@@ -554,6 +144,7 @@ class WPvivid_downloader
|
|
554 |
if($ret['result']==WPVIVID_SUCCESS)
|
555 |
{
|
556 |
$progress=100;
|
|
|
557 |
WPvivid_taskmanager::update_download_task_v2( $task,$progress,'completed');
|
558 |
return $ret;
|
559 |
}
|
@@ -561,6 +152,20 @@ class WPvivid_downloader
|
|
561 |
{
|
562 |
$progress=0;
|
563 |
$message=$ret['error'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
564 |
WPvivid_taskmanager::update_download_task_v2($task,$progress,'error',$message);
|
565 |
return $ret;
|
566 |
}
|
@@ -568,8 +173,24 @@ class WPvivid_downloader
|
|
568 |
|
569 |
public function download_callback_v2($offset,$current_name,$current_size,$last_time,$last_size)
|
570 |
{
|
|
|
571 |
$progress= floor(($offset/$current_size)* 100) ;
|
572 |
$text='Total size:'.size_format($current_size,2).' downloaded:'.size_format($offset,2);
|
573 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
574 |
}
|
575 |
}
|
10 |
{
|
11 |
private $task;
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
public function ready_download($download_info)
|
14 |
{
|
15 |
$files=array();
|
96 |
}
|
97 |
else
|
98 |
{
|
99 |
+
if(WPvivid_taskmanager::is_download_task_running_v2($download_info['file_name']))
|
100 |
{
|
101 |
global $wpvivid_pulgin;
|
102 |
$wpvivid_pulgin->wpvivid_log->WriteLog('has a downloading task,exit download.','test');
|
124 |
return true;
|
125 |
}
|
126 |
|
127 |
+
public function download_ex(&$task,$remotes,$file,$local_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
{
|
129 |
+
$this->task=$task;
|
|
|
|
|
130 |
|
131 |
+
$remote_option=array_shift($remotes);
|
|
|
|
|
|
|
132 |
|
133 |
+
if(is_null($remote_option))
|
134 |
{
|
135 |
+
return array('result' => WPVIVID_FAILED ,'error'=>'Retrieving the cloud storage information failed while downloading backups. Please try again later.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
|
|
|
|
|
|
|
138 |
global $wpvivid_pulgin;
|
139 |
|
140 |
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote_option);
|
144 |
if($ret['result']==WPVIVID_SUCCESS)
|
145 |
{
|
146 |
$progress=100;
|
147 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Download completed.', 'notice');
|
148 |
WPvivid_taskmanager::update_download_task_v2( $task,$progress,'completed');
|
149 |
return $ret;
|
150 |
}
|
152 |
{
|
153 |
$progress=0;
|
154 |
$message=$ret['error'];
|
155 |
+
if($wpvivid_pulgin->wpvivid_download_log){
|
156 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Download failed, ' . $message ,'error');
|
157 |
+
WPvivid_error_log::create_error_log($wpvivid_pulgin->wpvivid_download_log->log_file);
|
158 |
+
$wpvivid_pulgin->wpvivid_download_log->CloseFile();
|
159 |
+
}
|
160 |
+
else {
|
161 |
+
$id = uniqid('wpvivid-');
|
162 |
+
$log_file_name = $id . '_download';
|
163 |
+
$log = new WPvivid_Log();
|
164 |
+
$log->CreateLogFile($log_file_name, 'no_folder', 'download');
|
165 |
+
$log->WriteLog($message, 'notice');
|
166 |
+
WPvivid_error_log::create_error_log($log->log_file);
|
167 |
+
$log->CloseFile();
|
168 |
+
}
|
169 |
WPvivid_taskmanager::update_download_task_v2($task,$progress,'error',$message);
|
170 |
return $ret;
|
171 |
}
|
173 |
|
174 |
public function download_callback_v2($offset,$current_name,$current_size,$last_time,$last_size)
|
175 |
{
|
176 |
+
global $wpvivid_pulgin;
|
177 |
$progress= floor(($offset/$current_size)* 100) ;
|
178 |
$text='Total size:'.size_format($current_size,2).' downloaded:'.size_format($offset,2);
|
179 |
+
$this->task['download_descript']=$text;
|
180 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Total Size: '.$current_size.', Downloaded Size: '.$offset ,'notice');
|
181 |
+
WPvivid_taskmanager::update_download_task_v2( $this->task,$progress,'running');
|
182 |
+
}
|
183 |
+
|
184 |
+
public static function delete($remote , $files)
|
185 |
+
{
|
186 |
+
global $wpvivid_pulgin;
|
187 |
+
|
188 |
+
set_time_limit(60);
|
189 |
+
|
190 |
+
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote);
|
191 |
+
|
192 |
+
$result =$remote->cleanup($files);
|
193 |
+
|
194 |
+
return $result;
|
195 |
}
|
196 |
}
|
includes/class-wpvivid-migrate.php
CHANGED
@@ -21,8 +21,6 @@ class WPvivid_Migrate
|
|
21 |
add_action('wp_ajax_wpvivid_list_upload_tasks',array( $this,'list_tasks'));
|
22 |
add_action('wp_ajax_wpvivid_test_connect_site',array( $this,'test_connect_site'));
|
23 |
add_action('wp_ajax_wpvivid_delete_transfer_key',array($this, 'delete_transfer_key'));
|
24 |
-
add_action('wp_ajax_wpvivid_delete_transfer_backup', array($this, 'delete_transfer_backup'));
|
25 |
-
add_action('wp_ajax_wpvivid_delete_transfer_backup_array', array($this, 'delete_transfer_backup_array'));
|
26 |
|
27 |
add_filter('wpvivid_put_transfer_key', array($this, 'wpvivid_put_transfer_key'));
|
28 |
add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_handle_backup_failed'),9);
|
@@ -137,13 +135,15 @@ class WPvivid_Migrate
|
|
137 |
else
|
138 |
{
|
139 |
$ret['result']=WPVIVID_FAILED;
|
140 |
-
$ret['error']= '
|
|
|
141 |
}
|
142 |
}
|
143 |
else
|
144 |
{
|
145 |
$ret['result']=WPVIVID_FAILED;
|
146 |
$ret['error']= 'upload error '.$response['response']['code'].' '.$response['body'];
|
|
|
147 |
}
|
148 |
}
|
149 |
|
@@ -162,117 +162,6 @@ class WPvivid_Migrate
|
|
162 |
die();
|
163 |
}
|
164 |
|
165 |
-
public function delete_transfer_backup(){
|
166 |
-
global $wpvivid_pulgin;
|
167 |
-
$wpvivid_pulgin->ajax_check_security();
|
168 |
-
if(isset($_POST['backup_id'])&&!empty($_POST['backup_id'])&&is_string($_POST['backup_id'])&&isset($_POST['force']))
|
169 |
-
{
|
170 |
-
if($_POST['force']==0||$_POST['force']==1)
|
171 |
-
{
|
172 |
-
$force_del=$_POST['force'];
|
173 |
-
}
|
174 |
-
else
|
175 |
-
{
|
176 |
-
$force_del=0;
|
177 |
-
}
|
178 |
-
$backup_id=sanitize_key($_POST['backup_id']);
|
179 |
-
|
180 |
-
$ret=$wpvivid_pulgin->delete_backup_by_id($backup_id, $force_del);
|
181 |
-
$html = '';
|
182 |
-
$html = apply_filters('wpvivid_add_backup_list', $html);
|
183 |
-
$ret['html'] = $html;
|
184 |
-
echo json_encode($ret);
|
185 |
-
}
|
186 |
-
|
187 |
-
die();
|
188 |
-
}
|
189 |
-
|
190 |
-
public function delete_transfer_backup_array(){
|
191 |
-
global $wpvivid_pulgin;
|
192 |
-
$wpvivid_pulgin->ajax_check_security();
|
193 |
-
if(isset($_POST['backup_id'])&&!empty($_POST['backup_id'])&&is_array($_POST['backup_id']))
|
194 |
-
{
|
195 |
-
$backup_ids=$_POST['backup_id'];
|
196 |
-
$ret=array();
|
197 |
-
foreach($backup_ids as $backup_id)
|
198 |
-
{
|
199 |
-
$backup_id=sanitize_key($backup_id);
|
200 |
-
$ret=$wpvivid_pulgin->delete_backup_by_id($backup_id);
|
201 |
-
}
|
202 |
-
$html = '';
|
203 |
-
$html = apply_filters('wpvivid_add_backup_list', $html);
|
204 |
-
$ret['html'] = $html;
|
205 |
-
echo json_encode($ret);
|
206 |
-
}
|
207 |
-
|
208 |
-
die();
|
209 |
-
}
|
210 |
-
|
211 |
-
public function upload($task_id)
|
212 |
-
{
|
213 |
-
$task=WPvivid_taskmanager::get_task($task_id);
|
214 |
-
|
215 |
-
if($task===false)
|
216 |
-
{
|
217 |
-
$ret['result']=WPVIVID_FAILED;
|
218 |
-
$ret['error']='Task id not found';
|
219 |
-
echo json_encode($ret);
|
220 |
-
die();
|
221 |
-
}
|
222 |
-
|
223 |
-
global $wpvivid_pulgin;
|
224 |
-
$log_file_name=uniqid('test-');
|
225 |
-
$wpvivid_pulgin->wpvivid_log=new WPvivid_Log();
|
226 |
-
$wpvivid_pulgin->wpvivid_log->CreateLogFile($log_file_name,'no_folder','test');
|
227 |
-
|
228 |
-
$ret['result']='success';
|
229 |
-
$ret['task_id']=$task_id;
|
230 |
-
$json=json_encode($ret);
|
231 |
-
header('Content-Length: '.strlen($json));
|
232 |
-
header('Connection: close');
|
233 |
-
header('Content-Encoding: none');
|
234 |
-
|
235 |
-
if (session_id())
|
236 |
-
session_write_close();
|
237 |
-
echo $json;
|
238 |
-
|
239 |
-
if(function_exists('fastcgi_finish_request'))
|
240 |
-
{
|
241 |
-
fastcgi_finish_request();
|
242 |
-
}
|
243 |
-
else
|
244 |
-
{
|
245 |
-
ob_flush();
|
246 |
-
flush();
|
247 |
-
}
|
248 |
-
|
249 |
-
include_once WPVIVID_PLUGIN_DIR . '/addons/class-wpvivid-upload.php';
|
250 |
-
|
251 |
-
$upload=new WPvivid_Upload();
|
252 |
-
|
253 |
-
set_time_limit(900);
|
254 |
-
|
255 |
-
$backup=WPvivid_taskmanager::get_task_options($task_id,'backup');
|
256 |
-
$remote_options=WPvivid_taskmanager::get_task_options($task_id,'remote_options');
|
257 |
-
$remote_option=array_shift($remote_options);
|
258 |
-
$this->add_monitor_event($task_id);
|
259 |
-
|
260 |
-
$ret=$upload->upload($task_id,$backup,$remote_option);
|
261 |
-
if($ret['result']==WPVIVID_SUCCESS)
|
262 |
-
{
|
263 |
-
$timestamp =wp_next_scheduled(WPVIVID_UPLOAD_TASK_MONITOR_EVENT,array($task_id));
|
264 |
-
if($timestamp!==false)
|
265 |
-
{
|
266 |
-
wp_unschedule_event($timestamp,WPVIVID_UPLOAD_TASK_MONITOR_EVENT,array($task_id));
|
267 |
-
}
|
268 |
-
|
269 |
-
if(!array_key_exists('temp',$remote_options))
|
270 |
-
{
|
271 |
-
WPvivid_Backuplist::update_backup($_POST['backup_id'],'remote',$remote_options);
|
272 |
-
}
|
273 |
-
}
|
274 |
-
}
|
275 |
-
|
276 |
public function send_backup_to_site()
|
277 |
{
|
278 |
try {
|
21 |
add_action('wp_ajax_wpvivid_list_upload_tasks',array( $this,'list_tasks'));
|
22 |
add_action('wp_ajax_wpvivid_test_connect_site',array( $this,'test_connect_site'));
|
23 |
add_action('wp_ajax_wpvivid_delete_transfer_key',array($this, 'delete_transfer_key'));
|
|
|
|
|
24 |
|
25 |
add_filter('wpvivid_put_transfer_key', array($this, 'wpvivid_put_transfer_key'));
|
26 |
add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_handle_backup_failed'),9);
|
135 |
else
|
136 |
{
|
137 |
$ret['result']=WPVIVID_FAILED;
|
138 |
+
$ret['error']= $response['body'];
|
139 |
+
//$ret['error']= 'failed to parse returned data. Unable to retrieve the correct authorization data via HTTP request.';
|
140 |
}
|
141 |
}
|
142 |
else
|
143 |
{
|
144 |
$ret['result']=WPVIVID_FAILED;
|
145 |
$ret['error']= 'upload error '.$response['response']['code'].' '.$response['body'];
|
146 |
+
//$response['body']
|
147 |
}
|
148 |
}
|
149 |
|
162 |
die();
|
163 |
}
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
public function send_backup_to_site()
|
166 |
{
|
167 |
try {
|
includes/class-wpvivid-mysqldump-method.php
CHANGED
@@ -482,7 +482,15 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
482 |
|
483 |
public function connect($host,$dbname,$user,$pass,$init_commands=array())
|
484 |
{
|
485 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
$this->user=$user;
|
487 |
$this->pass=$pass;
|
488 |
$this->dbHandler = @new PDO(
|
482 |
|
483 |
public function connect($host,$dbname,$user,$pass,$init_commands=array())
|
484 |
{
|
485 |
+
$res = explode(':',DB_HOST);
|
486 |
+
$db_host = $res[0];
|
487 |
+
$db_port = empty($res[1])?'':$res[1];
|
488 |
+
if(!empty($db_port)) {
|
489 |
+
$this->dsn='mysql:host=' . $db_host . ';port=' . $db_port . ';dbname=' . $dbname;
|
490 |
+
}
|
491 |
+
else{
|
492 |
+
$this->dsn='mysql:host=' . $db_host . ';dbname=' . $dbname;
|
493 |
+
}
|
494 |
$this->user=$user;
|
495 |
$this->pass=$pass;
|
496 |
$this->dbHandler = @new PDO(
|
includes/class-wpvivid-mysqldump.php
CHANGED
@@ -562,9 +562,9 @@ class WPvivid_Mysqldump
|
|
562 |
if($this->task_id!=='')
|
563 |
{
|
564 |
$options_name[]='backup_options';
|
565 |
-
|
566 |
$options=WPvivid_taskmanager::get_task_options($this->task_id,$options_name);
|
567 |
-
if($options['ismerge'])
|
568 |
{
|
569 |
if(isset($options['backup_options']['backup']['backup_type'])) {
|
570 |
$i_step = intval(1 / (sizeof($options['backup_options']['backup']['backup_type']) + 1) * 100);
|
562 |
if($this->task_id!=='')
|
563 |
{
|
564 |
$options_name[]='backup_options';
|
565 |
+
//$options_name[]='ismerge';
|
566 |
$options=WPvivid_taskmanager::get_task_options($this->task_id,$options_name);
|
567 |
+
if($options['backup_options']['ismerge'])
|
568 |
{
|
569 |
if(isset($options['backup_options']['backup']['backup_type'])) {
|
570 |
$i_step = intval(1 / (sizeof($options['backup_options']['backup']['backup_type']) + 1) * 100);
|
includes/class-wpvivid-restore-data.php
CHANGED
@@ -133,6 +133,7 @@ class WPvivid_restore_data
|
|
133 |
foreach ($packages as $index=>$package)
|
134 |
{
|
135 |
$data['restore_tasks'][$index]['files']=$package['files'];
|
|
|
136 |
$data['restore_tasks'][$index]['status']=WPVIVID_RESTORE_WAIT;
|
137 |
$data['restore_tasks'][$index]['result']=array();
|
138 |
$data['restore_tasks'][$index]['option']=array();
|
@@ -511,28 +512,26 @@ class WPvivid_restore_data
|
|
511 |
$this->restore_cache=WPvivid_tools::file_get_array($this->restore_data_file);
|
512 |
}
|
513 |
|
514 |
-
$
|
515 |
-
$this->restore_cache['restore_tasks'][$task_index]['status']=$result['result'];
|
516 |
-
$this->restore_cache['data'][$task_index]['time']['end'] = time();
|
517 |
-
WPvivid_tools::file_put_array($this->restore_cache,$this->restore_data_file);
|
518 |
-
}
|
519 |
-
|
520 |
-
public function update_sub_task_completed($task_type,$return,$table=array())
|
521 |
-
{
|
522 |
-
if($this->restore_cache===false)
|
523 |
{
|
524 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
}
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
$this->restore_cache['status'] = WPVIVID_RESTORE_RUNNING;
|
531 |
-
if(!empty($table)){
|
532 |
-
$this->restore_cache['data'][$task_type]['table']['succeed'] = empty($table['succeed'])?0:$table['succeed'];
|
533 |
-
$this->restore_cache['data'][$task_type]['table']['failed'] = empty($table['failed'])?0:$table['failed'];
|
534 |
-
$this->restore_cache['data'][$task_type]['table']['unfinished'] = empty($table['unfinished'])?0:$table['unfinished'];
|
535 |
}
|
|
|
|
|
536 |
WPvivid_tools::file_put_array($this->restore_cache,$this->restore_data_file);
|
537 |
}
|
538 |
|
@@ -565,4 +564,32 @@ class WPvivid_restore_data
|
|
565 |
$rollback_data['data'][$type_name]['data'] = $data;
|
566 |
WPvivid_tools::file_put_array($rollback_data,$this->rollback_file);
|
567 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
}
|
133 |
foreach ($packages as $index=>$package)
|
134 |
{
|
135 |
$data['restore_tasks'][$index]['files']=$package['files'];
|
136 |
+
$data['restore_tasks'][$index]['unzip_files']=array();
|
137 |
$data['restore_tasks'][$index]['status']=WPVIVID_RESTORE_WAIT;
|
138 |
$data['restore_tasks'][$index]['result']=array();
|
139 |
$data['restore_tasks'][$index]['option']=array();
|
512 |
$this->restore_cache=WPvivid_tools::file_get_array($this->restore_data_file);
|
513 |
}
|
514 |
|
515 |
+
if($result['result']==WPVIVID_SUCCESS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
{
|
517 |
+
$files=$this->get_need_unzip_file($this->restore_cache['restore_tasks'][$task_index]);
|
518 |
+
if(empty($files))
|
519 |
+
{
|
520 |
+
$this->restore_cache['restore_tasks'][$task_index]['result']=$result;
|
521 |
+
$this->restore_cache['restore_tasks'][$task_index]['status']=$result['result'];
|
522 |
+
}
|
523 |
+
else {
|
524 |
+
$this->restore_cache['restore_tasks'][$task_index]['result']=$result;
|
525 |
+
$this->restore_cache['restore_tasks'][$task_index]['status']=WPVIVID_RESTORE_WAIT;
|
526 |
+
}
|
527 |
}
|
528 |
+
else
|
529 |
+
{
|
530 |
+
$this->restore_cache['restore_tasks'][$task_index]['result']=$result;
|
531 |
+
$this->restore_cache['restore_tasks'][$task_index]['status']=$result['result'];
|
|
|
|
|
|
|
|
|
|
|
532 |
}
|
533 |
+
|
534 |
+
$this->restore_cache['data'][$task_index]['time']['end'] = time();
|
535 |
WPvivid_tools::file_put_array($this->restore_cache,$this->restore_data_file);
|
536 |
}
|
537 |
|
564 |
$rollback_data['data'][$type_name]['data'] = $data;
|
565 |
WPvivid_tools::file_put_array($rollback_data,$this->rollback_file);
|
566 |
}
|
567 |
+
|
568 |
+
public function get_need_unzip_file($restore_task)
|
569 |
+
{
|
570 |
+
$files=array();
|
571 |
+
foreach ($restore_task['files'] as $file)
|
572 |
+
{
|
573 |
+
if(in_array($file,$restore_task['unzip_files']))
|
574 |
+
{
|
575 |
+
continue;
|
576 |
+
}
|
577 |
+
else
|
578 |
+
{
|
579 |
+
$files[]=$file;
|
580 |
+
return $files;
|
581 |
+
}
|
582 |
+
}
|
583 |
+
return $files;
|
584 |
+
}
|
585 |
+
|
586 |
+
public function update_need_unzip_file($task_index,$files)
|
587 |
+
{
|
588 |
+
if($this->restore_cache===false)
|
589 |
+
{
|
590 |
+
$this->restore_cache=WPvivid_tools::file_get_array($this->restore_data_file);
|
591 |
+
}
|
592 |
+
$this->restore_cache['restore_tasks'][$task_index]['unzip_files']=array_merge($this->restore_cache['restore_tasks'][$task_index]['unzip_files'],$files);
|
593 |
+
WPvivid_tools::file_put_array($this->restore_cache,$this->restore_data_file);
|
594 |
+
}
|
595 |
}
|
includes/class-wpvivid-restore-database.php
CHANGED
@@ -509,7 +509,6 @@ class WPvivid_RestoreDB
|
|
509 |
|
510 |
$query='DESCRIBE `'.$table_name.'`';
|
511 |
$result=$this->db_method->query($query,ARRAY_A);
|
512 |
-
//$result=$result -> fetchAll(PDO::FETCH_ASSOC);
|
513 |
$columns=array();
|
514 |
foreach ($result as $data)
|
515 |
{
|
@@ -518,6 +517,11 @@ class WPvivid_RestoreDB
|
|
518 |
$column['PRI']=1;
|
519 |
else
|
520 |
$column['PRI']=0;
|
|
|
|
|
|
|
|
|
|
|
521 |
$columns[]=$column;
|
522 |
}
|
523 |
$page=5000;
|
@@ -541,6 +545,12 @@ class WPvivid_RestoreDB
|
|
541 |
$where=array();
|
542 |
foreach ($columns as $column)
|
543 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
$old_data = $row[$column['Field']];
|
545 |
if($column['PRI']==1)
|
546 |
{
|
@@ -556,7 +566,6 @@ class WPvivid_RestoreDB
|
|
556 |
{
|
557 |
continue;
|
558 |
}
|
559 |
-
|
560 |
$new_data=$this->replace_row_data($old_data);
|
561 |
if($new_data==$old_data)
|
562 |
continue;
|
@@ -690,28 +699,45 @@ class WPvivid_RestoreDB
|
|
690 |
}
|
691 |
else if(is_object($value))
|
692 |
{
|
693 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
694 |
}
|
695 |
}
|
696 |
}
|
697 |
else if(is_object($data))
|
698 |
{
|
699 |
-
$
|
700 |
-
|
701 |
{
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
$data->$key=$this->replace_serialize_data($value);
|
709 |
-
}
|
710 |
-
else if(is_object($value))
|
711 |
{
|
712 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
713 |
}
|
714 |
}
|
|
|
|
|
715 |
}
|
716 |
|
717 |
return $data;
|
@@ -931,6 +957,7 @@ class WPvivid_RestoreDB
|
|
931 |
$skip_tables[]='learnpress_sessions';
|
932 |
$skip_tables[]='icl_string_pages';
|
933 |
$skip_tables[]='webarx_event_log';
|
|
|
934 |
if(in_array(substr($table_name, strlen($this->new_prefix)),$skip_tables))
|
935 |
{
|
936 |
$skip_table=true;
|
509 |
|
510 |
$query='DESCRIBE `'.$table_name.'`';
|
511 |
$result=$this->db_method->query($query,ARRAY_A);
|
|
|
512 |
$columns=array();
|
513 |
foreach ($result as $data)
|
514 |
{
|
517 |
$column['PRI']=1;
|
518 |
else
|
519 |
$column['PRI']=0;
|
520 |
+
|
521 |
+
if($data['Type']=='mediumblob')
|
522 |
+
{
|
523 |
+
$column['skip']=1;
|
524 |
+
}
|
525 |
$columns[]=$column;
|
526 |
}
|
527 |
$page=5000;
|
545 |
$where=array();
|
546 |
foreach ($columns as $column)
|
547 |
{
|
548 |
+
if(isset($column['skip']))
|
549 |
+
{
|
550 |
+
$wpvivid_pulgin->restore_data->write_log('skip mediumblob type data', 'notice');
|
551 |
+
continue;
|
552 |
+
}
|
553 |
+
|
554 |
$old_data = $row[$column['Field']];
|
555 |
if($column['PRI']==1)
|
556 |
{
|
566 |
{
|
567 |
continue;
|
568 |
}
|
|
|
569 |
$new_data=$this->replace_row_data($old_data);
|
570 |
if($new_data==$old_data)
|
571 |
continue;
|
699 |
}
|
700 |
else if(is_object($value))
|
701 |
{
|
702 |
+
if (is_a($value, '__PHP_Incomplete_Class'))
|
703 |
+
{
|
704 |
+
//
|
705 |
+
}
|
706 |
+
else
|
707 |
+
{
|
708 |
+
$data[$key]=$this->replace_serialize_data($value);
|
709 |
+
}
|
710 |
}
|
711 |
}
|
712 |
}
|
713 |
else if(is_object($data))
|
714 |
{
|
715 |
+
$temp = $data; // new $data_class();
|
716 |
+
if (is_a($data, '__PHP_Incomplete_Class'))
|
717 |
{
|
718 |
+
|
719 |
+
}
|
720 |
+
else
|
721 |
+
{
|
722 |
+
$props = get_object_vars($data);
|
723 |
+
foreach ($props as $key => $value)
|
|
|
|
|
|
|
724 |
{
|
725 |
+
if(is_string($value))
|
726 |
+
{
|
727 |
+
$temp->$key =$this->replace_string($value);
|
728 |
+
}
|
729 |
+
else if(is_array($value))
|
730 |
+
{
|
731 |
+
$temp->$key=$this->replace_serialize_data($value);
|
732 |
+
}
|
733 |
+
else if(is_object($value))
|
734 |
+
{
|
735 |
+
$temp->$key=$this->replace_serialize_data($value);
|
736 |
+
}
|
737 |
}
|
738 |
}
|
739 |
+
$data = $temp;
|
740 |
+
unset($temp);
|
741 |
}
|
742 |
|
743 |
return $data;
|
957 |
$skip_tables[]='learnpress_sessions';
|
958 |
$skip_tables[]='icl_string_pages';
|
959 |
$skip_tables[]='webarx_event_log';
|
960 |
+
$skip_tables[]='duplicator_packages';
|
961 |
if(in_array(substr($table_name, strlen($this->new_prefix)),$skip_tables))
|
962 |
{
|
963 |
$skip_table=true;
|
includes/class-wpvivid-restore-db-pdo-mysql-method.php
CHANGED
@@ -16,11 +16,19 @@ class WPvivid_Restore_DB_PDO_Mysql_Method
|
|
16 |
|
17 |
public function connect_db()
|
18 |
{
|
19 |
-
$db_host=DB_HOST;
|
20 |
try
|
21 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
$this->db = null;
|
23 |
-
$this->db=new PDO(
|
24 |
$this->db->exec('SET NAMES utf8');
|
25 |
if(empty($this->db) || !$this->db)
|
26 |
{
|
16 |
|
17 |
public function connect_db()
|
18 |
{
|
|
|
19 |
try
|
20 |
{
|
21 |
+
$res = explode(':',DB_HOST);
|
22 |
+
$db_host = $res[0];
|
23 |
+
$db_port = empty($res[1])?'':$res[1];
|
24 |
+
if(!empty($db_port)) {
|
25 |
+
$dsn='mysql:host=' . $db_host . ';port=' . $db_port . ';dbname=' . DB_NAME;
|
26 |
+
}
|
27 |
+
else{
|
28 |
+
$dsn='mysql:host=' . $db_host . ';dbname=' . DB_NAME;
|
29 |
+
}
|
30 |
$this->db = null;
|
31 |
+
$this->db=new PDO($dsn, DB_USER, DB_PASSWORD);
|
32 |
$this->db->exec('SET NAMES utf8');
|
33 |
if(empty($this->db) || !$this->db)
|
34 |
{
|
includes/class-wpvivid-restore-site.php
CHANGED
@@ -15,14 +15,18 @@ class WPvivid_RestoreSite
|
|
15 |
|
16 |
if(isset($option['has_child']))
|
17 |
{
|
18 |
-
$root_path
|
19 |
|
|
|
|
|
|
|
|
|
20 |
$wpvivid_pulgin->restore_data->write_log('extract root:'.$root_path,'notice');
|
21 |
$zip = new WPvivid_ZipClass();
|
22 |
$all_files = array();
|
23 |
foreach ($files as $file)
|
24 |
{
|
25 |
-
$all_files[] =
|
26 |
}
|
27 |
|
28 |
return $zip -> extract($all_files,$root_path);
|
@@ -90,12 +94,13 @@ class WPvivid_RestoreSite
|
|
90 |
|
91 |
if(isset($option['wp_core'])&&isset($option['is_migrate']))
|
92 |
{
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
97 |
}
|
98 |
-
WPvivid_Setting::update_option('wpvivid_migrate_status', 'completed');
|
99 |
}
|
100 |
return $ret;
|
101 |
}
|
15 |
|
16 |
if(isset($option['has_child']))
|
17 |
{
|
18 |
+
$root_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
|
19 |
|
20 |
+
if(!file_exists($root_path))
|
21 |
+
{
|
22 |
+
@mkdir($root_path);
|
23 |
+
}
|
24 |
$wpvivid_pulgin->restore_data->write_log('extract root:'.$root_path,'notice');
|
25 |
$zip = new WPvivid_ZipClass();
|
26 |
$all_files = array();
|
27 |
foreach ($files as $file)
|
28 |
{
|
29 |
+
$all_files[] =WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.$file;
|
30 |
}
|
31 |
|
32 |
return $zip -> extract($all_files,$root_path);
|
94 |
|
95 |
if(isset($option['wp_core'])&&isset($option['is_migrate']))
|
96 |
{
|
97 |
+
if($option['is_migrate'] == 1) {
|
98 |
+
@rename(get_home_path() . '.htaccess', get_home_path() . '.htaccess_old');
|
99 |
+
if (function_exists('save_mod_rewrite_rules')) {
|
100 |
+
save_mod_rewrite_rules();
|
101 |
+
}
|
102 |
+
WPvivid_Setting::update_option('wpvivid_migrate_status', 'completed');
|
103 |
}
|
|
|
104 |
}
|
105 |
return $ret;
|
106 |
}
|
includes/class-wpvivid-restore.php
CHANGED
@@ -33,10 +33,8 @@ class WPvivid_Restore
|
|
33 |
}
|
34 |
else
|
35 |
{
|
36 |
-
$wpvivid_pulgin->restore_data->write_log('Start restoring '.$next_task['files'][0],'notice');
|
37 |
$result = $this -> execute_restore($next_task);
|
38 |
$wpvivid_pulgin->restore_data->update_sub_task($next_task['index'],$result);
|
39 |
-
//WPvivid_tools::clearcache($this -> restore_data -> get_restore_data_id());
|
40 |
|
41 |
if($result['result'] != WPVIVID_SUCCESS)
|
42 |
{
|
@@ -45,7 +43,6 @@ class WPvivid_Restore
|
|
45 |
return array('result'=>WPVIVID_FAILED,'error'=>$result['error']);
|
46 |
}
|
47 |
else {
|
48 |
-
$wpvivid_pulgin->restore_data->write_log('Finished restoring ','notice');
|
49 |
$wpvivid_pulgin->restore_data->update_status(WPVIVID_RESTORE_WAIT);
|
50 |
return array('result'=> WPVIVID_SUCCESS);
|
51 |
}
|
@@ -69,6 +66,7 @@ class WPvivid_Restore
|
|
69 |
if(isset($option['dump_db']))
|
70 |
{
|
71 |
$restore_site = new WPvivid_RestoreSite();
|
|
|
72 |
$ret= $restore_site -> restore($option,$restore_task['files']);
|
73 |
if($ret['result']==WPVIVID_SUCCESS)
|
74 |
{
|
@@ -77,7 +75,8 @@ class WPvivid_Restore
|
|
77 |
$wpvivid_pulgin->restore_data->write_log('sql file: '.$sql_file,'notice');
|
78 |
$restore_db=new WPvivid_RestoreDB();
|
79 |
$restore_db->restore($path,$sql_file,$option);
|
80 |
-
|
|
|
81 |
return array('result'=>WPVIVID_SUCCESS);
|
82 |
}
|
83 |
else
|
@@ -88,8 +87,12 @@ class WPvivid_Restore
|
|
88 |
else
|
89 |
{
|
90 |
$restore_site = new WPvivid_RestoreSite();
|
91 |
-
$ret= $restore_site -> restore($option,$restore_task['files']);
|
92 |
|
|
|
|
|
|
|
|
|
|
|
93 |
return $ret;
|
94 |
}
|
95 |
}
|
33 |
}
|
34 |
else
|
35 |
{
|
|
|
36 |
$result = $this -> execute_restore($next_task);
|
37 |
$wpvivid_pulgin->restore_data->update_sub_task($next_task['index'],$result);
|
|
|
38 |
|
39 |
if($result['result'] != WPVIVID_SUCCESS)
|
40 |
{
|
43 |
return array('result'=>WPVIVID_FAILED,'error'=>$result['error']);
|
44 |
}
|
45 |
else {
|
|
|
46 |
$wpvivid_pulgin->restore_data->update_status(WPVIVID_RESTORE_WAIT);
|
47 |
return array('result'=> WPVIVID_SUCCESS);
|
48 |
}
|
66 |
if(isset($option['dump_db']))
|
67 |
{
|
68 |
$restore_site = new WPvivid_RestoreSite();
|
69 |
+
$wpvivid_pulgin->restore_data->write_log('Start restoring '.$restore_task['files'][0],'notice');
|
70 |
$ret= $restore_site -> restore($option,$restore_task['files']);
|
71 |
if($ret['result']==WPVIVID_SUCCESS)
|
72 |
{
|
75 |
$wpvivid_pulgin->restore_data->write_log('sql file: '.$sql_file,'notice');
|
76 |
$restore_db=new WPvivid_RestoreDB();
|
77 |
$restore_db->restore($path,$sql_file,$option);
|
78 |
+
$wpvivid_pulgin->restore_data->write_log('Finished restoring '.$restore_task['files'][0],'notice');
|
79 |
+
$wpvivid_pulgin->restore_data->update_need_unzip_file($restore_task['index'],$restore_task['files']);
|
80 |
return array('result'=>WPVIVID_SUCCESS);
|
81 |
}
|
82 |
else
|
87 |
else
|
88 |
{
|
89 |
$restore_site = new WPvivid_RestoreSite();
|
|
|
90 |
|
91 |
+
$files=$wpvivid_pulgin->restore_data->get_need_unzip_file($restore_task);
|
92 |
+
$wpvivid_pulgin->restore_data->write_log('Start restoring '.$files[0],'notice');
|
93 |
+
$ret= $restore_site -> restore($option,$files);
|
94 |
+
$wpvivid_pulgin->restore_data->update_need_unzip_file($restore_task['index'],$files);
|
95 |
+
$wpvivid_pulgin->restore_data->write_log('Finished restoring '.$files[0],'notice');
|
96 |
return $ret;
|
97 |
}
|
98 |
}
|
includes/class-wpvivid-schedule.php
CHANGED
@@ -349,10 +349,16 @@ class WPvivid_Schedule
|
|
349 |
public static function reset_schedule()
|
350 |
{
|
351 |
$schedule=WPvivid_Setting::get_option('wpvivid_schedule_setting');
|
352 |
-
|
353 |
-
if($schedule['enable'])
|
354 |
{
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
}
|
357 |
else
|
358 |
{
|
349 |
public static function reset_schedule()
|
350 |
{
|
351 |
$schedule=WPvivid_Setting::get_option('wpvivid_schedule_setting');
|
352 |
+
if(!empty($schedule))
|
|
|
353 |
{
|
354 |
+
if($schedule['enable'])
|
355 |
+
{
|
356 |
+
self::set_schedule_ex($schedule);
|
357 |
+
}
|
358 |
+
else
|
359 |
+
{
|
360 |
+
self::disable_schedule();
|
361 |
+
}
|
362 |
}
|
363 |
else
|
364 |
{
|
includes/class-wpvivid-setting.php
CHANGED
@@ -128,7 +128,6 @@ class WPvivid_Setting
|
|
128 |
$common_option['memory_limit']=WPVIVID_MEMORY_LIMIT;
|
129 |
$common_option['restore_memory_limit']=WPVIVID_RESTORE_MEMORY_LIMIT;
|
130 |
$common_option['migrate_size']=WPVIVID_MIGRATE_SIZE;
|
131 |
-
$common_option['low_resource_enable']=WPVIVID_DEFAULT_LOW_RESOURCE_MODE;
|
132 |
self::update_option('wpvivid_common_setting',$common_option);
|
133 |
return $common_option;
|
134 |
}
|
@@ -465,13 +464,18 @@ class WPvivid_Setting
|
|
465 |
$json['data']['wpvivid_schedule_setting']=self::get_option('wpvivid_schedule_setting');
|
466 |
if(!empty( $json['data']['wpvivid_schedule_setting']))
|
467 |
{
|
468 |
-
$json['data']['wpvivid_schedule_setting']['
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
|
|
|
|
|
|
|
|
474 |
}
|
|
|
475 |
$json['data']['wpvivid_schedule_setting']['lock']=0;
|
476 |
if(wp_get_schedule(WPVIVID_MAIN_SCHEDULE_EVENT))
|
477 |
{
|
128 |
$common_option['memory_limit']=WPVIVID_MEMORY_LIMIT;
|
129 |
$common_option['restore_memory_limit']=WPVIVID_RESTORE_MEMORY_LIMIT;
|
130 |
$common_option['migrate_size']=WPVIVID_MIGRATE_SIZE;
|
|
|
131 |
self::update_option('wpvivid_common_setting',$common_option);
|
132 |
return $common_option;
|
133 |
}
|
464 |
$json['data']['wpvivid_schedule_setting']=self::get_option('wpvivid_schedule_setting');
|
465 |
if(!empty( $json['data']['wpvivid_schedule_setting']))
|
466 |
{
|
467 |
+
if(isset($json['data']['wpvivid_schedule_setting']['backup']['backup_files']))
|
468 |
+
$json['data']['wpvivid_schedule_setting']['backup_type']=$json['data']['wpvivid_schedule_setting']['backup']['backup_files'];
|
469 |
+
if(isset($json['data']['wpvivid_schedule_setting']['backup']['local']))
|
470 |
+
{
|
471 |
+
if($json['data']['wpvivid_schedule_setting']['backup']['local'] == 1){
|
472 |
+
$json['data']['wpvivid_schedule_setting']['save_local_remote']='local';
|
473 |
+
}
|
474 |
+
else{
|
475 |
+
$json['data']['wpvivid_schedule_setting']['save_local_remote']='remote';
|
476 |
+
}
|
477 |
}
|
478 |
+
|
479 |
$json['data']['wpvivid_schedule_setting']['lock']=0;
|
480 |
if(wp_get_schedule(WPVIVID_MAIN_SCHEDULE_EVENT))
|
481 |
{
|
includes/class-wpvivid-taskmanager.php
CHANGED
@@ -212,8 +212,13 @@ class WPvivid_taskmanager
|
|
212 |
$ret['type']=$task['data']['doing'];
|
213 |
$ret['progress']=$task['data'][$ret['type']]['progress'];
|
214 |
$ret['doing']=$task['data'][$ret['type']]['doing'];
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
217 |
$ret['running_time']=$running_time;
|
218 |
$ret['running_stamp']=$time_diff;
|
219 |
$ret['next_resume_time']=$next_resume_time;
|
@@ -238,6 +243,7 @@ class WPvivid_taskmanager
|
|
238 |
return false;
|
239 |
}
|
240 |
}
|
|
|
241 |
public static function update_backup_task_status($task_id,$reset_start_time=false,$status='',$reset_timeout=false,$resume_count=false,$error='')
|
242 |
{
|
243 |
$tasks=WPvivid_Setting::get_tasks();
|
@@ -270,6 +276,7 @@ class WPvivid_taskmanager
|
|
270 |
return false;
|
271 |
}
|
272 |
}
|
|
|
273 |
public static function get_backup_task_error($task_id)
|
274 |
{
|
275 |
$tasks=WPvivid_Setting::get_tasks();
|
@@ -435,6 +442,7 @@ class WPvivid_taskmanager
|
|
435 |
$options[$backup_id]['cache']=$cache;
|
436 |
update_option('wpvivid_download_cache',$options);
|
437 |
}
|
|
|
438 |
public static function get_download_cache($backup_id)
|
439 |
{
|
440 |
$default = array();
|
@@ -448,226 +456,6 @@ class WPvivid_taskmanager
|
|
448 |
|
449 |
return false;
|
450 |
}
|
451 |
-
public static function new_download_task($backup_id,$download_type,$need_download_files)
|
452 |
-
{
|
453 |
-
$default = array();
|
454 |
-
wp_cache_delete('notoptions', 'options');
|
455 |
-
wp_cache_delete('alloptions', 'options');
|
456 |
-
wp_cache_delete('wpvivid_download_task', 'options');
|
457 |
-
|
458 |
-
$options = get_option('wpvivid_download_task', $default);
|
459 |
-
|
460 |
-
$data=array();
|
461 |
-
$data['backup_id']=$backup_id;
|
462 |
-
$data['download_type']=$download_type;
|
463 |
-
$data['start_time']=time();
|
464 |
-
$data['run_time']=time();
|
465 |
-
$data['progress_text']=0;
|
466 |
-
|
467 |
-
foreach ($need_download_files as $file)
|
468 |
-
{
|
469 |
-
$data['files'][$file['file_name']]['status']='running';
|
470 |
-
}
|
471 |
-
|
472 |
-
$options[$backup_id][$download_type]=$data;
|
473 |
-
|
474 |
-
update_option('wpvivid_download_task',$options);
|
475 |
-
return $options[$backup_id][$download_type];
|
476 |
-
}
|
477 |
-
|
478 |
-
public static function update_download_task(&$task,$progress_text,$file_name='',$status='',$error='')
|
479 |
-
{
|
480 |
-
$default = array();
|
481 |
-
wp_cache_delete('notoptions', 'options');
|
482 |
-
wp_cache_delete('alloptions', 'options');
|
483 |
-
wp_cache_delete('wpvivid_download_task', 'options');
|
484 |
-
|
485 |
-
$options = get_option('wpvivid_download_task', $default);
|
486 |
-
$backup_id=$task['backup_id'];
|
487 |
-
$download_type=$task['download_type'];
|
488 |
-
$task['run_time']=time();
|
489 |
-
$task['progress_text']=$progress_text;
|
490 |
-
if($file_name!='')
|
491 |
-
{
|
492 |
-
$task['files'][$file_name]['status']=$status;
|
493 |
-
if($error!='')
|
494 |
-
{
|
495 |
-
$task['files'][$file_name]['error']=$error;
|
496 |
-
}
|
497 |
-
}
|
498 |
-
|
499 |
-
$options[$backup_id][$download_type]=$task;
|
500 |
-
|
501 |
-
update_option('wpvivid_download_task',$options);
|
502 |
-
}
|
503 |
-
public static function get_download_task($backup_id,$download_type,$file_name)
|
504 |
-
{
|
505 |
-
$default = array();
|
506 |
-
$options = get_option('wpvivid_download_task', $default);
|
507 |
-
|
508 |
-
if(empty($options))
|
509 |
-
{
|
510 |
-
return false;
|
511 |
-
}
|
512 |
-
if(array_key_exists($backup_id,$options))
|
513 |
-
{
|
514 |
-
if(array_key_exists($download_type,$options[$backup_id]))
|
515 |
-
{
|
516 |
-
if(array_key_exists($file_name,$options[$backup_id][$download_type]['files']))
|
517 |
-
{
|
518 |
-
return $options[$backup_id][$download_type];
|
519 |
-
}
|
520 |
-
}
|
521 |
-
}
|
522 |
-
return false;
|
523 |
-
}
|
524 |
-
public static function is_download_task_running($backup_id,$download_type,$file_name)
|
525 |
-
{
|
526 |
-
$default = array();
|
527 |
-
$options = get_option('wpvivid_download_task', $default);
|
528 |
-
|
529 |
-
if(empty($options))
|
530 |
-
{
|
531 |
-
return false;
|
532 |
-
}
|
533 |
-
if(array_key_exists($backup_id,$options))
|
534 |
-
{
|
535 |
-
if(array_key_exists($download_type,$options[$backup_id]))
|
536 |
-
{
|
537 |
-
if(array_key_exists($file_name,$options[$backup_id][$download_type]['files']))
|
538 |
-
{
|
539 |
-
$task=$options[$backup_id][$download_type];
|
540 |
-
|
541 |
-
if(time()-$task['run_time']>60)
|
542 |
-
{
|
543 |
-
return false;
|
544 |
-
}
|
545 |
-
else {
|
546 |
-
return true;
|
547 |
-
}
|
548 |
-
}
|
549 |
-
}
|
550 |
-
}
|
551 |
-
return false;
|
552 |
-
}
|
553 |
-
public static function delete_download_task($backup_id,$file_name)
|
554 |
-
{
|
555 |
-
$default = array();
|
556 |
-
wp_cache_delete('notoptions', 'options');
|
557 |
-
wp_cache_delete('alloptions', 'options');
|
558 |
-
wp_cache_delete('wpvivid_download_task', 'options');
|
559 |
-
|
560 |
-
$options = get_option('wpvivid_download_task', $default);
|
561 |
-
foreach ($options[$backup_id] as $type_name=>$type)
|
562 |
-
{
|
563 |
-
foreach ($type['files'] as $key=>$file)
|
564 |
-
{
|
565 |
-
if($key==$file_name)
|
566 |
-
{
|
567 |
-
unset($options[$backup_id][$type_name]['files'][$key]);
|
568 |
-
}
|
569 |
-
}
|
570 |
-
if(empty($options[$backup_id][$type_name]['files']))
|
571 |
-
{
|
572 |
-
unset($options[$backup_id][$type_name]);
|
573 |
-
if(empty($options[$backup_id]))
|
574 |
-
{
|
575 |
-
unset($options[$backup_id]);
|
576 |
-
}
|
577 |
-
}
|
578 |
-
}
|
579 |
-
|
580 |
-
update_option('wpvivid_download_task',$options);
|
581 |
-
}
|
582 |
-
|
583 |
-
public static function clear_timeout_download_task($backup_id)
|
584 |
-
{
|
585 |
-
$tasks=self::get_tasks_by_action('download');
|
586 |
-
|
587 |
-
foreach ($tasks as $task)
|
588 |
-
{
|
589 |
-
if($task['data']['backup_id']==$backup_id)
|
590 |
-
{
|
591 |
-
if($task['data']['status']=='running')
|
592 |
-
{
|
593 |
-
$current_time=date("Y-m-d H:i:s");
|
594 |
-
$run_time=date("Y-m-d H:i:s",$task['data']['run_time']);
|
595 |
-
$running_time=strtotime($current_time)-strtotime($run_time);
|
596 |
-
if($running_time>60)
|
597 |
-
{
|
598 |
-
self::delete_task($task['id']);
|
599 |
-
}
|
600 |
-
}
|
601 |
-
}
|
602 |
-
}
|
603 |
-
}
|
604 |
-
public static function get_downloaded_task($backup_id,$download_type)
|
605 |
-
{
|
606 |
-
$default = array();
|
607 |
-
$options = get_option('wpvivid_downloaded_task_list', $default);
|
608 |
-
if(empty($options))
|
609 |
-
{
|
610 |
-
return false;
|
611 |
-
}
|
612 |
-
else
|
613 |
-
{
|
614 |
-
if(array_key_exists($backup_id,$options))
|
615 |
-
{
|
616 |
-
if(array_key_exists($download_type,$options[$backup_id]))
|
617 |
-
{
|
618 |
-
return $options[$backup_id][$download_type];
|
619 |
-
}
|
620 |
-
}
|
621 |
-
|
622 |
-
}
|
623 |
-
return false;
|
624 |
-
}
|
625 |
-
public static function update_downloaded_task($backup_id,$task)
|
626 |
-
{
|
627 |
-
$default = array();
|
628 |
-
wp_cache_delete('notoptions', 'options');
|
629 |
-
wp_cache_delete('alloptions', 'options');
|
630 |
-
wp_cache_delete('wpvivid_downloaded_task_list', 'options');
|
631 |
-
|
632 |
-
$options = get_option('wpvivid_downloaded_task_list', $default);
|
633 |
-
$options[$backup_id][$task['data']['download_type']]=$task;
|
634 |
-
update_option('wpvivid_downloaded_task_list',$options);
|
635 |
-
}
|
636 |
-
public static function delete_downloaded_task($backup_id)
|
637 |
-
{
|
638 |
-
$default = array();
|
639 |
-
wp_cache_delete('notoptions', 'options');
|
640 |
-
wp_cache_delete('alloptions', 'options');
|
641 |
-
wp_cache_delete('wpvivid_downloaded_task_list', 'options');
|
642 |
-
|
643 |
-
$options = get_option('wpvivid_downloaded_task_list', $default);
|
644 |
-
$tasks=$options[$backup_id];
|
645 |
-
unset($options[$backup_id]);
|
646 |
-
update_option('wpvivid_downloaded_task_list',$options);
|
647 |
-
return $tasks;
|
648 |
-
}
|
649 |
-
public static function delete_downloaded_task_ex($backup_id,$download_type)
|
650 |
-
{
|
651 |
-
$default = array();
|
652 |
-
$options = get_option('wpvivid_downloaded_task_list', $default);
|
653 |
-
if(!empty($options))
|
654 |
-
{
|
655 |
-
unset($options[$backup_id][$download_type]);
|
656 |
-
update_option('wpvivid_downloaded_task_list',$options);
|
657 |
-
}
|
658 |
-
}
|
659 |
-
public static function get_downloaded_task_ex($backup_id){
|
660 |
-
$default = array();
|
661 |
-
$options = get_option('wpvivid_downloaded_task_list', $default);
|
662 |
-
if(empty($options))
|
663 |
-
{
|
664 |
-
return false;
|
665 |
-
}
|
666 |
-
else
|
667 |
-
{
|
668 |
-
return $options[$backup_id];
|
669 |
-
}
|
670 |
-
}
|
671 |
|
672 |
public static function get_task($id)
|
673 |
{
|
@@ -708,12 +496,9 @@ class WPvivid_taskmanager
|
|
708 |
$tasks=WPvivid_Setting::get_tasks();
|
709 |
foreach ($tasks as $task)
|
710 |
{
|
711 |
-
if($task['
|
712 |
{
|
713 |
-
|
714 |
-
{
|
715 |
-
return true;
|
716 |
-
}
|
717 |
}
|
718 |
}
|
719 |
return false;
|
212 |
$ret['type']=$task['data']['doing'];
|
213 |
$ret['progress']=$task['data'][$ret['type']]['progress'];
|
214 |
$ret['doing']=$task['data'][$ret['type']]['doing'];
|
215 |
+
if(isset($task['data'][$ret['type']]['sub_job'][$ret['doing']]['progress']))
|
216 |
+
$ret['descript']=__($task['data'][$ret['type']]['sub_job'][$ret['doing']]['progress'], 'wpvivid');
|
217 |
+
else
|
218 |
+
$ret['descript']='';
|
219 |
+
if(isset($task['data'][$ret['type']]['sub_job'][$ret['doing']]['upload_data']))
|
220 |
+
$ret['upload_data']=$task['data'][$ret['type']]['sub_job'][$ret['doing']]['upload_data'];
|
221 |
+
$task['data'][$ret['type']]['sub_job'][$ret['doing']]['upload_data']=false;
|
222 |
$ret['running_time']=$running_time;
|
223 |
$ret['running_stamp']=$time_diff;
|
224 |
$ret['next_resume_time']=$next_resume_time;
|
243 |
return false;
|
244 |
}
|
245 |
}
|
246 |
+
|
247 |
public static function update_backup_task_status($task_id,$reset_start_time=false,$status='',$reset_timeout=false,$resume_count=false,$error='')
|
248 |
{
|
249 |
$tasks=WPvivid_Setting::get_tasks();
|
276 |
return false;
|
277 |
}
|
278 |
}
|
279 |
+
|
280 |
public static function get_backup_task_error($task_id)
|
281 |
{
|
282 |
$tasks=WPvivid_Setting::get_tasks();
|
442 |
$options[$backup_id]['cache']=$cache;
|
443 |
update_option('wpvivid_download_cache',$options);
|
444 |
}
|
445 |
+
|
446 |
public static function get_download_cache($backup_id)
|
447 |
{
|
448 |
$default = array();
|
456 |
|
457 |
return false;
|
458 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
|
460 |
public static function get_task($id)
|
461 |
{
|
496 |
$tasks=WPvivid_Setting::get_tasks();
|
497 |
foreach ($tasks as $task)
|
498 |
{
|
499 |
+
if ($task['status']['str']=='running'||$task['status']['str']=='no_responds')
|
500 |
{
|
501 |
+
return true;
|
|
|
|
|
|
|
502 |
}
|
503 |
}
|
504 |
return false;
|
includes/class-wpvivid-upload.php
CHANGED
@@ -20,30 +20,71 @@ class WPvivid_Upload
|
|
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(
|
26 |
{
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
-
|
|
|
|
|
30 |
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
else
|
42 |
{
|
43 |
-
$remote
|
44 |
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
}
|
49 |
|
@@ -68,7 +109,7 @@ class WPvivid_Upload
|
|
68 |
$wpvivid_pulgin->wpvivid_log->WriteLog($message,'notice');
|
69 |
$progress=intval(($offset/$current_size)*100);
|
70 |
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',$progress,0);
|
71 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'upload','',
|
72 |
}
|
73 |
|
74 |
public function get_backup_files($backup)
|
20 |
if(is_null($remote_option))
|
21 |
{
|
22 |
$remote_options=WPvivid_taskmanager::get_task_options($this->task_id,'remote_options');
|
|
|
23 |
|
24 |
+
if(sizeof($remote_options)>1)
|
25 |
{
|
26 |
+
$result=array('result' => WPVIVID_FAILED , 'error' => 'not support multi remote storage');
|
27 |
+
$result= apply_filters('wpvivid_upload_files_to_multi_remote',$result,$task_id);
|
28 |
+
|
29 |
+
if($result['result']==WPVIVID_SUCCESS)
|
30 |
+
{
|
31 |
+
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',100,1);
|
32 |
+
WPvivid_taskmanager::update_backup_task_status($task_id,false,'completed');
|
33 |
+
return array('result' => WPVIVID_SUCCESS);
|
34 |
+
}
|
35 |
+
else
|
36 |
+
{
|
37 |
+
WPvivid_taskmanager::update_backup_task_status($this->task_id,false,'error',false,false,$result['error']);
|
38 |
+
return array('result' => WPVIVID_FAILED , 'error' => $result['error']);
|
39 |
+
}
|
40 |
}
|
41 |
+
else
|
42 |
+
{
|
43 |
+
$remote_option=array_shift($remote_options);
|
44 |
|
45 |
+
if(is_null($remote_option))
|
46 |
+
{
|
47 |
+
return array('result' => WPVIVID_FAILED , 'error' => 'not select remote storage');
|
48 |
+
}
|
49 |
|
50 |
+
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote_option);
|
51 |
|
52 |
+
$result=$remote->upload($this->task_id,$files,array($this,'upload_callback'));
|
53 |
+
|
54 |
+
if($result['result']==WPVIVID_SUCCESS)
|
55 |
+
{
|
56 |
+
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',100,1);
|
57 |
+
WPvivid_taskmanager::update_backup_task_status($task_id,false,'completed');
|
58 |
+
return array('result' => WPVIVID_SUCCESS);
|
59 |
+
}
|
60 |
+
else
|
61 |
+
{
|
62 |
+
$remote ->cleanup($files);
|
63 |
+
|
64 |
+
WPvivid_taskmanager::update_backup_task_status($this->task_id,false,'error',false,false,$result['error']);
|
65 |
+
return array('result' => WPVIVID_FAILED , 'error' => $result['error']);
|
66 |
+
}
|
67 |
+
}
|
68 |
}
|
69 |
else
|
70 |
{
|
71 |
+
$remote=$wpvivid_pulgin->remote_collection->get_remote($remote_option);
|
72 |
|
73 |
+
$result=$remote->upload($this->task_id,$files,array($this,'upload_callback'));
|
74 |
+
|
75 |
+
if($result['result']==WPVIVID_SUCCESS)
|
76 |
+
{
|
77 |
+
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',100,1);
|
78 |
+
WPvivid_taskmanager::update_backup_task_status($task_id,false,'completed');
|
79 |
+
return array('result' => WPVIVID_SUCCESS);
|
80 |
+
}
|
81 |
+
else
|
82 |
+
{
|
83 |
+
$remote ->cleanup($files);
|
84 |
+
|
85 |
+
WPvivid_taskmanager::update_backup_task_status($this->task_id,false,'error',false,false,$result['error']);
|
86 |
+
return array('result' => WPVIVID_FAILED , 'error' => $result['error']);
|
87 |
+
}
|
88 |
}
|
89 |
}
|
90 |
|
109 |
$wpvivid_pulgin->wpvivid_log->WriteLog($message,'notice');
|
110 |
$progress=intval(($offset/$current_size)*100);
|
111 |
WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'upload',$progress,0);
|
112 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'upload','',WPVIVID_UPLOAD_UNDO,$message, $job_data, $upload_data);
|
113 |
}
|
114 |
|
115 |
public function get_backup_files($backup)
|
includes/class-wpvivid-zipclass.php
CHANGED
@@ -237,9 +237,6 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
|
|
237 |
$packages[] = $package;
|
238 |
}
|
239 |
|
240 |
-
|
241 |
-
define(PCLZIP_TEMPORARY_DIR,$temp_dir);
|
242 |
-
|
243 |
$ret['result']=WPVIVID_SUCCESS;
|
244 |
$ret['files']=array();
|
245 |
|
@@ -268,7 +265,7 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
|
|
268 |
public function extract($files,$path = '')
|
269 |
{
|
270 |
global $wpvivid_pulgin;
|
271 |
-
|
272 |
define(PCLZIP_TEMPORARY_DIR,dirname($path));
|
273 |
|
274 |
$ret['result']=WPVIVID_SUCCESS;
|
@@ -460,7 +457,6 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
|
|
460 |
$file_data = array();
|
461 |
$file_data['file_name'] = basename($name);
|
462 |
$file_data['size'] = filesize($name);
|
463 |
-
$file_data['md5'] = md5_file($name);
|
464 |
|
465 |
return array('result'=>WPVIVID_SUCCESS,'file_data'=>$file_data);
|
466 |
}
|
237 |
$packages[] = $package;
|
238 |
}
|
239 |
|
|
|
|
|
|
|
240 |
$ret['result']=WPVIVID_SUCCESS;
|
241 |
$ret['files']=array();
|
242 |
|
265 |
public function extract($files,$path = '')
|
266 |
{
|
267 |
global $wpvivid_pulgin;
|
268 |
+
//$wpvivid_pulgin->restore_data->write_log('start prepare extract','notice');
|
269 |
define(PCLZIP_TEMPORARY_DIR,dirname($path));
|
270 |
|
271 |
$ret['result']=WPVIVID_SUCCESS;
|
457 |
$file_data = array();
|
458 |
$file_data['file_name'] = basename($name);
|
459 |
$file_data['size'] = filesize($name);
|
|
|
460 |
|
461 |
return array('result'=>WPVIVID_SUCCESS,'file_data'=>$file_data);
|
462 |
}
|
includes/class-wpvivid.php
CHANGED
@@ -38,6 +38,7 @@ class WPvivid {
|
|
38 |
protected $version;
|
39 |
|
40 |
public $wpvivid_log;
|
|
|
41 |
|
42 |
public $current_task;
|
43 |
|
@@ -100,6 +101,7 @@ class WPvivid {
|
|
100 |
add_filter('wpvivid_get_last_backup_message', array( $this, 'wpvivid_get_last_backup_message' ), 10);
|
101 |
add_filter('wpvivid_schedule_local_remote', array( $this, 'wpvivid_schedule_local_remote' ), 10);
|
102 |
add_filter('wpvivid_remote_storage', array( $this, 'wpvivid_remote_storage'), 10);
|
|
|
103 |
add_filter('wpvivid_set_general_setting', array($this, 'wpvivid_set_general_setting'), 10, 3);
|
104 |
|
105 |
add_action('wpvivid_handle_backup_succeed',array($this,'wpvivid_handle_backup_succeed'),10);
|
@@ -108,7 +110,7 @@ class WPvivid {
|
|
108 |
add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_mark_task'),20);
|
109 |
add_action('wpvivid_handle_backup_succeed',array($this,'wpvivid_mark_task'),20);
|
110 |
|
111 |
-
add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_handle_backup_failed'),9);
|
112 |
|
113 |
add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_deal_upload_succeed'),9);
|
114 |
|
@@ -118,6 +120,7 @@ class WPvivid {
|
|
118 |
$this->init_cron();
|
119 |
//Initialisation log object
|
120 |
$this->wpvivid_log=new WPvivid_Log();
|
|
|
121 |
}
|
122 |
|
123 |
public function init_cron()
|
@@ -322,6 +325,7 @@ class WPvivid {
|
|
322 |
add_action('wp_ajax_wpvivid_need_review',array( $this,'need_review'));
|
323 |
add_action('wp_ajax_wpvivid_send_debug_info',array($this,'wpvivid_send_debug_info'));
|
324 |
add_action('wp_ajax_wpvivid_get_ini_memory_limit',array($this,'get_ini_memory_limit'));
|
|
|
325 |
}
|
326 |
|
327 |
public function get_plugin_name()
|
@@ -1090,7 +1094,7 @@ class WPvivid {
|
|
1090 |
else
|
1091 |
{
|
1092 |
$task=WPvivid_taskmanager::get_task($task_id);
|
1093 |
-
do_action('wpvivid_handle_backup_failed',$task);
|
1094 |
return false;
|
1095 |
}
|
1096 |
}
|
@@ -1156,7 +1160,7 @@ class WPvivid {
|
|
1156 |
WPvivid_Setting::update_option('wpvivid_backup_list',$list);
|
1157 |
$this->wpvivid_log->WriteLog('Uploading the file ends with an error '. $ret['error'], 'error');
|
1158 |
$task=WPvivid_taskmanager::get_task($task_id);
|
1159 |
-
do_action('wpvivid_handle_backup_failed',$task);
|
1160 |
}
|
1161 |
$this->end_shutdown_function=true;
|
1162 |
die();
|
@@ -1173,6 +1177,7 @@ class WPvivid {
|
|
1173 |
}
|
1174 |
$this->wpvivid_log->WriteLog('Upload succeeded.','notice');
|
1175 |
$remote_options=$task['options']['remote_options'];
|
|
|
1176 |
WPvivid_Backuplist::update_backup($task['id'],'remote',$remote_options);
|
1177 |
}
|
1178 |
|
@@ -1198,7 +1203,7 @@ class WPvivid {
|
|
1198 |
WPvivid_taskmanager::mark_task($task['id']);
|
1199 |
}
|
1200 |
|
1201 |
-
function wpvivid_handle_backup_failed($task)
|
1202 |
{
|
1203 |
if($task['action'] === 'backup')
|
1204 |
{
|
@@ -1210,7 +1215,45 @@ class WPvivid {
|
|
1210 |
if (!array_key_exists($task['id'], $backup_error_array['bu_error']))
|
1211 |
{
|
1212 |
$backup_error_array['bu_error']['task_id'] = $task['id'];
|
1213 |
-
$backup_error_array['bu_error']['error_msg'] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1214 |
WPvivid_Setting::update_option('wpvivid_backup_error_array', $backup_error_array);
|
1215 |
}
|
1216 |
}
|
@@ -1275,7 +1318,7 @@ class WPvivid {
|
|
1275 |
{
|
1276 |
$message = __('Too many resumption attempts.', 'wpvivid');
|
1277 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1278 |
-
do_action('wpvivid_handle_backup_failed', $task);
|
1279 |
} else {
|
1280 |
$this->check_cancel_backup($task_id);
|
1281 |
$message = 'Task timed out.';
|
@@ -1284,7 +1327,7 @@ class WPvivid {
|
|
1284 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'wait_resume', false, $status['resume_count']);
|
1285 |
} else {
|
1286 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1287 |
-
do_action('wpvivid_handle_backup_failed', $task);
|
1288 |
}
|
1289 |
}
|
1290 |
if ($this->wpvivid_log)
|
@@ -1301,7 +1344,7 @@ class WPvivid {
|
|
1301 |
$message.= 'type: '. $error['type'] . ', ' . $error['message'] . ' file:' . $error['file'] . ' line:' . $error['line'];
|
1302 |
}
|
1303 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1304 |
-
do_action('wpvivid_handle_backup_failed', $task);
|
1305 |
} else {
|
1306 |
$this->check_cancel_backup($task_id);
|
1307 |
$message = 'Task timed out (WebHosting).';
|
@@ -1310,7 +1353,7 @@ class WPvivid {
|
|
1310 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'wait_resume', false, $status['resume_count']);
|
1311 |
} else {
|
1312 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1313 |
-
do_action('wpvivid_handle_backup_failed', $task);
|
1314 |
}
|
1315 |
}
|
1316 |
if ($this->wpvivid_log)
|
@@ -1329,7 +1372,7 @@ class WPvivid {
|
|
1329 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1330 |
}
|
1331 |
$task = WPvivid_taskmanager::get_task($task_id);
|
1332 |
-
do_action('wpvivid_handle_backup_failed', $task);
|
1333 |
}
|
1334 |
}
|
1335 |
}
|
@@ -1343,7 +1386,7 @@ class WPvivid {
|
|
1343 |
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,false,$message);
|
1344 |
$this->wpvivid_log->WriteLog($message,'error');
|
1345 |
|
1346 |
-
do_action('wpvivid_handle_backup_failed',$task);
|
1347 |
}
|
1348 |
/**
|
1349 |
* update time limit.
|
@@ -1421,7 +1464,7 @@ class WPvivid {
|
|
1421 |
$message=__('Too many resumption attempts.', 'wpvivid');
|
1422 |
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1423 |
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1424 |
-
do_action('wpvivid_handle_backup_failed',$task);
|
1425 |
}
|
1426 |
else
|
1427 |
{
|
@@ -1434,7 +1477,7 @@ class WPvivid {
|
|
1434 |
else
|
1435 |
{
|
1436 |
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1437 |
-
do_action('wpvivid_handle_backup_failed',$task);
|
1438 |
}
|
1439 |
}
|
1440 |
if($this->wpvivid_log)
|
@@ -1467,7 +1510,7 @@ class WPvivid {
|
|
1467 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'wait_resume', false, $status['resume_count']);
|
1468 |
} else {
|
1469 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1470 |
-
do_action('wpvivid_handle_backup_failed', $task);
|
1471 |
}
|
1472 |
}
|
1473 |
}
|
@@ -1491,7 +1534,7 @@ class WPvivid {
|
|
1491 |
$options=WPvivid_Setting::get_option('wpvivid_common_setting');
|
1492 |
if(isset($options['estimate_backup']))
|
1493 |
{
|
1494 |
-
if($options['estimate_backup']
|
1495 |
{
|
1496 |
$ret['alert_db']=false;
|
1497 |
$ret['alter_files']=false;
|
@@ -1839,33 +1882,6 @@ class WPvivid {
|
|
1839 |
}
|
1840 |
die();
|
1841 |
}
|
1842 |
-
/**
|
1843 |
-
* return update download page data
|
1844 |
-
*
|
1845 |
-
* @var string $task_id
|
1846 |
-
*
|
1847 |
-
* @return array
|
1848 |
-
*
|
1849 |
-
* @since 0.9.1
|
1850 |
-
*/
|
1851 |
-
public function update_download_page($backup_id)
|
1852 |
-
{
|
1853 |
-
$cache=WPvivid_taskmanager::get_download_cache($backup_id);
|
1854 |
-
if($cache===false)
|
1855 |
-
{
|
1856 |
-
return $this->init_download($backup_id);
|
1857 |
-
}
|
1858 |
-
else
|
1859 |
-
{
|
1860 |
-
$ret['data']=$cache;
|
1861 |
-
foreach ($ret['data']['type'] as $type_name=>$type)
|
1862 |
-
{
|
1863 |
-
$ret['data']['type'][$type_name]=$this->update_backup_download($backup_id,$type_name,$ret['data']['type'][$type_name]);
|
1864 |
-
}
|
1865 |
-
WPvivid_taskmanager::update_download_cache($backup_id,$ret['data']);
|
1866 |
-
return $ret;
|
1867 |
-
}
|
1868 |
-
}
|
1869 |
/**
|
1870 |
* prepare download backup
|
1871 |
*
|
@@ -1878,8 +1894,16 @@ class WPvivid {
|
|
1878 |
public function prepare_download_backup()
|
1879 |
{
|
1880 |
$this->ajax_check_security();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1881 |
try {
|
1882 |
if (!isset($_POST['backup_id']) || empty($_POST['backup_id']) || !is_string($_POST['backup_id']) || !isset($_POST['file_name']) || empty($_POST['file_name']) || !is_string($_POST['file_name'])) {
|
|
|
1883 |
die();
|
1884 |
}
|
1885 |
$download_info = array();
|
@@ -1889,16 +1913,9 @@ class WPvivid {
|
|
1889 |
set_time_limit(600);
|
1890 |
if (session_id())
|
1891 |
session_write_close();
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
} catch (Exception $e) {
|
1896 |
-
$message = 'A exception (' . get_class($e) . ') occurred ' . $e->getMessage() . ' (Code: ' . $e->getCode() . ', line ' . $e->getLine() . ' in ' . $e->getFile() . ')';
|
1897 |
-
error_log($message);
|
1898 |
-
} catch (Error $e) {
|
1899 |
-
$message = 'A error (' . get_class($e) . ') has occurred: ' . $e->getMessage() . ' (Code: ' . $e->getCode() . ', line ' . $e->getLine() . ' in ' . $e->getFile() . ')';
|
1900 |
-
error_log($message);
|
1901 |
-
}
|
1902 |
|
1903 |
$ret['result'] = 'success';
|
1904 |
$json = json_encode($ret);
|
@@ -1906,13 +1923,65 @@ class WPvivid {
|
|
1906 |
}
|
1907 |
catch (Exception $error) {
|
1908 |
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1909 |
error_log($message);
|
|
|
1910 |
echo json_encode(array('result'=>'failed','error'=>$message));
|
1911 |
die();
|
1912 |
}
|
|
|
|
|
1913 |
die();
|
1914 |
}
|
1915 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1916 |
public function init_download($backup_id)
|
1917 |
{
|
1918 |
if(empty($backup_id))
|
@@ -1934,316 +2003,14 @@ class WPvivid {
|
|
1934 |
|
1935 |
$backup_item=new WPvivid_Backup_Item($backup);
|
1936 |
$ret=$backup_item->get_download_backup_files($backup_id);
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
}
|
1941 |
-
public function check_backup_download($backup_id,$check_type)
|
1942 |
-
{
|
1943 |
-
$files=array();
|
1944 |
-
$data=array();
|
1945 |
-
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
1946 |
-
if(!$backup)
|
1947 |
-
{
|
1948 |
-
return $data;
|
1949 |
-
}
|
1950 |
-
|
1951 |
-
$b_has_remote=true;
|
1952 |
-
if(empty($backup['remote']))
|
1953 |
-
{
|
1954 |
-
$b_has_remote=false;
|
1955 |
-
}
|
1956 |
-
$download_dir=$backup['local']['path'];
|
1957 |
-
$option=$check_type;
|
1958 |
-
if($option=='all')
|
1959 |
-
{
|
1960 |
-
$files=$backup['backup']['data']['meta']['files'];
|
1961 |
-
}
|
1962 |
-
else
|
1963 |
-
{
|
1964 |
-
foreach ($backup['backup']['data']['type'] as $type)
|
1965 |
-
{
|
1966 |
-
if($type['type_name']==$option)
|
1967 |
-
{
|
1968 |
-
$files=$type['files'];
|
1969 |
-
break;
|
1970 |
-
}
|
1971 |
-
}
|
1972 |
}
|
1973 |
|
1974 |
-
$
|
1975 |
-
$file_count=0;
|
1976 |
-
$file_part_num=1;
|
1977 |
-
foreach ($files as $file)
|
1978 |
-
{
|
1979 |
-
$b_need_download=true;
|
1980 |
-
$file_path=$path.$file['file_name'];
|
1981 |
-
if(file_exists($file_path))
|
1982 |
-
{
|
1983 |
-
$new_md5=md5_file($file_path);
|
1984 |
-
if($file['md5']==$new_md5)
|
1985 |
-
{
|
1986 |
-
$b_need_download=false;
|
1987 |
-
}
|
1988 |
-
}
|
1989 |
-
if($file_part_num < 10){
|
1990 |
-
$format_part=sprintf("%02d", $file_part_num);
|
1991 |
-
}
|
1992 |
-
else{
|
1993 |
-
$format_part=$file_part_num;
|
1994 |
-
}
|
1995 |
-
if($b_need_download)
|
1996 |
-
{
|
1997 |
-
$task=WPvivid_taskmanager::get_download_task($backup_id,$check_type,$file['file_name']);
|
1998 |
-
if($task===false)
|
1999 |
-
{
|
2000 |
-
if($b_has_remote)
|
2001 |
-
{
|
2002 |
-
$data['files'][$file['file_name']]['status']='need_download';
|
2003 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2004 |
-
<span>Part'.$format_part.'</span></br>
|
2005 |
-
<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>
|
2006 |
-
<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>
|
2007 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2008 |
-
</div>';
|
2009 |
-
}
|
2010 |
-
else
|
2011 |
-
{
|
2012 |
-
$data['files'][$file['file_name']]['status']='file_not_found';
|
2013 |
-
}
|
2014 |
-
}
|
2015 |
-
else
|
2016 |
-
{
|
2017 |
-
if($task['files'][$file['file_name']]['status']=='running')
|
2018 |
-
{
|
2019 |
-
if(time()-$task['run_time']>60)
|
2020 |
-
{
|
2021 |
-
$data['files'][$file['file_name']]['status']='timeout';
|
2022 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2023 |
-
<span>Part'.$format_part.'</span></br>
|
2024 |
-
<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>
|
2025 |
-
<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>
|
2026 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2027 |
-
</div>';
|
2028 |
-
}
|
2029 |
-
else
|
2030 |
-
{
|
2031 |
-
$data['files'][$file['file_name']]['status'] = 'running';
|
2032 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2033 |
-
<span>Part'.$format_part.'</span></br>
|
2034 |
-
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
2035 |
-
<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>
|
2036 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2037 |
-
</div>';
|
2038 |
-
}
|
2039 |
-
$data['files'][$file['file_name']]['progress_text']=$task['progress_text'];
|
2040 |
-
}
|
2041 |
-
else if($task['files'][$file['file_name']]['status']=='completed')
|
2042 |
-
{
|
2043 |
-
if($b_has_remote)
|
2044 |
-
{
|
2045 |
-
$data['files'][$file['file_name']]['status']='need_download';
|
2046 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2047 |
-
<span>Part'.$format_part.'</span></br>
|
2048 |
-
<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>
|
2049 |
-
<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>
|
2050 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2051 |
-
</div>';
|
2052 |
-
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
2053 |
-
}
|
2054 |
-
else
|
2055 |
-
{
|
2056 |
-
$data['files'][$file['file_name']]['status']='file_not_found';
|
2057 |
-
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
2058 |
-
}
|
2059 |
-
}
|
2060 |
-
else if($task['files'][$file['file_name']]['status']=='error')
|
2061 |
-
{
|
2062 |
-
if($b_has_remote)
|
2063 |
-
{
|
2064 |
-
$data['files'][$file['file_name']]['status']='need_download';
|
2065 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2066 |
-
<span>Part'.$format_part.'</span></br>
|
2067 |
-
<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>
|
2068 |
-
<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>
|
2069 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2070 |
-
</div>';
|
2071 |
-
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
2072 |
-
}
|
2073 |
-
else
|
2074 |
-
{
|
2075 |
-
$data['files'][$file['file_name']]['status']='file_not_found';
|
2076 |
-
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
2077 |
-
}
|
2078 |
-
}
|
2079 |
-
}
|
2080 |
-
}
|
2081 |
-
else
|
2082 |
-
{
|
2083 |
-
if(WPvivid_taskmanager::get_download_task($backup_id,$check_type,$file['file_name']))
|
2084 |
-
WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
|
2085 |
-
|
2086 |
-
$data['files'][$file['file_name']]['status']='completed';
|
2087 |
-
$download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
|
2088 |
-
$data['files'][$file['file_name']]['download_path']=$download_path;
|
2089 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2090 |
-
<span>Part'.$format_part.'</span></br>
|
2091 |
-
<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>
|
2092 |
-
<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>
|
2093 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2094 |
-
</div>';
|
2095 |
-
}
|
2096 |
-
$data['files'][$file['file_name']]['size']=$this->formatBytes($file['size']);
|
2097 |
-
$file_count++;
|
2098 |
-
$file_part_num++;
|
2099 |
-
}
|
2100 |
-
if ($file_count % 2 != 0) {
|
2101 |
-
$file_count++;
|
2102 |
-
if($file_count < 10){
|
2103 |
-
$format_part=sprintf("%02d", $file_count);
|
2104 |
-
}
|
2105 |
-
else{
|
2106 |
-
$format_part=$file_count;
|
2107 |
-
}
|
2108 |
-
$data['place_html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px; color:#cccccc;">
|
2109 |
-
<span>Part'.$format_part.'</span></br>
|
2110 |
-
<span>Download</span></br>
|
2111 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2112 |
-
<span>size:</span><span>0</span>
|
2113 |
-
</div>';
|
2114 |
-
}
|
2115 |
-
else{
|
2116 |
-
$data['place_html']='';
|
2117 |
-
}
|
2118 |
-
|
2119 |
-
return $data;
|
2120 |
}
|
2121 |
-
public function update_backup_download($backup_id,$check_type,$data)
|
2122 |
-
{
|
2123 |
-
$files=array();
|
2124 |
-
$backup=WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
2125 |
-
if(!$backup)
|
2126 |
-
{
|
2127 |
-
return array();
|
2128 |
-
}
|
2129 |
-
$download_dir=$backup['local']['path'];
|
2130 |
-
|
2131 |
-
$option=$check_type;
|
2132 |
-
if($option=='all')
|
2133 |
-
{
|
2134 |
-
$files=$backup['backup']['data']['meta']['files'];
|
2135 |
-
}
|
2136 |
-
else
|
2137 |
-
{
|
2138 |
-
foreach ($backup['backup']['data']['type'] as $type)
|
2139 |
-
{
|
2140 |
-
if($type['type_name']==$option)
|
2141 |
-
{
|
2142 |
-
$files=$type['files'];
|
2143 |
-
break;
|
2144 |
-
}
|
2145 |
-
}
|
2146 |
-
}
|
2147 |
-
|
2148 |
-
$file_count=0;
|
2149 |
-
$file_part_num=1;
|
2150 |
-
foreach ($files as $file)
|
2151 |
-
{
|
2152 |
-
if($file_part_num < 10){
|
2153 |
-
$format_part=sprintf("%02d", $file_part_num);
|
2154 |
-
}
|
2155 |
-
else{
|
2156 |
-
$format_part=$file_part_num;
|
2157 |
-
}
|
2158 |
-
$task=WPvivid_taskmanager::get_download_task($backup_id,$check_type,$file['file_name']);
|
2159 |
-
if($task!==false)
|
2160 |
-
{
|
2161 |
-
if ($task['files'][$file['file_name']]['status'] == 'running')
|
2162 |
-
{
|
2163 |
-
if(time()-$task['run_time']>60)
|
2164 |
-
{
|
2165 |
-
$data['files'][$file['file_name']]['status']='timeout';
|
2166 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2167 |
-
<span>Part'.$format_part.'</span></br>
|
2168 |
-
<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>
|
2169 |
-
<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>
|
2170 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2171 |
-
</div>';
|
2172 |
-
}
|
2173 |
-
else
|
2174 |
-
{
|
2175 |
-
$data['files'][$file['file_name']]['status'] = 'running';
|
2176 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2177 |
-
<span>Part'.$format_part.'</span></br>
|
2178 |
-
<span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
|
2179 |
-
<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>
|
2180 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2181 |
-
</div>';
|
2182 |
-
}
|
2183 |
-
$data['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
|
2184 |
-
} else if ($task['files'][$file['file_name']]['status'] == 'completed')
|
2185 |
-
{
|
2186 |
-
$data['files'][$file['file_name']]['status'] = 'completed';
|
2187 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2188 |
-
<span>Part'.$format_part.'</span></br>
|
2189 |
-
<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>
|
2190 |
-
<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>
|
2191 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2192 |
-
</div>';
|
2193 |
-
$download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
|
2194 |
-
$data['files'][$file['file_name']]['download_path']=$download_path;
|
2195 |
-
WPvivid_taskmanager::delete_download_task($backup_id, $file['file_name']);
|
2196 |
-
} else if ($task['files'][$file['file_name']]['status'] == 'error')
|
2197 |
-
{
|
2198 |
-
$data['files'][$file['file_name']]['status'] = 'error';
|
2199 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
2200 |
-
<span>Part'.$format_part.'</span></br>
|
2201 |
-
<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>
|
2202 |
-
<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>
|
2203 |
-
<span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
|
2204 |
-
</div>';
|
2205 |
-
$data['files'][$file['file_name']]['error']=__($task['files'][$file['file_name']]['error'], 'wpvivid');
|
2206 |
-
WPvivid_taskmanager::delete_download_task($backup_id, $file['file_name']);
|
2207 |
-
}
|
2208 |
-
}
|
2209 |
-
else
|
2210 |
-
{
|
2211 |
-
if($data['files'][$file['file_name']]['status']=='error')
|
2212 |
-
{
|
2213 |
-
$data['files'][$file['file_name']]['status']='need_download';
|
2214 |
-
$data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
|
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']='';
|
2221 |
-
}
|
2222 |
-
}
|
2223 |
-
$file_count++;
|
2224 |
-
$file_part_num++;
|
2225 |
-
}
|
2226 |
-
if ($file_count % 2 != 0) {
|
2227 |
-
$file_count++;
|
2228 |
-
if($file_count < 10){
|
2229 |
-
$format_part=sprintf("%02d", $file_count);
|
2230 |
-
}
|
2231 |
-
else{
|
2232 |
-
$format_part=$file_count;
|
2233 |
-
}
|
2234 |
-
$data['place_html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px; color:#cccccc;">
|
2235 |
-
<span>Part'.$format_part.'</span></br>
|
2236 |
-
<span>Download</span></br>
|
2237 |
-
<div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0;height:5px;"></div></div>
|
2238 |
-
<span>size:</span><span>0</span>
|
2239 |
-
</div>';
|
2240 |
-
}
|
2241 |
-
else{
|
2242 |
-
$data['place_html']='';
|
2243 |
-
}
|
2244 |
|
2245 |
-
return $data;
|
2246 |
-
}
|
2247 |
/**
|
2248 |
* delete download file
|
2249 |
*
|
@@ -2511,14 +2278,18 @@ class WPvivid {
|
|
2511 |
|
2512 |
if(!empty($backup['remote']))
|
2513 |
{
|
|
|
2514 |
$files=$backup_item->get_files(false);
|
2515 |
foreach($backup['remote'] as $remote)
|
2516 |
{
|
2517 |
WPvivid_downloader::delete($remote,$files);
|
2518 |
}
|
2519 |
}
|
|
|
|
|
|
|
|
|
2520 |
|
2521 |
-
WPvivid_Backuplist::delete_backup($backup_id);
|
2522 |
|
2523 |
$ret['result']='success';
|
2524 |
return $ret;
|
@@ -2619,6 +2390,11 @@ class WPvivid {
|
|
2619 |
$remote_storage = '';
|
2620 |
$remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
|
2621 |
$ret['remote_storage'] = $remote_storage;
|
|
|
|
|
|
|
|
|
|
|
2622 |
}
|
2623 |
}
|
2624 |
catch (Exception $error) {
|
@@ -2756,6 +2532,11 @@ class WPvivid {
|
|
2756 |
$remote_storage = '';
|
2757 |
$remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
|
2758 |
$ret['remote_storage'] = $remote_storage;
|
|
|
|
|
|
|
|
|
|
|
2759 |
}
|
2760 |
}
|
2761 |
catch (Exception $error) {
|
@@ -2911,12 +2692,20 @@ class WPvivid {
|
|
2911 |
|
2912 |
$ret = $backup_item->check_backup_files();
|
2913 |
|
2914 |
-
|
2915 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2916 |
} else {
|
2917 |
-
$ret['
|
2918 |
}
|
2919 |
|
|
|
|
|
2920 |
$ret['skip_backup_old_site'] = 1;
|
2921 |
$ret['skip_backup_old_database'] = 1;
|
2922 |
|
@@ -2955,6 +2744,49 @@ class WPvivid {
|
|
2955 |
die();
|
2956 |
}
|
2957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2958 |
public function delete_last_restore_data()
|
2959 |
{
|
2960 |
$this->ajax_check_security();
|
@@ -3010,7 +2842,8 @@ class WPvivid {
|
|
3010 |
|
3011 |
$ret = $backup_item->check_backup_files();
|
3012 |
|
3013 |
-
if ($backup_item->get_backup_type() == 'Upload')
|
|
|
3014 |
$ret['is_migrate'] = 1;
|
3015 |
} else {
|
3016 |
$ret['is_migrate'] = 0;
|
@@ -3065,9 +2898,20 @@ class WPvivid {
|
|
3065 |
die();
|
3066 |
}
|
3067 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3068 |
$downloader = new WPvivid_downloader();
|
3069 |
-
$
|
3070 |
|
|
|
3071 |
echo json_encode($ret);
|
3072 |
}
|
3073 |
catch (Exception $error) {
|
@@ -3096,7 +2940,7 @@ class WPvivid {
|
|
3096 |
} else {
|
3097 |
$ret['result'] = WPVIVID_SUCCESS;
|
3098 |
$ret['status'] = $task['status'];
|
3099 |
-
$ret['log'] = $task['
|
3100 |
$ret['error'] = $task['error'];
|
3101 |
echo json_encode($ret);
|
3102 |
}
|
@@ -3671,41 +3515,7 @@ class WPvivid {
|
|
3671 |
$error_notice_html = array();
|
3672 |
foreach ($backup_error_array as $key => $value){
|
3673 |
$error_notice_html['bu_error']['task_id']=$value['task_id'];
|
3674 |
-
$
|
3675 |
-
$need_notice = false;
|
3676 |
-
if(!isset($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload'])){
|
3677 |
-
$need_notice = true;
|
3678 |
-
}
|
3679 |
-
else{
|
3680 |
-
if($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']){
|
3681 |
-
$need_notice = false;
|
3682 |
-
}
|
3683 |
-
else{
|
3684 |
-
$need_notice = true;
|
3685 |
-
}
|
3686 |
-
}
|
3687 |
-
if($need_notice) {
|
3688 |
-
if($value['error_msg'] == 'Too many resumption attempts.' || $value['error_msg'] == 'Task timed out.' || $value['error_msg'] = 'Task timed out (WebHosting).') {
|
3689 |
-
$notice_msg1 = 'Backup failed, it seems due to insufficient server resource or hitting server limit. Please navigate to Settings > Advanced > ';
|
3690 |
-
$notice_msg2 = 'optimization mode for web hosting/shared hosting';
|
3691 |
-
$notice_msg3 = ' to enable it and try again';
|
3692 |
-
$error_notice_html['bu_error']['error_msg']=__('<div class="notice notice-error inline"><p>'.$notice_msg1.'<strong>'.$notice_msg2.'</strong>'.$notice_msg3.'</p></div>');
|
3693 |
-
}
|
3694 |
-
else{
|
3695 |
-
$notice_msg = 'Backup error: '.$value['error_msg'].', task id: '.$value['task_id'];
|
3696 |
-
$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>');
|
3697 |
-
}
|
3698 |
-
}
|
3699 |
-
else{
|
3700 |
-
if($value['error_msg'] == 'Too many resumption attempts.' || $value['error_msg'] == 'Task timed out.' || $value['error_msg'] = 'Task timed out (WebHosting).') {
|
3701 |
-
$notice_msg = 'Backup failed, it seems due to insufficient server resource or hitting server limit.';
|
3702 |
-
$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>');
|
3703 |
-
}
|
3704 |
-
else {
|
3705 |
-
$notice_msg = 'Backup error: ' . $value['error_msg'] . ', task id: ' . $value['task_id'];
|
3706 |
-
$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>');
|
3707 |
-
}
|
3708 |
-
}
|
3709 |
}
|
3710 |
WPvivid_Setting::delete_option('wpvivid_backup_error_array');
|
3711 |
$html = '';
|
@@ -3731,8 +3541,6 @@ class WPvivid {
|
|
3731 |
}
|
3732 |
$backup_item=new WPvivid_Backup_Item($backup);
|
3733 |
$ret['download']=$backup_item->update_download_page($backup_id);
|
3734 |
-
//$ret=$backup_item->get_download_backup_files($backup_id);
|
3735 |
-
//$ret['download'] = self::update_download_page($backup_id);
|
3736 |
}
|
3737 |
|
3738 |
$html='';
|
@@ -4274,6 +4082,8 @@ class WPvivid {
|
|
4274 |
$remote_storage = '';
|
4275 |
$remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
|
4276 |
$ret['remote_storage'] = $remote_storage;
|
|
|
|
|
4277 |
echo json_encode($ret);
|
4278 |
}
|
4279 |
catch (Exception $error) {
|
@@ -4939,165 +4749,133 @@ class WPvivid {
|
|
4939 |
|
4940 |
public function get_website_info()
|
4941 |
{
|
4942 |
-
|
4943 |
-
|
4944 |
-
|
4945 |
-
|
4946 |
-
|
4947 |
-
|
4948 |
-
|
4949 |
-
|
4950 |
-
|
4951 |
-
|
4952 |
-
|
4953 |
-
|
4954 |
-
|
4955 |
-
|
4956 |
-
|
4957 |
-
|
4958 |
-
$ret['data']['
|
4959 |
-
|
4960 |
-
|
4961 |
-
|
4962 |
-
|
4963 |
-
|
4964 |
-
|
4965 |
-
|
4966 |
-
|
4967 |
-
|
4968 |
-
|
4969 |
-
{
|
4970 |
-
$ret['wp_debug'] = false;
|
4971 |
-
}
|
4972 |
-
$ret['data']['language']=get_bloginfo('language');
|
4973 |
-
$ret['data']['upload_max_filesize']=ini_get("upload_max_filesize");
|
4974 |
|
4975 |
-
|
4976 |
-
|
4977 |
-
|
4978 |
-
|
4979 |
-
|
4980 |
-
|
4981 |
-
|
4982 |
-
|
4983 |
-
|
4984 |
-
|
4985 |
-
|
4986 |
-
|
4987 |
-
|
4988 |
-
|
4989 |
-
|
4990 |
-
|
4991 |
-
|
4992 |
-
|
4993 |
-
|
4994 |
-
|
4995 |
-
|
4996 |
-
|
4997 |
-
|
4998 |
-
|
4999 |
-
|
5000 |
-
|
5001 |
-
|
5002 |
-
$ret['data']['exif']='support';
|
5003 |
-
}
|
5004 |
-
else
|
5005 |
-
{
|
5006 |
-
$ret['data']['exif']='not support';
|
5007 |
-
}
|
5008 |
|
5009 |
-
|
5010 |
-
|
5011 |
-
|
5012 |
-
|
5013 |
-
|
5014 |
-
{
|
5015 |
-
$ret['data']['xml']='not support';
|
5016 |
-
}
|
5017 |
|
5018 |
-
|
5019 |
-
|
5020 |
-
|
5021 |
-
|
5022 |
-
|
5023 |
-
{
|
5024 |
-
$ret['data']['suhosin']='not support';
|
5025 |
-
}
|
5026 |
|
5027 |
-
|
5028 |
-
|
5029 |
-
|
5030 |
-
|
5031 |
-
|
5032 |
-
{
|
5033 |
-
$ret['data']['IPTC']='not support';
|
5034 |
-
}
|
5035 |
|
5036 |
-
|
5037 |
|
5038 |
-
|
5039 |
-
|
5040 |
-
|
5041 |
-
|
5042 |
-
|
5043 |
-
{
|
5044 |
-
$ret['data']['apache_modules']=array();
|
5045 |
-
}
|
5046 |
|
5047 |
-
|
5048 |
-
|
5049 |
-
|
5050 |
-
|
5051 |
-
|
5052 |
-
{
|
5053 |
-
$ret['data']['pdo_mysql']='not support';
|
5054 |
-
}
|
5055 |
|
5056 |
-
|
5057 |
-
|
5058 |
-
|
5059 |
-
|
5060 |
-
|
5061 |
-
|
5062 |
-
|
|
|
|
|
|
|
|
|
5063 |
}
|
5064 |
-
|
5065 |
-
{
|
5066 |
-
$ret['data']['
|
5067 |
-
|
|
|
5068 |
}
|
5069 |
-
}
|
5070 |
-
else {
|
5071 |
-
$ret['data']['mysql_mode']='';
|
5072 |
-
}
|
5073 |
-
if (!class_exists('PclZip')) include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
|
5074 |
-
if (!class_exists('PclZip'))
|
5075 |
-
{
|
5076 |
-
$ret['data']['PclZip']='not support';
|
5077 |
-
}
|
5078 |
-
else
|
5079 |
-
{
|
5080 |
-
$ret['data']['PclZip']='support';
|
5081 |
-
}
|
5082 |
|
5083 |
-
|
5084 |
-
|
5085 |
-
|
5086 |
-
|
5087 |
-
|
5088 |
-
}
|
5089 |
|
5090 |
-
|
5091 |
|
5092 |
-
|
5093 |
|
5094 |
-
|
5095 |
-
|
5096 |
-
|
|
|
|
|
5097 |
}
|
5098 |
-
|
5099 |
-
|
5100 |
-
$
|
|
|
5101 |
}
|
5102 |
return $ret;
|
5103 |
}
|
@@ -5276,6 +5054,22 @@ class WPvivid {
|
|
5276 |
return $remote_storage;
|
5277 |
}
|
5278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5279 |
public function wpvivid_schedule_add_remote_pic($html){
|
5280 |
$html = '';
|
5281 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
@@ -5530,4 +5324,9 @@ class WPvivid {
|
|
5530 |
}
|
5531 |
die();
|
5532 |
}
|
|
|
|
|
|
|
|
|
|
|
5533 |
}
|
38 |
protected $version;
|
39 |
|
40 |
public $wpvivid_log;
|
41 |
+
public $wpvivid_download_log;
|
42 |
|
43 |
public $current_task;
|
44 |
|
101 |
add_filter('wpvivid_get_last_backup_message', array( $this, 'wpvivid_get_last_backup_message' ), 10);
|
102 |
add_filter('wpvivid_schedule_local_remote', array( $this, 'wpvivid_schedule_local_remote' ), 10);
|
103 |
add_filter('wpvivid_remote_storage', array( $this, 'wpvivid_remote_storage'), 10);
|
104 |
+
add_filter('wpvivid_add_remote_notice', array($this, 'wpvivid_add_remote_notice'), 10, 2);
|
105 |
add_filter('wpvivid_set_general_setting', array($this, 'wpvivid_set_general_setting'), 10, 3);
|
106 |
|
107 |
add_action('wpvivid_handle_backup_succeed',array($this,'wpvivid_handle_backup_succeed'),10);
|
110 |
add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_mark_task'),20);
|
111 |
add_action('wpvivid_handle_backup_succeed',array($this,'wpvivid_mark_task'),20);
|
112 |
|
113 |
+
add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_handle_backup_failed'),9, 2);
|
114 |
|
115 |
add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_deal_upload_succeed'),9);
|
116 |
|
120 |
$this->init_cron();
|
121 |
//Initialisation log object
|
122 |
$this->wpvivid_log=new WPvivid_Log();
|
123 |
+
$this->wpvivid_download_log=new WPvivid_Log();
|
124 |
}
|
125 |
|
126 |
public function init_cron()
|
325 |
add_action('wp_ajax_wpvivid_need_review',array( $this,'need_review'));
|
326 |
add_action('wp_ajax_wpvivid_send_debug_info',array($this,'wpvivid_send_debug_info'));
|
327 |
add_action('wp_ajax_wpvivid_get_ini_memory_limit',array($this,'get_ini_memory_limit'));
|
328 |
+
add_action('wp_ajax_wpvivid_get_restore_file_is_migrate', array($this, 'get_restore_file_is_migrate'));
|
329 |
}
|
330 |
|
331 |
public function get_plugin_name()
|
1094 |
else
|
1095 |
{
|
1096 |
$task=WPvivid_taskmanager::get_task($task_id);
|
1097 |
+
do_action('wpvivid_handle_backup_failed',$task, false);
|
1098 |
return false;
|
1099 |
}
|
1100 |
}
|
1160 |
WPvivid_Setting::update_option('wpvivid_backup_list',$list);
|
1161 |
$this->wpvivid_log->WriteLog('Uploading the file ends with an error '. $ret['error'], 'error');
|
1162 |
$task=WPvivid_taskmanager::get_task($task_id);
|
1163 |
+
do_action('wpvivid_handle_backup_failed',$task, false);
|
1164 |
}
|
1165 |
$this->end_shutdown_function=true;
|
1166 |
die();
|
1177 |
}
|
1178 |
$this->wpvivid_log->WriteLog('Upload succeeded.','notice');
|
1179 |
$remote_options=$task['options']['remote_options'];
|
1180 |
+
$remote_options=apply_filters('wpvivid_set_backup_remote_options',$remote_options,$task['id']);
|
1181 |
WPvivid_Backuplist::update_backup($task['id'],'remote',$remote_options);
|
1182 |
}
|
1183 |
|
1203 |
WPvivid_taskmanager::mark_task($task['id']);
|
1204 |
}
|
1205 |
|
1206 |
+
function wpvivid_handle_backup_failed($task, $need_set_low_resource_mode)
|
1207 |
{
|
1208 |
if($task['action'] === 'backup')
|
1209 |
{
|
1215 |
if (!array_key_exists($task['id'], $backup_error_array['bu_error']))
|
1216 |
{
|
1217 |
$backup_error_array['bu_error']['task_id'] = $task['id'];
|
1218 |
+
$backup_error_array['bu_error']['error_msg'] = 'Unknown error.';
|
1219 |
+
//$backup_error_array['bu_error']['error_msg'] = $task['status']['error'];
|
1220 |
+
//
|
1221 |
+
$general_setting=WPvivid_Setting::get_setting(true, "");
|
1222 |
+
$need_notice = false;
|
1223 |
+
if(!isset($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload'])){
|
1224 |
+
$need_notice = true;
|
1225 |
+
}
|
1226 |
+
else{
|
1227 |
+
if($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']){
|
1228 |
+
$need_notice = false;
|
1229 |
+
}
|
1230 |
+
else{
|
1231 |
+
$need_notice = true;
|
1232 |
+
}
|
1233 |
+
}
|
1234 |
+
if($need_notice) {
|
1235 |
+
if($need_set_low_resource_mode) {
|
1236 |
+
$notice_msg1 = 'Backup failed, it seems due to insufficient server resource or hitting server limit. Please navigate to Settings > Advanced > ';
|
1237 |
+
$notice_msg2 = 'optimization mode for web hosting/shared hosting';
|
1238 |
+
$notice_msg3 = ' to enable it and try again';
|
1239 |
+
$backup_error_array['bu_error']['error_msg']=__('<div class="notice notice-error inline"><p>'.$notice_msg1.'<strong>'.$notice_msg2.'</strong>'.$notice_msg3.'</p></div>');
|
1240 |
+
}
|
1241 |
+
else{
|
1242 |
+
$notice_msg = 'Backup error: '.$task['status']['error'].', task id: '.$task['id'];
|
1243 |
+
$backup_error_array['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>');
|
1244 |
+
}
|
1245 |
+
}
|
1246 |
+
else{
|
1247 |
+
if($need_set_low_resource_mode) {
|
1248 |
+
$notice_msg = 'Backup failed, it seems due to insufficient server resource or hitting server limit.';
|
1249 |
+
$backup_error_array['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>');
|
1250 |
+
}
|
1251 |
+
else {
|
1252 |
+
$notice_msg = 'Backup error: ' . $task['status']['error'] . ', task id: ' . $task['id'];
|
1253 |
+
$backup_error_array['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>');
|
1254 |
+
}
|
1255 |
+
}
|
1256 |
+
//
|
1257 |
WPvivid_Setting::update_option('wpvivid_backup_error_array', $backup_error_array);
|
1258 |
}
|
1259 |
}
|
1318 |
{
|
1319 |
$message = __('Too many resumption attempts.', 'wpvivid');
|
1320 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1321 |
+
do_action('wpvivid_handle_backup_failed', $task, true);
|
1322 |
} else {
|
1323 |
$this->check_cancel_backup($task_id);
|
1324 |
$message = 'Task timed out.';
|
1327 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'wait_resume', false, $status['resume_count']);
|
1328 |
} else {
|
1329 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1330 |
+
do_action('wpvivid_handle_backup_failed', $task, true);
|
1331 |
}
|
1332 |
}
|
1333 |
if ($this->wpvivid_log)
|
1344 |
$message.= 'type: '. $error['type'] . ', ' . $error['message'] . ' file:' . $error['file'] . ' line:' . $error['line'];
|
1345 |
}
|
1346 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1347 |
+
do_action('wpvivid_handle_backup_failed', $task ,true);
|
1348 |
} else {
|
1349 |
$this->check_cancel_backup($task_id);
|
1350 |
$message = 'Task timed out (WebHosting).';
|
1353 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'wait_resume', false, $status['resume_count']);
|
1354 |
} else {
|
1355 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1356 |
+
do_action('wpvivid_handle_backup_failed', $task, true);
|
1357 |
}
|
1358 |
}
|
1359 |
if ($this->wpvivid_log)
|
1372 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1373 |
}
|
1374 |
$task = WPvivid_taskmanager::get_task($task_id);
|
1375 |
+
do_action('wpvivid_handle_backup_failed', $task, false);
|
1376 |
}
|
1377 |
}
|
1378 |
}
|
1386 |
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,false,$message);
|
1387 |
$this->wpvivid_log->WriteLog($message,'error');
|
1388 |
|
1389 |
+
do_action('wpvivid_handle_backup_failed',$task, false);
|
1390 |
}
|
1391 |
/**
|
1392 |
* update time limit.
|
1464 |
$message=__('Too many resumption attempts.', 'wpvivid');
|
1465 |
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1466 |
WPvivid_error_log::create_error_log($this->wpvivid_log->log_file);
|
1467 |
+
do_action('wpvivid_handle_backup_failed',$task, true);
|
1468 |
}
|
1469 |
else
|
1470 |
{
|
1477 |
else
|
1478 |
{
|
1479 |
$task=WPvivid_taskmanager::update_backup_task_status($task_id,false,'error',false,$status['resume_count'],$message);
|
1480 |
+
do_action('wpvivid_handle_backup_failed',$task, true);
|
1481 |
}
|
1482 |
}
|
1483 |
if($this->wpvivid_log)
|
1510 |
WPvivid_taskmanager::update_backup_task_status($task_id, false, 'wait_resume', false, $status['resume_count']);
|
1511 |
} else {
|
1512 |
$task = WPvivid_taskmanager::update_backup_task_status($task_id, false, 'error', false, $status['resume_count'], $message);
|
1513 |
+
do_action('wpvivid_handle_backup_failed', $task, true);
|
1514 |
}
|
1515 |
}
|
1516 |
}
|
1534 |
$options=WPvivid_Setting::get_option('wpvivid_common_setting');
|
1535 |
if(isset($options['estimate_backup']))
|
1536 |
{
|
1537 |
+
if($options['estimate_backup'] == false)
|
1538 |
{
|
1539 |
$ret['alert_db']=false;
|
1540 |
$ret['alter_files']=false;
|
1882 |
}
|
1883 |
die();
|
1884 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1885 |
/**
|
1886 |
* prepare download backup
|
1887 |
*
|
1894 |
public function prepare_download_backup()
|
1895 |
{
|
1896 |
$this->ajax_check_security();
|
1897 |
+
$this->end_shutdown_function=false;
|
1898 |
+
register_shutdown_function(array($this,'deal_prepare_download_shutdown_error'));
|
1899 |
+
$id=uniqid('wpvivid-');
|
1900 |
+
$log_file_name=$id.'_download';
|
1901 |
+
$this->wpvivid_download_log->OpenLogFile($log_file_name);
|
1902 |
+
$this->wpvivid_download_log->WriteLog('Prepare download backup.','notice');
|
1903 |
+
$this->wpvivid_download_log->WriteLogHander();
|
1904 |
try {
|
1905 |
if (!isset($_POST['backup_id']) || empty($_POST['backup_id']) || !is_string($_POST['backup_id']) || !isset($_POST['file_name']) || empty($_POST['file_name']) || !is_string($_POST['file_name'])) {
|
1906 |
+
$this->end_shutdown_function=true;
|
1907 |
die();
|
1908 |
}
|
1909 |
$download_info = array();
|
1913 |
set_time_limit(600);
|
1914 |
if (session_id())
|
1915 |
session_write_close();
|
1916 |
+
|
1917 |
+
$downloader = new WPvivid_downloader();
|
1918 |
+
$downloader->ready_download($download_info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1919 |
|
1920 |
$ret['result'] = 'success';
|
1921 |
$json = json_encode($ret);
|
1923 |
}
|
1924 |
catch (Exception $error) {
|
1925 |
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
1926 |
+
if($this->wpvivid_download_log){
|
1927 |
+
$this->wpvivid_download_log->WriteLog($message ,'error');
|
1928 |
+
WPvivid_error_log::create_error_log($this->wpvivid_download_log->log_file);
|
1929 |
+
$this->wpvivid_download_log->CloseFile();
|
1930 |
+
}
|
1931 |
+
else {
|
1932 |
+
$id = uniqid('wpvivid-');
|
1933 |
+
$log_file_name = $id . '_download';
|
1934 |
+
$log = new WPvivid_Log();
|
1935 |
+
$log->CreateLogFile($log_file_name, 'no_folder', 'download');
|
1936 |
+
$log->WriteLog($message, 'error');
|
1937 |
+
WPvivid_error_log::create_error_log($log->log_file);
|
1938 |
+
$log->CloseFile();
|
1939 |
+
}
|
1940 |
error_log($message);
|
1941 |
+
$this->end_shutdown_function=true;
|
1942 |
echo json_encode(array('result'=>'failed','error'=>$message));
|
1943 |
die();
|
1944 |
}
|
1945 |
+
$this->wpvivid_download_log->CloseFile();
|
1946 |
+
$this->end_shutdown_function=true;
|
1947 |
die();
|
1948 |
}
|
1949 |
|
1950 |
+
public function deal_prepare_download_shutdown_error()
|
1951 |
+
{
|
1952 |
+
if($this->end_shutdown_function==false) {
|
1953 |
+
$last_error = error_get_last();
|
1954 |
+
if (!empty($last_error) && !in_array($last_error['type'], array(E_NOTICE), true)) {
|
1955 |
+
$error = $last_error;
|
1956 |
+
} else {
|
1957 |
+
$error = false;
|
1958 |
+
}
|
1959 |
+
$ret['result'] = 'failed';
|
1960 |
+
if ($error === false) {
|
1961 |
+
$ret['error'] = 'unknown Error';
|
1962 |
+
} else {
|
1963 |
+
$ret['error'] = 'type: '. $error['type'] . ', ' . $error['message'] . ' file:' . $error['file'] . ' line:' . $error['line'];
|
1964 |
+
error_log($ret['error']);
|
1965 |
+
}
|
1966 |
+
if($this->wpvivid_download_log){
|
1967 |
+
$this->wpvivid_download_log->WriteLog($ret['error'] ,'error');
|
1968 |
+
WPvivid_error_log::create_error_log($this->wpvivid_download_log->log_file);
|
1969 |
+
$this->wpvivid_download_log->CloseFile();
|
1970 |
+
}
|
1971 |
+
else {
|
1972 |
+
$id = uniqid('wpvivid-');
|
1973 |
+
$log_file_name = $id . '_download';
|
1974 |
+
$log = new WPvivid_Log();
|
1975 |
+
$log->CreateLogFile($log_file_name, 'no_folder', 'download');
|
1976 |
+
$log->WriteLog($ret['error'], 'notice');
|
1977 |
+
WPvivid_error_log::create_error_log($log->log_file);
|
1978 |
+
$log->CloseFile();
|
1979 |
+
}
|
1980 |
+
echo json_encode($ret);
|
1981 |
+
die();
|
1982 |
+
}
|
1983 |
+
}
|
1984 |
+
|
1985 |
public function init_download($backup_id)
|
1986 |
{
|
1987 |
if(empty($backup_id))
|
2003 |
|
2004 |
$backup_item=new WPvivid_Backup_Item($backup);
|
2005 |
$ret=$backup_item->get_download_backup_files($backup_id);
|
2006 |
+
if($ret['result']==WPVIVID_SUCCESS){
|
2007 |
+
$ret=$backup_item->get_download_progress($backup_id, $ret['files']);
|
2008 |
+
WPvivid_taskmanager::update_download_cache($backup_id,$ret);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009 |
}
|
2010 |
|
2011 |
+
return $ret;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013 |
|
|
|
|
|
2014 |
/**
|
2015 |
* delete download file
|
2016 |
*
|
2278 |
|
2279 |
if(!empty($backup['remote']))
|
2280 |
{
|
2281 |
+
WPvivid_Backuplist::delete_backup($backup_id);
|
2282 |
$files=$backup_item->get_files(false);
|
2283 |
foreach($backup['remote'] as $remote)
|
2284 |
{
|
2285 |
WPvivid_downloader::delete($remote,$files);
|
2286 |
}
|
2287 |
}
|
2288 |
+
else
|
2289 |
+
{
|
2290 |
+
WPvivid_Backuplist::delete_backup($backup_id);
|
2291 |
+
}
|
2292 |
|
|
|
2293 |
|
2294 |
$ret['result']='success';
|
2295 |
return $ret;
|
2390 |
$remote_storage = '';
|
2391 |
$remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
|
2392 |
$ret['remote_storage'] = $remote_storage;
|
2393 |
+
$success_msg = 'You have successfully added a remote storage.';
|
2394 |
+
$ret['notice'] = apply_filters('wpvivid_add_remote_notice', true, $success_msg);
|
2395 |
+
}
|
2396 |
+
else{
|
2397 |
+
$ret['notice'] = apply_filters('wpvivid_add_remote_notice', false, $ret['error']);
|
2398 |
}
|
2399 |
}
|
2400 |
catch (Exception $error) {
|
2532 |
$remote_storage = '';
|
2533 |
$remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
|
2534 |
$ret['remote_storage'] = $remote_storage;
|
2535 |
+
$success_msg = 'You have successfully updated the account information of your remote storage.';
|
2536 |
+
$ret['notice'] = apply_filters('wpvivid_add_remote_notice', true, $success_msg);
|
2537 |
+
}
|
2538 |
+
else{
|
2539 |
+
$ret['notice'] = apply_filters('wpvivid_add_remote_notice', false, $ret['error']);
|
2540 |
}
|
2541 |
}
|
2542 |
catch (Exception $error) {
|
2692 |
|
2693 |
$ret = $backup_item->check_backup_files();
|
2694 |
|
2695 |
+
$ret['is_migrate'] = $backup_item->check_migrate_file();
|
2696 |
+
|
2697 |
+
if ($backup_item->get_backup_type() == 'Upload' || $backup_item->get_backup_type() == 'Migration')
|
2698 |
+
{
|
2699 |
+
if( $ret['is_migrate']==0)
|
2700 |
+
$ret['is_migrate_ui'] = 1;
|
2701 |
+
else
|
2702 |
+
$ret['is_migrate_ui'] = 0;
|
2703 |
} else {
|
2704 |
+
$ret['is_migrate_ui'] = 0;
|
2705 |
}
|
2706 |
|
2707 |
+
|
2708 |
+
|
2709 |
$ret['skip_backup_old_site'] = 1;
|
2710 |
$ret['skip_backup_old_database'] = 1;
|
2711 |
|
2744 |
die();
|
2745 |
}
|
2746 |
|
2747 |
+
public function get_restore_file_is_migrate()
|
2748 |
+
{
|
2749 |
+
$this->ajax_check_security();
|
2750 |
+
try {
|
2751 |
+
if (!isset($_POST['backup_id']) || empty($_POST['backup_id']) || !is_string($_POST['backup_id'])) {
|
2752 |
+
die();
|
2753 |
+
}
|
2754 |
+
|
2755 |
+
$backup_id = sanitize_key($_POST['backup_id']);
|
2756 |
+
|
2757 |
+
$backup = WPvivid_Backuplist::get_backuplist_by_key($backup_id);
|
2758 |
+
|
2759 |
+
$backup_item = new WPvivid_Backup_Item($backup);
|
2760 |
+
|
2761 |
+
$ret = $backup_item->check_backup_files();
|
2762 |
+
|
2763 |
+
$ret['is_migrate'] = $backup_item->check_migrate_file();
|
2764 |
+
|
2765 |
+
if ($backup_item->get_backup_type() == 'Upload' || $backup_item->get_backup_type() == 'Migration')
|
2766 |
+
{
|
2767 |
+
if( $ret['is_migrate']==0)
|
2768 |
+
$ret['is_migrate_ui'] = 1;
|
2769 |
+
else
|
2770 |
+
$ret['is_migrate_ui'] = 0;
|
2771 |
+
} else {
|
2772 |
+
$ret['is_migrate_ui'] = 0;
|
2773 |
+
}
|
2774 |
+
|
2775 |
+
if ($ret['result'] == WPVIVID_FAILED) {
|
2776 |
+
$this->wpvivid_handle_restore_error($ret['error'], 'Init restore page');
|
2777 |
+
}
|
2778 |
+
|
2779 |
+
echo json_encode($ret);
|
2780 |
+
}
|
2781 |
+
catch (Exception $error) {
|
2782 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
2783 |
+
error_log($message);
|
2784 |
+
echo json_encode(array('result'=>'failed','error'=>$message));
|
2785 |
+
die();
|
2786 |
+
}
|
2787 |
+
die();
|
2788 |
+
}
|
2789 |
+
|
2790 |
public function delete_last_restore_data()
|
2791 |
{
|
2792 |
$this->ajax_check_security();
|
2842 |
|
2843 |
$ret = $backup_item->check_backup_files();
|
2844 |
|
2845 |
+
if ($backup_item->get_backup_type() == 'Upload')
|
2846 |
+
{
|
2847 |
$ret['is_migrate'] = 1;
|
2848 |
} else {
|
2849 |
$ret['is_migrate'] = 0;
|
2898 |
die();
|
2899 |
}
|
2900 |
|
2901 |
+
//$downloader = new WPvivid_downloader();
|
2902 |
+
//$ret = $downloader->download($file, $local_path, $remote_option);
|
2903 |
+
$download_info = array();
|
2904 |
+
$download_info['backup_id'] = sanitize_key($_POST['backup_id']);
|
2905 |
+
//$download_info['file_name']=sanitize_file_name($_POST['file_name']);
|
2906 |
+
$download_info['file_name'] = $_POST['file_name'];
|
2907 |
+
//set_time_limit(600);
|
2908 |
+
if (session_id())
|
2909 |
+
session_write_close();
|
2910 |
+
|
2911 |
$downloader = new WPvivid_downloader();
|
2912 |
+
$downloader->ready_download($download_info);
|
2913 |
|
2914 |
+
$ret['result'] = 'success';
|
2915 |
echo json_encode($ret);
|
2916 |
}
|
2917 |
catch (Exception $error) {
|
2940 |
} else {
|
2941 |
$ret['result'] = WPVIVID_SUCCESS;
|
2942 |
$ret['status'] = $task['status'];
|
2943 |
+
$ret['log'] = $task['download_descript'];
|
2944 |
$ret['error'] = $task['error'];
|
2945 |
echo json_encode($ret);
|
2946 |
}
|
3515 |
$error_notice_html = array();
|
3516 |
foreach ($backup_error_array as $key => $value){
|
3517 |
$error_notice_html['bu_error']['task_id']=$value['task_id'];
|
3518 |
+
$error_notice_html['bu_error']['error_msg']=$value['error_msg'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3519 |
}
|
3520 |
WPvivid_Setting::delete_option('wpvivid_backup_error_array');
|
3521 |
$html = '';
|
3541 |
}
|
3542 |
$backup_item=new WPvivid_Backup_Item($backup);
|
3543 |
$ret['download']=$backup_item->update_download_page($backup_id);
|
|
|
|
|
3544 |
}
|
3545 |
|
3546 |
$html='';
|
4082 |
$remote_storage = '';
|
4083 |
$remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
|
4084 |
$ret['remote_storage'] = $remote_storage;
|
4085 |
+
$success_msg = 'You have successfully changed your default remote storage.';
|
4086 |
+
$ret['notice'] = apply_filters('wpvivid_add_remote_notice', true, $success_msg);
|
4087 |
echo json_encode($ret);
|
4088 |
}
|
4089 |
catch (Exception $error) {
|
4749 |
|
4750 |
public function get_website_info()
|
4751 |
{
|
4752 |
+
try {
|
4753 |
+
$ret['result'] = 'success';
|
4754 |
+
$ret['data']['version'] = $this->version;
|
4755 |
+
$ret['data']['home_url'] = get_home_url();
|
4756 |
+
$ret['data']['abspath'] = ABSPATH;
|
4757 |
+
$ret['data']['wp_content_path'] = WP_CONTENT_DIR;
|
4758 |
+
$ret['data']['wp_plugin_path'] = WP_PLUGIN_DIR;
|
4759 |
+
$ret['data']['active_plugins'] = get_option('active_plugins');
|
4760 |
+
|
4761 |
+
global $wp_version;
|
4762 |
+
$ret['wp_version'] = $wp_version;
|
4763 |
+
if (is_multisite()) {
|
4764 |
+
$ret['data']['multisite'] = 'enable';
|
4765 |
+
} else {
|
4766 |
+
$ret['data']['multisite'] = 'disable';
|
4767 |
+
}
|
4768 |
+
$ret['data']['web_server'] = $_SERVER["SERVER_SOFTWARE"];
|
4769 |
+
$ret['data']['php_version'] = phpversion();
|
4770 |
+
global $wpdb;
|
4771 |
+
$ret['data']['mysql_version'] = $wpdb->db_version();
|
4772 |
+
if (defined('WP_DEBUG')) {
|
4773 |
+
$ret['data']['wp_debug'] = WP_DEBUG;
|
4774 |
+
} else {
|
4775 |
+
$ret['wp_debug'] = false;
|
4776 |
+
}
|
4777 |
+
$ret['data']['language'] = get_bloginfo('language');
|
4778 |
+
$ret['data']['upload_max_filesize'] = ini_get("upload_max_filesize");
|
|
|
|
|
|
|
|
|
|
|
4779 |
|
4780 |
+
$options = WPvivid_Setting::get_option('wpvivid_common_setting');
|
4781 |
+
if (isset($options['max_execution_time'])) {
|
4782 |
+
$limit = $options['max_execution_time'];
|
4783 |
+
} else {
|
4784 |
+
$limit = WPVIVID_MAX_EXECUTION_TIME;
|
4785 |
+
}
|
4786 |
+
ini_set('max_execution_time', $limit);
|
4787 |
+
|
4788 |
+
|
4789 |
+
$ret['data']['max_execution_time'] = ini_get("max_execution_time");
|
4790 |
+
$ret['data']['max_input_vars'] = ini_get("max_input_vars");
|
4791 |
+
$ret['data']['max_input_vars'] = ini_get("max_input_vars");
|
4792 |
+
$ret['data']['timezone'] = date_default_timezone_get();
|
4793 |
+
$ret['data']['OS'] = php_uname();
|
4794 |
+
$ret['data']['memory_current'] = $this->formatBytes(memory_get_usage());
|
4795 |
+
$ret['data']['memory_peak'] = $this->formatBytes(memory_get_peak_usage());
|
4796 |
+
$ret['data']['memory_limit'] = ini_get('memory_limit');
|
4797 |
+
$ret['data']['post_max_size'] = ini_get('post_max_size');
|
4798 |
+
$ret['data']['allow_url_fopen'] = ini_get('allow_url_fopen');
|
4799 |
+
$ret['data']['safe_mode'] = ini_get('safe_mode');
|
4800 |
+
$ret['data']['pcre.backtrack_limit'] = ini_get('pcre.backtrack_limit');
|
4801 |
+
$extensions = get_loaded_extensions();
|
4802 |
+
if (array_search('exif', $extensions)) {
|
4803 |
+
$ret['data']['exif'] = 'support';
|
4804 |
+
} else {
|
4805 |
+
$ret['data']['exif'] = 'not support';
|
4806 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
4807 |
|
4808 |
+
if (array_search('xml', $extensions)) {
|
4809 |
+
$ret['data']['xml'] = 'support';
|
4810 |
+
} else {
|
4811 |
+
$ret['data']['xml'] = 'not support';
|
4812 |
+
}
|
|
|
|
|
|
|
4813 |
|
4814 |
+
if (array_search('suhosin', $extensions)) {
|
4815 |
+
$ret['data']['suhosin'] = 'support';
|
4816 |
+
} else {
|
4817 |
+
$ret['data']['suhosin'] = 'not support';
|
4818 |
+
}
|
|
|
|
|
|
|
4819 |
|
4820 |
+
if (array_search('gd', $extensions)) {
|
4821 |
+
$ret['data']['IPTC'] = 'support';
|
4822 |
+
} else {
|
4823 |
+
$ret['data']['IPTC'] = 'not support';
|
4824 |
+
}
|
|
|
|
|
|
|
4825 |
|
4826 |
+
$ret['data']['extensions'] = $extensions;
|
4827 |
|
4828 |
+
if (function_exists('apache_get_modules')) {
|
4829 |
+
$ret['data']['apache_modules'] = apache_get_modules();
|
4830 |
+
} else {
|
4831 |
+
$ret['data']['apache_modules'] = array();
|
4832 |
+
}
|
|
|
|
|
|
|
4833 |
|
4834 |
+
if (array_search('pdo_mysql', $extensions)) {
|
4835 |
+
$ret['data']['pdo_mysql'] = 'support';
|
4836 |
+
} else {
|
4837 |
+
$ret['data']['pdo_mysql'] = 'not support';
|
4838 |
+
}
|
|
|
|
|
|
|
4839 |
|
4840 |
+
if ($ret['data']['pdo_mysql'] == 'support') {
|
4841 |
+
$db_method = new WPvivid_DB_Method();
|
4842 |
+
$ret_sql_mode = $db_method->get_sql_mode();
|
4843 |
+
if ($ret_sql_mode['result'] == WPVIVID_FAILED) {
|
4844 |
+
$ret['data']['mysql_mode'] = '';
|
4845 |
+
} else {
|
4846 |
+
$ret['data']['mysql_mode'] = $ret_sql_mode['mysql_mode'];
|
4847 |
+
$ret['mysql_mode'] = $ret_sql_mode['mysql_mode'];
|
4848 |
+
}
|
4849 |
+
} else {
|
4850 |
+
$ret['data']['mysql_mode'] = '';
|
4851 |
}
|
4852 |
+
if (!class_exists('PclZip')) include_once(ABSPATH . '/wp-admin/includes/class-pclzip.php');
|
4853 |
+
if (!class_exists('PclZip')) {
|
4854 |
+
$ret['data']['PclZip'] = 'not support';
|
4855 |
+
} else {
|
4856 |
+
$ret['data']['PclZip'] = 'support';
|
4857 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4858 |
|
4859 |
+
if (is_multisite() && !defined('MULTISITE')) {
|
4860 |
+
$prefix = $wpdb->base_prefix;
|
4861 |
+
} else {
|
4862 |
+
$prefix = $wpdb->get_blog_prefix(0);
|
4863 |
+
}
|
|
|
4864 |
|
4865 |
+
$ret['data']['wp_prefix'] = $prefix;
|
4866 |
|
4867 |
+
$sapi_type = php_sapi_name();
|
4868 |
|
4869 |
+
if ($sapi_type == 'cgi-fcgi' || $sapi_type == ' fpm-fcgi') {
|
4870 |
+
$ret['data']['fast_cgi'] = 'On';
|
4871 |
+
} else {
|
4872 |
+
$ret['data']['fast_cgi'] = 'Off';
|
4873 |
+
}
|
4874 |
}
|
4875 |
+
catch (Exception $error) {
|
4876 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
4877 |
+
error_log($message);
|
4878 |
+
return array('result'=>'failed','error'=>$message);
|
4879 |
}
|
4880 |
return $ret;
|
4881 |
}
|
5054 |
return $remote_storage;
|
5055 |
}
|
5056 |
|
5057 |
+
public function wpvivid_add_remote_notice($notice_type, $message){
|
5058 |
+
$html = '';
|
5059 |
+
if($notice_type) {
|
5060 |
+
$html .= __('<div class="notice notice-success is-dismissible inline"><p>'.$message.'</p>
|
5061 |
+
<button type="button" class="notice-dismiss" onclick="click_dismiss_notice(this);">
|
5062 |
+
<span class="screen-reader-text">Dismiss this notice.</span>
|
5063 |
+
</button>
|
5064 |
+
</div>');
|
5065 |
+
|
5066 |
+
}
|
5067 |
+
else{
|
5068 |
+
$html .= __('<div class="notice notice-error"><p>' . $message . '</p></div>');
|
5069 |
+
}
|
5070 |
+
return $html;
|
5071 |
+
}
|
5072 |
+
|
5073 |
public function wpvivid_schedule_add_remote_pic($html){
|
5074 |
$html = '';
|
5075 |
$remoteslist=WPvivid_Setting::get_all_remote_options();
|
5324 |
}
|
5325 |
die();
|
5326 |
}
|
5327 |
+
|
5328 |
+
public function wpvivid_check_zip_valid()
|
5329 |
+
{
|
5330 |
+
return true;
|
5331 |
+
}
|
5332 |
}
|
includes/customclass/class-wpvivid-amazons3-plus.php
CHANGED
@@ -45,6 +45,14 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
45 |
|
46 |
public function wpvivid_add_storage_page_amazons3()
|
47 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
?>
|
49 |
<div id="storage_account_amazons3" class="storage-account-page" style="display:none;">
|
50 |
<h2><span><?php _e( 'Enter Your Amazon S3 Account ','wpvivid'); ?></span></h2>
|
@@ -80,7 +88,16 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
80 |
</label>
|
81 |
</div>
|
82 |
<div id="wpvivid_storage_account_notice"></div>
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
</div>
|
85 |
<script>
|
86 |
jQuery("input:text[option=amazons3][name=s3Path]").keyup(function(){
|
@@ -150,19 +167,22 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
150 |
|
151 |
public function test_connect()
|
152 |
{
|
153 |
-
$amazons3 = $this -> getS3();
|
154 |
-
if(is_array($amazons3) && $amazons3['result'] === WPVIVID_FAILED)
|
155 |
-
return $amazons3;
|
156 |
-
|
157 |
-
$temp_file = md5(rand());
|
158 |
try{
|
|
|
|
|
|
|
|
|
159 |
if(!$amazons3 -> putObjectString($temp_file,$this -> bucket,$this->options['s3Path'].$temp_file)){
|
160 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, but create test file failed.');
|
161 |
}
|
162 |
if(!$amazons3 -> deleteObject($this -> bucket,$this->options['s3Path'].$temp_file)){
|
163 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, and create test file succeed, but delete test file failed.');
|
164 |
}
|
165 |
-
}
|
|
|
|
|
|
|
|
|
166 |
return array('result'=>WPVIVID_FAILED,'error'=>$e -> getMessage());
|
167 |
}
|
168 |
return array('result'=>WPVIVID_SUCCESS);
|
@@ -260,7 +280,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
260 |
$file_data['uploaded']=0;
|
261 |
$job_data[basename($file)]=$file_data;
|
262 |
}
|
263 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,
|
264 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
265 |
}
|
266 |
|
@@ -296,7 +316,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
296 |
{
|
297 |
try
|
298 |
{
|
299 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,
|
300 |
if($chunk_num > 1)
|
301 |
{
|
302 |
if(!empty($upload_job['job_data'][basename($file)]['upload_id']))
|
@@ -305,7 +325,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
305 |
}else{
|
306 |
$build_id = $amazons3 -> initiateMultipartUpload($this -> bucket,$this->options['s3Path'].$this -> current_file_name);
|
307 |
$upload_job['job_data'][basename($file)]['upload_id'] = $build_id;
|
308 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,
|
309 |
}
|
310 |
if(!empty($upload_job['job_data'][basename($file)]['upload_chunks']))
|
311 |
{
|
@@ -313,7 +333,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
313 |
}else{
|
314 |
$chunks = array();
|
315 |
$upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
|
316 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,
|
317 |
}
|
318 |
|
319 |
for($i =sizeof($chunks);$i <$chunk_num;$i ++)
|
@@ -322,12 +342,12 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
322 |
if(!$chunk_id){
|
323 |
$chunks = array();
|
324 |
$upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
|
325 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,
|
326 |
return array('result' => WPVIVID_FAILED,'error' => 'upload '.$file.' failed.');
|
327 |
}
|
328 |
$chunks[] = $chunk_id;
|
329 |
$upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
|
330 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,
|
331 |
|
332 |
$offset = (($i + 1) * $this -> upload_chunk_size) > $this -> current_file_size ? $this -> current_file_size : (($i + 1) * $this -> upload_chunk_size);
|
333 |
if((time() - $this -> last_time) >3)
|
@@ -358,7 +378,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
358 |
}
|
359 |
if($result){
|
360 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
361 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,
|
362 |
break;
|
363 |
}
|
364 |
if(!$result && $i == (WPVIVID_REMOTE_CONNECT_RETRY_TIMES - 1))
|
@@ -372,53 +392,67 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
|
|
372 |
|
373 |
public function download($file,$local_path,$callback = '')
|
374 |
{
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
|
|
|
|
383 |
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
while($start_offset < $this
|
390 |
-
|
391 |
-
$last_byte = min($start_offset + $this -> download_chunk_size - 1,$this -> current_file_size-1);
|
392 |
$headers['Range'] = "bytes=$start_offset-$last_byte";
|
393 |
-
$response = $amazons3
|
394 |
-
if(!$response)
|
395 |
-
return array('result' => WPVIVID_FAILED,'error'=> 'download '
|
396 |
clearstatcache();
|
397 |
$state = stat($file_path);
|
398 |
$start_offset = $state['size'];
|
399 |
|
400 |
-
if((time() - $this
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
call_user_func_array($callback,array($start_offset,$this -> current_file_name,
|
405 |
-
$this->current_file_size,$this -> last_time,$this -> last_size));
|
406 |
}
|
407 |
-
$this
|
408 |
-
$this
|
409 |
}
|
410 |
}
|
411 |
-
|
412 |
-
|
413 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
}
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
return array('result' => WPVIVID_FAILED, 'error' =>'file md5 is not matched.');
|
420 |
}
|
421 |
-
return array('result' => WPVIVID_SUCCESS);
|
422 |
}
|
423 |
|
424 |
public function cleanup($files)
|
45 |
|
46 |
public function wpvivid_add_storage_page_amazons3()
|
47 |
{
|
48 |
+
if(!function_exists('simplexml_load_string')){
|
49 |
+
$need_extension = true;
|
50 |
+
$add_btn_style = 'pointer-events: none; opacity: 0.4;';
|
51 |
+
}
|
52 |
+
else{
|
53 |
+
$need_extension = false;
|
54 |
+
$add_btn_style = 'pointer-events: auto; opacity: 1;';
|
55 |
+
}
|
56 |
?>
|
57 |
<div id="storage_account_amazons3" class="storage-account-page" style="display:none;">
|
58 |
<h2><span><?php _e( 'Enter Your Amazon S3 Account ','wpvivid'); ?></span></h2>
|
88 |
</label>
|
89 |
</div>
|
90 |
<div id="wpvivid_storage_account_notice"></div>
|
91 |
+
<?php
|
92 |
+
if($need_extension){
|
93 |
+
?>
|
94 |
+
<p style="padding-left: 10px;">The simplexml extension is not detected. Please install the extension first.</p>
|
95 |
+
<?php
|
96 |
+
}
|
97 |
+
?>
|
98 |
+
<div>
|
99 |
+
<input class="button-primary storage-account-button" option="add-remote" type="button" name="Example" value="<?php _e( 'Test and Add', 'wpvivid' ); ?>" style="<?php esc_attr_e($add_btn_style); ?>" />
|
100 |
+
</div>
|
101 |
</div>
|
102 |
<script>
|
103 |
jQuery("input:text[option=amazons3][name=s3Path]").keyup(function(){
|
167 |
|
168 |
public function test_connect()
|
169 |
{
|
|
|
|
|
|
|
|
|
|
|
170 |
try{
|
171 |
+
$amazons3 = $this -> getS3();
|
172 |
+
if(is_array($amazons3) && $amazons3['result'] === WPVIVID_FAILED)
|
173 |
+
return $amazons3;
|
174 |
+
$temp_file = md5(rand());
|
175 |
if(!$amazons3 -> putObjectString($temp_file,$this -> bucket,$this->options['s3Path'].$temp_file)){
|
176 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, but create test file failed.');
|
177 |
}
|
178 |
if(!$amazons3 -> deleteObject($this -> bucket,$this->options['s3Path'].$temp_file)){
|
179 |
return array('result'=>WPVIVID_FAILED,'error'=>'We successfully accessed the bucket, and create test file succeed, but delete test file failed.');
|
180 |
}
|
181 |
+
}
|
182 |
+
catch(Exception $e){
|
183 |
+
return array('result'=>WPVIVID_FAILED,'error'=>$e -> getMessage());
|
184 |
+
}
|
185 |
+
catch(Error $e){
|
186 |
return array('result'=>WPVIVID_FAILED,'error'=>$e -> getMessage());
|
187 |
}
|
188 |
return array('result'=>WPVIVID_SUCCESS);
|
280 |
$file_data['uploaded']=0;
|
281 |
$job_data[basename($file)]=$file_data;
|
282 |
}
|
283 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,WPVIVID_UPLOAD_UNDO,'Start uploading',$job_data);
|
284 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
285 |
}
|
286 |
|
316 |
{
|
317 |
try
|
318 |
{
|
319 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,WPVIVID_UPLOAD_UNDO,'Start uploading '.basename($file).'.',$upload_job['job_data']);
|
320 |
if($chunk_num > 1)
|
321 |
{
|
322 |
if(!empty($upload_job['job_data'][basename($file)]['upload_id']))
|
325 |
}else{
|
326 |
$build_id = $amazons3 -> initiateMultipartUpload($this -> bucket,$this->options['s3Path'].$this -> current_file_name);
|
327 |
$upload_job['job_data'][basename($file)]['upload_id'] = $build_id;
|
328 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,WPVIVID_UPLOAD_UNDO,'InitiateMultipartUpload, created build id of '.basename($file).'.',$upload_job['job_data']);
|
329 |
}
|
330 |
if(!empty($upload_job['job_data'][basename($file)]['upload_chunks']))
|
331 |
{
|
333 |
}else{
|
334 |
$chunks = array();
|
335 |
$upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
|
336 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,WPVIVID_UPLOAD_UNDO,'Start multipartupload of '.basename($file).'.',$upload_job['job_data']);
|
337 |
}
|
338 |
|
339 |
for($i =sizeof($chunks);$i <$chunk_num;$i ++)
|
342 |
if(!$chunk_id){
|
343 |
$chunks = array();
|
344 |
$upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
|
345 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,WPVIVID_UPLOAD_FAILED,'Start multipartupload of '.basename($file).'.',$upload_job['job_data']);
|
346 |
return array('result' => WPVIVID_FAILED,'error' => 'upload '.$file.' failed.');
|
347 |
}
|
348 |
$chunks[] = $chunk_id;
|
349 |
$upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
|
350 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,WPVIVID_UPLOAD_UNDO,'Uploading '.basename($file).'.',$upload_job['job_data']);
|
351 |
|
352 |
$offset = (($i + 1) * $this -> upload_chunk_size) > $this -> current_file_size ? $this -> current_file_size : (($i + 1) * $this -> upload_chunk_size);
|
353 |
if((time() - $this -> last_time) >3)
|
378 |
}
|
379 |
if($result){
|
380 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
381 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
382 |
break;
|
383 |
}
|
384 |
if(!$result && $i == (WPVIVID_REMOTE_CONNECT_RETRY_TIMES - 1))
|
392 |
|
393 |
public function download($file,$local_path,$callback = '')
|
394 |
{
|
395 |
+
try {
|
396 |
+
global $wpvivid_pulgin;
|
397 |
+
$this->current_file_name = $file['file_name'];
|
398 |
+
$this->current_file_size = $file['size'];
|
399 |
+
$file_md5 = $file['md5'];
|
400 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Get amazons3 client.','notice');
|
401 |
+
$amazons3 = $this->getS3();
|
402 |
+
if (is_array($amazons3) && $amazons3['result'] === WPVIVID_FAILED) {
|
403 |
+
return $amazons3;
|
404 |
+
}
|
405 |
|
406 |
+
$file_path = trailingslashit($local_path) . $this->current_file_name;
|
407 |
+
$start_offset = file_exists($file_path) ? filesize($file_path) : 0;
|
408 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Create local file.','notice');
|
409 |
+
$fh = fopen($file_path, 'a');
|
410 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Downloading file ' . $file['file_name'] . ', Size: ' . $file['size'] ,'notice');
|
411 |
+
while ($start_offset < $this->current_file_size) {
|
412 |
+
$last_byte = min($start_offset + $this->download_chunk_size - 1, $this->current_file_size - 1);
|
|
|
413 |
$headers['Range'] = "bytes=$start_offset-$last_byte";
|
414 |
+
$response = $amazons3->getObject($this->bucket, $this->options['s3Path'] . $this->current_file_name, $fh, $headers['Range']);
|
415 |
+
if (!$response)
|
416 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'download ' . $this->options['s3Path'] . $this->current_file_name . ' failed.');
|
417 |
clearstatcache();
|
418 |
$state = stat($file_path);
|
419 |
$start_offset = $state['size'];
|
420 |
|
421 |
+
if ((time() - $this->last_time) > 3) {
|
422 |
+
if (is_callable($callback)) {
|
423 |
+
call_user_func_array($callback, array($start_offset, $this->current_file_name,
|
424 |
+
$this->current_file_size, $this->last_time, $this->last_size));
|
|
|
|
|
425 |
}
|
426 |
+
$this->last_size = $start_offset;
|
427 |
+
$this->last_time = time();
|
428 |
}
|
429 |
}
|
430 |
+
@fclose($fh);
|
431 |
+
|
432 |
+
if(filesize($file_path) === $file['size']){
|
433 |
+
if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
|
434 |
+
$res = TRUE;
|
435 |
+
}
|
436 |
+
else{
|
437 |
+
$res = FALSE;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
else{
|
441 |
+
$res = FALSE;
|
442 |
+
}
|
443 |
+
|
444 |
+
if ($res !== TRUE) {
|
445 |
+
@unlink($file_path);
|
446 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Downloading ' . $file['file_name'] . ' failed. ' . $file['file_name'] . ' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.');
|
447 |
+
}
|
448 |
+
|
449 |
+
return array('result' => WPVIVID_SUCCESS);
|
450 |
}
|
451 |
+
catch (Exception $error){
|
452 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
453 |
+
error_log($message);
|
454 |
+
return array('result'=>WPVIVID_FAILED, 'error'=>$message);
|
|
|
455 |
}
|
|
|
456 |
}
|
457 |
|
458 |
public function cleanup($files)
|
includes/customclass/class-wpvivid-dropbox.php
CHANGED
@@ -16,7 +16,6 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
16 |
private $upload_chunk_size = 2097152;
|
17 |
private $download_chunk_size = 2097152;
|
18 |
private $redirect_url = 'https://auth.wpvivid.com/dropbox_v2/';
|
19 |
-
|
20 |
public function __construct($options = array())
|
21 |
{
|
22 |
if(empty($options)){
|
@@ -93,7 +92,7 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
93 |
$file_data['uploaded']=0;
|
94 |
$job_data[basename($file)]=$file_data;
|
95 |
}
|
96 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,
|
97 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX);
|
98 |
}
|
99 |
|
@@ -128,7 +127,7 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
128 |
|
129 |
if($this -> current_file_size > $this -> upload_chunk_size){
|
130 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Creating upload session.','notice');
|
131 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,
|
132 |
$result = $dropbox -> upload_session_start();
|
133 |
if(isset($result['error_summary'])){
|
134 |
return array('result'=>WPVIVID_FAILED,'error'=>$result['error_summary']);
|
@@ -139,10 +138,10 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
139 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Uploaded files are less than 2M.','notice');
|
140 |
$result = $dropbox -> upload($path,$file);
|
141 |
if(isset($result['error_summary'])){
|
142 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,
|
143 |
$result = array('result' => WPVIVID_FAILED,'error' => $result['error_summary']);
|
144 |
}else{
|
145 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,
|
146 |
$result = array('result'=> WPVIVID_SUCCESS);
|
147 |
}
|
148 |
}
|
@@ -197,48 +196,68 @@ class WPvivid_Dropbox extends WPvivid_Remote {
|
|
197 |
|
198 |
public function download($file, $local_path, $callback = '')
|
199 |
{
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$
|
213 |
-
$
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
}
|
220 |
-
|
221 |
-
$state = stat($file_path);
|
222 |
-
$start_offset = $state['size'];
|
223 |
|
224 |
-
if((
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
}
|
231 |
-
$this -> last_size = $start_offset;
|
232 |
-
$this -> last_time = time();
|
233 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
return array('result' => WPVIVID_FAILED, 'error' =>'file md5 is not matched.');
|
240 |
}
|
241 |
-
return array('result' => WPVIVID_SUCCESS);
|
242 |
}
|
243 |
|
244 |
public function cleanup($files)
|
16 |
private $upload_chunk_size = 2097152;
|
17 |
private $download_chunk_size = 2097152;
|
18 |
private $redirect_url = 'https://auth.wpvivid.com/dropbox_v2/';
|
|
|
19 |
public function __construct($options = array())
|
20 |
{
|
21 |
if(empty($options)){
|
92 |
$file_data['uploaded']=0;
|
93 |
$job_data[basename($file)]=$file_data;
|
94 |
}
|
95 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,WPVIVID_UPLOAD_UNDO,'Start uploading',$job_data);
|
96 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX);
|
97 |
}
|
98 |
|
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,WPVIVID_UPLOAD_UNDO,'Start uploading '.basename($file).'.',$upload_job['job_data']);
|
131 |
$result = $dropbox -> upload_session_start();
|
132 |
if(isset($result['error_summary'])){
|
133 |
return array('result'=>WPVIVID_FAILED,'error'=>$result['error_summary']);
|
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,WPVIVID_UPLOAD_FAILED,'Uploading '.basename($file).' failed.',$upload_job['job_data']);
|
142 |
$result = array('result' => WPVIVID_FAILED,'error' => $result['error_summary']);
|
143 |
}else{
|
144 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_DROPBOX,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
145 |
$result = array('result'=> WPVIVID_SUCCESS);
|
146 |
}
|
147 |
}
|
196 |
|
197 |
public function download($file, $local_path, $callback = '')
|
198 |
{
|
199 |
+
try {
|
200 |
+
global $wpvivid_pulgin;
|
201 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Remote type: Dropbox.','notice');
|
202 |
+
$this->current_file_name = $file['file_name'];
|
203 |
+
$this->current_file_size = $file['size'];
|
204 |
+
$file_md5 = $file['md5'];
|
205 |
+
$options = $this->options;
|
206 |
+
$dropbox = new Dropbox_Base($options);
|
207 |
+
|
208 |
+
$file_path = trailingslashit($local_path) . $this->current_file_name;
|
209 |
+
$start_offset = file_exists($file_path) ? filesize($file_path) : 0;
|
210 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Create local file.','notice');
|
211 |
+
$fh = fopen($file_path, 'a');
|
212 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Downloading file ' . $file['file_name'] . ', Size: ' . $file['size'] ,'notice');
|
213 |
+
while ($start_offset < $this->current_file_size) {
|
214 |
+
$last_byte = min($start_offset + $this->download_chunk_size - 1, $this->current_file_size - 1);
|
215 |
+
$headers = array("Range: bytes=$start_offset-$last_byte");
|
216 |
+
$response = $dropbox->download(trailingslashit($options['path']) . $this->current_file_name, $headers);
|
217 |
+
if (isset($response['error_summary'])) {
|
218 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Downloading ' . trailingslashit($options['path']) . $this->current_file_name . ' failed.' . $response['error_summary']);
|
219 |
+
}
|
220 |
+
if (!fwrite($fh, $response)) {
|
221 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Downloading ' . trailingslashit($options['path']) . $this->current_file_name . ' failed.');
|
222 |
+
}
|
223 |
+
clearstatcache();
|
224 |
+
$state = stat($file_path);
|
225 |
+
$start_offset = $state['size'];
|
226 |
+
|
227 |
+
if ((time() - $this->last_time) > 3) {
|
228 |
+
if (is_callable($callback)) {
|
229 |
+
call_user_func_array($callback, array($start_offset, $this->current_file_name,
|
230 |
+
$this->current_file_size, $this->last_time, $this->last_size));
|
231 |
+
}
|
232 |
+
$this->last_size = $start_offset;
|
233 |
+
$this->last_time = time();
|
234 |
+
}
|
235 |
}
|
236 |
+
@fclose($fh);
|
|
|
|
|
237 |
|
238 |
+
if(filesize($file_path) === $file['size']){
|
239 |
+
if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
|
240 |
+
$res = TRUE;
|
241 |
+
}
|
242 |
+
else{
|
243 |
+
$res = FALSE;
|
244 |
}
|
|
|
|
|
245 |
}
|
246 |
+
else{
|
247 |
+
$res = FALSE;
|
248 |
+
}
|
249 |
+
|
250 |
+
if ($res !== TRUE) {
|
251 |
+
@unlink($file_path);
|
252 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Downloading ' . $file['file_name'] . ' failed. ' . $file['file_name'] . ' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.');
|
253 |
+
}
|
254 |
+
return array('result' => WPVIVID_SUCCESS);
|
255 |
}
|
256 |
+
catch (Exception $error){
|
257 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
258 |
+
error_log($message);
|
259 |
+
return array('result'=>WPVIVID_FAILED, 'error'=>$message);
|
|
|
260 |
}
|
|
|
261 |
}
|
262 |
|
263 |
public function cleanup($files)
|
includes/customclass/class-wpvivid-ftpclass.php
CHANGED
@@ -288,7 +288,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
288 |
$file_data['uploaded']=0;
|
289 |
$job_data[basename($file)]=$file_data;
|
290 |
}
|
291 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_FTP,
|
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');
|
@@ -353,7 +353,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
353 |
{
|
354 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
355 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
356 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_FTP,
|
357 |
break;
|
358 |
}
|
359 |
|
@@ -376,58 +376,77 @@ class WPvivid_FTPClass extends WPvivid_Remote{
|
|
376 |
|
377 |
public function download($file,$local_path,$callback = '')
|
378 |
{
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
|
|
|
|
|
|
|
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
|
|
|
|
415 |
}
|
416 |
-
$this -> last_size = ftell($local_handle);
|
417 |
-
$this -> last_time = time();
|
418 |
}
|
419 |
-
}
|
420 |
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
-
|
428 |
-
|
|
|
|
|
429 |
|
430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
|
433 |
public function cleanup($file){
|
288 |
$file_data['uploaded']=0;
|
289 |
$job_data[basename($file)]=$file_data;
|
290 |
}
|
291 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_FTP,WPVIVID_UPLOAD_UNDO,'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');
|
353 |
{
|
354 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
355 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
356 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_FTP,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
357 |
break;
|
358 |
}
|
359 |
|
376 |
|
377 |
public function download($file,$local_path,$callback = '')
|
378 |
{
|
379 |
+
try {
|
380 |
+
global $wpvivid_pulgin;
|
381 |
+
$passive = $this->options['passive'];
|
382 |
+
$host = $this->options['host'];
|
383 |
+
$username = $this->options['username'];
|
384 |
+
$password = $this->options['password'];
|
385 |
+
$path = $this->options['path'];
|
386 |
+
$port = empty($this->options['port']) ? 21 : $this->options['port'];
|
387 |
+
|
388 |
+
$local_path = trailingslashit($local_path) . $file['file_name'];
|
389 |
+
$md5 = $file['md5'];
|
390 |
+
$remote_file = trailingslashit($path) . $file['file_name'];
|
391 |
+
|
392 |
+
$this->current_file_name = $file['file_name'];
|
393 |
+
$this->current_file_size = $file['size'];
|
394 |
+
|
395 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Connecting FTP server.','notice');
|
396 |
+
$conn = $this->do_connect($host, $username, $password, $port);
|
397 |
+
if (is_array($conn) && array_key_exists('result', $conn)) {
|
398 |
+
return $conn;
|
399 |
+
}
|
400 |
|
401 |
+
ftp_pasv($conn, $passive);
|
402 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Create local file.','notice');
|
403 |
+
$local_handle = fopen($local_path, 'ab');
|
404 |
+
if (!$local_handle) {
|
405 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Unable to create the local file. Please make sure the folder is writable and try again.');
|
406 |
+
}
|
407 |
|
408 |
+
$stat = fstat($local_handle);
|
409 |
+
$offset = $stat['size'];
|
410 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Downloading file ' . $file['file_name'] . ', Size: ' . $file['size'] ,'notice');
|
411 |
+
$status = ftp_nb_fget($conn, $local_handle, $remote_file, FTP_BINARY, $offset);
|
412 |
+
while ($status == FTP_MOREDATA) {
|
413 |
+
$status = ftp_nb_continue($conn);
|
414 |
+
if ((time() - $this->last_time) > 3) {
|
415 |
+
if (is_callable($callback)) {
|
416 |
+
call_user_func_array($callback, array(ftell($local_handle), $this->current_file_name,
|
417 |
+
$this->current_file_size, $this->last_time, $this->last_size));
|
418 |
+
}
|
419 |
+
$this->last_size = ftell($local_handle);
|
420 |
+
$this->last_time = time();
|
421 |
}
|
|
|
|
|
422 |
}
|
|
|
423 |
|
424 |
+
if(filesize($local_path) === $file['size']){
|
425 |
+
if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
|
426 |
+
$res = TRUE;
|
427 |
+
}
|
428 |
+
else{
|
429 |
+
$res = FALSE;
|
430 |
+
}
|
431 |
+
}
|
432 |
+
else{
|
433 |
+
$res = FALSE;
|
434 |
+
}
|
435 |
|
436 |
+
if ($status != FTP_FINISHED || $res !== TRUE) {
|
437 |
+
@unlink($local_path);
|
438 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Downloading ' . $remote_file . ' failed. ' . $remote_file . ' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.');
|
439 |
+
}
|
440 |
|
441 |
+
ftp_close($conn);
|
442 |
+
fclose($local_handle);
|
443 |
+
return array('result' => WPVIVID_SUCCESS);
|
444 |
+
}
|
445 |
+
catch (Exception $error){
|
446 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
447 |
+
error_log($message);
|
448 |
+
return array('result'=>WPVIVID_FAILED, 'error'=>$message);
|
449 |
+
}
|
450 |
}
|
451 |
|
452 |
public function cleanup($file){
|
includes/customclass/class-wpvivid-google-drive.php
CHANGED
@@ -493,7 +493,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
493 |
$file_data['uploaded']=0;
|
494 |
$job_data[basename($file)]=$file_data;
|
495 |
}
|
496 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,
|
497 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE);
|
498 |
}
|
499 |
|
@@ -551,7 +551,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
551 |
$status = false;
|
552 |
$handle = fopen($file, "rb");
|
553 |
|
554 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,
|
555 |
|
556 |
$offset=0;
|
557 |
|
@@ -581,7 +581,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
581 |
{
|
582 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
583 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
584 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,
|
585 |
return array('result' =>WPVIVID_SUCCESS);
|
586 |
}
|
587 |
else
|
@@ -655,14 +655,16 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
655 |
|
656 |
public function download( $file, $local_path, $callback = '')
|
657 |
{
|
658 |
-
$this -> current_file_name = $file['file_name'];
|
659 |
-
$this -> current_file_size = $file['size'];
|
660 |
-
|
661 |
try
|
662 |
{
|
|
|
|
|
|
|
|
|
663 |
$client=$this->get_client();
|
664 |
-
if($client['result'] == WPVIVID_FAILED)
|
665 |
return $client;
|
|
|
666 |
$client = $client['data'];
|
667 |
|
668 |
if($client===false)
|
@@ -673,6 +675,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
673 |
$service = new Google_Service_Drive($client);
|
674 |
|
675 |
$path=$this->options['path'];
|
|
|
676 |
$folder_id=$this->get_folder($service,$path);
|
677 |
|
678 |
if($folder_id==false)
|
@@ -698,6 +701,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
698 |
$file_id=$file->getId();
|
699 |
break;
|
700 |
}
|
|
|
701 |
$download_url=$this->get_download_url($client,$file_id);
|
702 |
|
703 |
if(!empty($file_id)||!empty($download_url))
|
@@ -716,7 +720,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
716 |
$fh = fopen($file_path, 'a');
|
717 |
$upload_size = WPVIVID_GOOGLEDRIVE_UPLOAD_SIZE;
|
718 |
$http = $client->authorize();
|
719 |
-
|
720 |
while ($offset < $fileSize)
|
721 |
{
|
722 |
$upload_end=min($offset+$upload_size-1,$fileSize-1);
|
@@ -762,7 +766,6 @@ class Wpvivid_Google_drive extends WPvivid_Remote
|
|
762 |
{
|
763 |
return array('result' => WPVIVID_FAILED,'error' => $e -> getMessage());
|
764 |
}
|
765 |
-
|
766 |
return array('result' => WPVIVID_SUCCESS);
|
767 |
}
|
768 |
|
493 |
$file_data['uploaded']=0;
|
494 |
$job_data[basename($file)]=$file_data;
|
495 |
}
|
496 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,WPVIVID_UPLOAD_UNDO,'Start uploading',$job_data);
|
497 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE);
|
498 |
}
|
499 |
|
551 |
$status = false;
|
552 |
$handle = fopen($file, "rb");
|
553 |
|
554 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,WPVIVID_UPLOAD_UNDO,'Start uploading '.basename($file).'.',$upload_job['job_data']);
|
555 |
|
556 |
$offset=0;
|
557 |
|
581 |
{
|
582 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
583 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
584 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_GOOGLEDRIVE,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
585 |
return array('result' =>WPVIVID_SUCCESS);
|
586 |
}
|
587 |
else
|
655 |
|
656 |
public function download( $file, $local_path, $callback = '')
|
657 |
{
|
|
|
|
|
|
|
658 |
try
|
659 |
{
|
660 |
+
global $wpvivid_pulgin;
|
661 |
+
$this -> current_file_name = $file['file_name'];
|
662 |
+
$this -> current_file_size = $file['size'];
|
663 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Google Drive get client.','notice');
|
664 |
$client=$this->get_client();
|
665 |
+
if($client['result'] == WPVIVID_FAILED) {
|
666 |
return $client;
|
667 |
+
}
|
668 |
$client = $client['data'];
|
669 |
|
670 |
if($client===false)
|
675 |
$service = new Google_Service_Drive($client);
|
676 |
|
677 |
$path=$this->options['path'];
|
678 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Create local file.','notice');
|
679 |
$folder_id=$this->get_folder($service,$path);
|
680 |
|
681 |
if($folder_id==false)
|
701 |
$file_id=$file->getId();
|
702 |
break;
|
703 |
}
|
704 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Get download url.','notice');
|
705 |
$download_url=$this->get_download_url($client,$file_id);
|
706 |
|
707 |
if(!empty($file_id)||!empty($download_url))
|
720 |
$fh = fopen($file_path, 'a');
|
721 |
$upload_size = WPVIVID_GOOGLEDRIVE_UPLOAD_SIZE;
|
722 |
$http = $client->authorize();
|
723 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Downloading file ' . $file['file_name'] . ', Size: ' . $file['size'] ,'notice');
|
724 |
while ($offset < $fileSize)
|
725 |
{
|
726 |
$upload_end=min($offset+$upload_size-1,$fileSize-1);
|
766 |
{
|
767 |
return array('result' => WPVIVID_FAILED,'error' => $e -> getMessage());
|
768 |
}
|
|
|
769 |
return array('result' => WPVIVID_SUCCESS);
|
770 |
}
|
771 |
|
includes/customclass/class-wpvivid-one-drive.php
CHANGED
@@ -448,7 +448,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
448 |
$file_data['uploaded']=0;
|
449 |
$job_data[basename($file)]=$file_data;
|
450 |
}
|
451 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,
|
452 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE);
|
453 |
}
|
454 |
|
@@ -508,62 +508,60 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
508 |
|
509 |
public function download($file, $local_path, $callback = '')
|
510 |
{
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
{
|
523 |
-
return $ret;
|
524 |
}
|
525 |
-
}
|
526 |
|
527 |
-
|
528 |
-
|
529 |
|
530 |
-
|
531 |
-
{
|
532 |
-
return $ret;
|
533 |
-
}
|
534 |
-
|
535 |
-
$file_path=$local_path.$file['file_name'];
|
536 |
-
|
537 |
-
$fh = fopen($file_path, 'a');
|
538 |
-
|
539 |
-
$downloaded_start=filesize($file_path);
|
540 |
-
$url='https://graph.microsoft.com/v1.0/me/drive/root:/'.$this->options['path'].'/'.$file['file_name'].':/content';
|
541 |
-
$download_size=WPVIVID_ONEDRIVE_DOWNLOAD_SIZE;
|
542 |
-
$size=$file['size'];
|
543 |
-
while($downloaded_start<$size)
|
544 |
-
{
|
545 |
-
$ret=$this->download_loop($url,$downloaded_start,$download_size,$size);
|
546 |
-
if($ret['result']!=WPVIVID_SUCCESS)
|
547 |
-
{
|
548 |
return $ret;
|
549 |
}
|
550 |
|
551 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
|
553 |
-
|
554 |
-
|
555 |
-
if(
|
556 |
-
|
557 |
-
|
558 |
-
|
|
|
|
|
|
|
559 |
}
|
560 |
-
$this -> last_size = $downloaded_start;
|
561 |
-
$this -> last_time = time();
|
562 |
}
|
563 |
-
}
|
564 |
|
565 |
-
|
566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
}
|
568 |
|
569 |
private function download_loop($url,&$downloaded_start,$download_size,$file_size,$retry_count=0)
|
@@ -747,7 +745,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
747 |
$data=file_get_contents($file);
|
748 |
$args['body']=$data;
|
749 |
|
750 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,
|
751 |
|
752 |
$response=wp_remote_post('https://graph.microsoft.com/v1.0/me/drive/root:/'.$path.':/content',$args);
|
753 |
|
@@ -755,7 +753,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
755 |
{
|
756 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
757 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
758 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,
|
759 |
return array('result' =>WPVIVID_SUCCESS);
|
760 |
}
|
761 |
else
|
@@ -781,7 +779,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
781 |
|
782 |
$offset=0;
|
783 |
|
784 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,
|
785 |
|
786 |
$file_size=filesize($file);
|
787 |
$handle=fopen($file,'rb');
|
@@ -822,7 +820,7 @@ class WPvivid_one_drive extends WPvivid_Remote
|
|
822 |
fclose($handle);
|
823 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
824 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
825 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,
|
826 |
return array('result' =>WPVIVID_SUCCESS);
|
827 |
}
|
828 |
|
448 |
$file_data['uploaded']=0;
|
449 |
$job_data[basename($file)]=$file_data;
|
450 |
}
|
451 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,WPVIVID_UPLOAD_UNDO,'Start uploading',$job_data);
|
452 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE);
|
453 |
}
|
454 |
|
508 |
|
509 |
public function download($file, $local_path, $callback = '')
|
510 |
{
|
511 |
+
try {
|
512 |
+
$this->current_file_name = $file['file_name'];
|
513 |
+
$this->current_file_size = $file['size'];
|
514 |
+
|
515 |
+
global $wpvivid_pulgin;
|
516 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Remote type: OneDrive.','notice');
|
517 |
+
if ($this->need_refresh()) {
|
518 |
+
$ret = $this->refresh_token();
|
519 |
+
if ($ret['result'] === WPVIVID_FAILED) {
|
520 |
+
return $ret;
|
521 |
+
}
|
|
|
|
|
522 |
}
|
|
|
523 |
|
524 |
+
$path = $this->options['path'];
|
525 |
+
$ret = $this->check_file($file['file_name'], $path);
|
526 |
|
527 |
+
if ($ret['result'] === WPVIVID_FAILED) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
return $ret;
|
529 |
}
|
530 |
|
531 |
+
$file_path = $local_path . $file['file_name'];
|
532 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Create local file.','notice');
|
533 |
+
$fh = fopen($file_path, 'a');
|
534 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Downloading file ' . $file['file_name'] . ', Size: ' . $file['size'] ,'notice');
|
535 |
+
$downloaded_start = filesize($file_path);
|
536 |
+
$url = 'https://graph.microsoft.com/v1.0/me/drive/root:/' . $this->options['path'] . '/' . $file['file_name'] . ':/content';
|
537 |
+
$download_size = WPVIVID_ONEDRIVE_DOWNLOAD_SIZE;
|
538 |
+
$size = $file['size'];
|
539 |
+
while ($downloaded_start < $size) {
|
540 |
+
$ret = $this->download_loop($url, $downloaded_start, $download_size, $size);
|
541 |
+
if ($ret['result'] != WPVIVID_SUCCESS) {
|
542 |
+
return $ret;
|
543 |
+
}
|
544 |
|
545 |
+
fwrite($fh, $ret['body']);
|
546 |
+
|
547 |
+
if ((time() - $this->last_time) > 3) {
|
548 |
+
if (is_callable($callback)) {
|
549 |
+
call_user_func_array($callback, array($downloaded_start, $this->current_file_name,
|
550 |
+
$this->current_file_size, $this->last_time, $this->last_size));
|
551 |
+
}
|
552 |
+
$this->last_size = $downloaded_start;
|
553 |
+
$this->last_time = time();
|
554 |
}
|
|
|
|
|
555 |
}
|
|
|
556 |
|
557 |
+
fclose($fh);
|
558 |
+
return array('result' => WPVIVID_SUCCESS);
|
559 |
+
}
|
560 |
+
catch (Exception $error){
|
561 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
562 |
+
error_log($message);
|
563 |
+
return array('result'=>WPVIVID_FAILED, 'error'=>$message);
|
564 |
+
}
|
565 |
}
|
566 |
|
567 |
private function download_loop($url,&$downloaded_start,$download_size,$file_size,$retry_count=0)
|
745 |
$data=file_get_contents($file);
|
746 |
$args['body']=$data;
|
747 |
|
748 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,WPVIVID_UPLOAD_UNDO,'Start uploading '.basename($file).'.',$upload_job['job_data']);
|
749 |
|
750 |
$response=wp_remote_post('https://graph.microsoft.com/v1.0/me/drive/root:/'.$path.':/content',$args);
|
751 |
|
753 |
{
|
754 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
755 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
756 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
757 |
return array('result' =>WPVIVID_SUCCESS);
|
758 |
}
|
759 |
else
|
779 |
|
780 |
$offset=0;
|
781 |
|
782 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,WPVIVID_UPLOAD_UNDO,'Start uploading '.basename($file).'.',$upload_job['job_data']);
|
783 |
|
784 |
$file_size=filesize($file);
|
785 |
$handle=fopen($file,'rb');
|
820 |
fclose($handle);
|
821 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
822 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
823 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_ONEDRIVE,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
824 |
return array('result' =>WPVIVID_SUCCESS);
|
825 |
}
|
826 |
|
includes/customclass/class-wpvivid-remote-default.php
CHANGED
@@ -3,6 +3,21 @@ if (!defined('WPVIVID_PLUGIN_DIR')){
|
|
3 |
die;
|
4 |
}
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote.php';
|
7 |
class WPvivid_Remote_Defult extends WPvivid_Remote{
|
8 |
public function test_connect()
|
3 |
die;
|
4 |
}
|
5 |
|
6 |
+
if(!defined('WPVIVID_UPLOAD_SUCCESS'))
|
7 |
+
{
|
8 |
+
define('WPVIVID_UPLOAD_SUCCESS',1);
|
9 |
+
}
|
10 |
+
|
11 |
+
if(!defined('WPVIVID_UPLOAD_FAILED'))
|
12 |
+
{
|
13 |
+
define('WPVIVID_UPLOAD_FAILED',2);
|
14 |
+
}
|
15 |
+
|
16 |
+
if(!defined('WPVIVID_UPLOAD_UNDO'))
|
17 |
+
{
|
18 |
+
define('WPVIVID_UPLOAD_UNDO',0);
|
19 |
+
}
|
20 |
+
|
21 |
require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote.php';
|
22 |
class WPvivid_Remote_Defult extends WPvivid_Remote{
|
23 |
public function test_connect()
|
includes/customclass/class-wpvivid-s3compat.php
CHANGED
@@ -79,13 +79,14 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
79 |
|
80 |
public function test_connect()
|
81 |
{
|
82 |
-
$s3compat = $this -> getClient();
|
83 |
-
if(is_array($s3compat) && $s3compat['result'] == WPVIVID_FAILED){
|
84 |
-
return $s3compat;
|
85 |
-
}
|
86 |
-
|
87 |
-
$temp_file = md5(rand());
|
88 |
try{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
$result = $s3compat -> putObject(
|
90 |
array(
|
91 |
'Bucket'=>$this -> bucket,
|
@@ -108,6 +109,8 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
108 |
return array('result' => WPVIVID_FAILED,'error' => $e -> getAwsErrorCode().$e -> getMessage());
|
109 |
}catch(Exception $e){
|
110 |
return array('result' => WPVIVID_FAILED,'error' => $e -> getMessage());
|
|
|
|
|
111 |
}
|
112 |
return array('result' => WPVIVID_SUCCESS);
|
113 |
}
|
@@ -130,7 +133,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
130 |
$file_data['uploaded']=0;
|
131 |
$job_data[basename($file)]=$file_data;
|
132 |
}
|
133 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,
|
134 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
135 |
}
|
136 |
|
@@ -255,52 +258,73 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
|
|
255 |
|
256 |
public function download($file, $local_path, $callback = '')
|
257 |
{
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
272 |
$range = "bytes=$start_offset-$last_byte";
|
273 |
-
$response = $this
|
274 |
-
if($response['result'] === WPVIVID_FAILED)
|
275 |
return $response;
|
|
|
276 |
|
277 |
clearstatcache();
|
278 |
$state = stat($file_path);
|
279 |
$start_offset = $state['size'];
|
280 |
-
if((time() - $this
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
call_user_func_array($callback,array($start_offset,$this -> current_file_name,
|
285 |
-
$this->current_file_size,$this -> last_time,$this -> last_size));
|
286 |
}
|
287 |
-
$this
|
288 |
-
$this
|
289 |
}
|
290 |
}
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
}
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
|
|
301 |
}
|
302 |
-
return array('result' => WPVIVID_SUCCESS);
|
303 |
}
|
|
|
304 |
public function _download_loop($s3compat,$range,$fh){
|
305 |
try{
|
306 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES;$i ++){
|
79 |
|
80 |
public function test_connect()
|
81 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
try{
|
83 |
+
$s3compat = $this -> getClient();
|
84 |
+
if(is_array($s3compat) && $s3compat['result'] == WPVIVID_FAILED){
|
85 |
+
return $s3compat;
|
86 |
+
}
|
87 |
+
|
88 |
+
$temp_file = md5(rand());
|
89 |
+
|
90 |
$result = $s3compat -> putObject(
|
91 |
array(
|
92 |
'Bucket'=>$this -> bucket,
|
109 |
return array('result' => WPVIVID_FAILED,'error' => $e -> getAwsErrorCode().$e -> getMessage());
|
110 |
}catch(Exception $e){
|
111 |
return array('result' => WPVIVID_FAILED,'error' => $e -> getMessage());
|
112 |
+
}catch(Error $e){
|
113 |
+
return array('result' => WPVIVID_FAILED,'error' => $e -> getMessage());
|
114 |
}
|
115 |
return array('result' => WPVIVID_SUCCESS);
|
116 |
}
|
133 |
$file_data['uploaded']=0;
|
134 |
$job_data[basename($file)]=$file_data;
|
135 |
}
|
136 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,WPVIVID_UPLOAD_UNDO,'Start uploading',$job_data);
|
137 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3);
|
138 |
}
|
139 |
|
258 |
|
259 |
public function download($file, $local_path, $callback = '')
|
260 |
{
|
261 |
+
try {
|
262 |
+
global $wpvivid_pulgin;
|
263 |
+
$this->current_file_name = $file['file_name'];
|
264 |
+
$this->current_file_size = $file['size'];
|
265 |
+
$file_path = trailingslashit($local_path) . $this->current_file_name;
|
266 |
+
$file_md5 = $file['md5'];
|
267 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Get s3compat client.','notice');
|
268 |
+
$s3compat = $this->getClient();
|
269 |
+
if (is_array($s3compat) && $s3compat['result'] == WPVIVID_FAILED) {
|
270 |
+
return $s3compat;
|
271 |
+
}
|
272 |
|
273 |
+
$start_offset = file_exists($file_path) ? filesize($file_path) : 0;
|
274 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Create local file.','notice');
|
275 |
+
$fh = fopen($file_path, 'a');
|
276 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Downloading file ' . $file['file_name'] . ', Size: ' . $file['size'] ,'notice');
|
277 |
+
while ($start_offset < $this->current_file_size) {
|
278 |
+
$last_byte = min($start_offset + $this->download_chunk_size - 1, $this->current_file_size - 1);
|
279 |
$range = "bytes=$start_offset-$last_byte";
|
280 |
+
$response = $this->_download_loop($s3compat, $range, $fh);
|
281 |
+
if ($response['result'] === WPVIVID_FAILED) {
|
282 |
return $response;
|
283 |
+
}
|
284 |
|
285 |
clearstatcache();
|
286 |
$state = stat($file_path);
|
287 |
$start_offset = $state['size'];
|
288 |
+
if ((time() - $this->last_time) > 3) {
|
289 |
+
if (is_callable($callback)) {
|
290 |
+
call_user_func_array($callback, array($start_offset, $this->current_file_name,
|
291 |
+
$this->current_file_size, $this->last_time, $this->last_size));
|
|
|
|
|
292 |
}
|
293 |
+
$this->last_size = $start_offset;
|
294 |
+
$this->last_time = time();
|
295 |
}
|
296 |
}
|
297 |
+
@fclose($fh);
|
298 |
+
|
299 |
+
if(filesize($file_path) === $file['size']){
|
300 |
+
if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
|
301 |
+
$res = TRUE;
|
302 |
+
}
|
303 |
+
else{
|
304 |
+
$res = FALSE;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
else{
|
308 |
+
$res = FALSE;
|
309 |
+
}
|
310 |
+
|
311 |
+
if ($res !== TRUE) {
|
312 |
+
@unlink($file_path);
|
313 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Downloading ' . $file['file_name'] . ' failed. ' . $file['file_name'] . ' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.');
|
314 |
+
}
|
315 |
+
|
316 |
+
return array('result' => WPVIVID_SUCCESS);
|
317 |
}
|
318 |
+
catch (S3Exception $e) {
|
319 |
+
return array('result' => WPVIVID_FAILED, 'error' => $e->getAwsErrorCode() . $e->getMessage());
|
320 |
+
}
|
321 |
+
catch (Exception $error){
|
322 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
323 |
+
error_log($message);
|
324 |
+
return array('result'=>WPVIVID_FAILED, 'error'=>$message);
|
325 |
}
|
|
|
326 |
}
|
327 |
+
|
328 |
public function _download_loop($s3compat,$range,$fh){
|
329 |
try{
|
330 |
for($i =0;$i <WPVIVID_REMOTE_CONNECT_RETRY_TIMES;$i ++){
|
includes/customclass/class-wpvivid-send-to-site.php
CHANGED
@@ -108,7 +108,8 @@ class WPvivid_Send_to_site extends WPvivid_Remote
|
|
108 |
$file_data['uploaded']=0;
|
109 |
$job_data[basename($file)]=$file_data;
|
110 |
}
|
111 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,
|
|
|
112 |
}
|
113 |
|
114 |
foreach ($files as $file)
|
@@ -145,7 +146,7 @@ class WPvivid_Send_to_site extends WPvivid_Remote
|
|
145 |
global $wpvivid_pulgin;
|
146 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Start uploading '.basename($file),'notice');
|
147 |
|
148 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,
|
149 |
|
150 |
$file_size=filesize($file);
|
151 |
$md5=md5_file($file);
|
@@ -162,7 +163,7 @@ class WPvivid_Send_to_site extends WPvivid_Remote
|
|
162 |
$wpvivid_pulgin->wpvivid_log->WriteLog('upload finished','notice');
|
163 |
fclose($handle);
|
164 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
165 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,
|
166 |
return array('result' =>WPVIVID_SUCCESS);
|
167 |
}
|
168 |
else if($ret['file_status']['status']=='continue')
|
@@ -245,7 +246,7 @@ class WPvivid_Send_to_site extends WPvivid_Remote
|
|
245 |
$wpvivid_pulgin->wpvivid_log->WriteLog('upload finished','notice');
|
246 |
fclose($handle);
|
247 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
248 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,
|
249 |
return array('result' =>WPVIVID_SUCCESS);
|
250 |
}
|
251 |
|
@@ -668,6 +669,7 @@ class WPvivid_Send_to_site extends WPvivid_Remote
|
|
668 |
|
669 |
if (isset($params['backup']) && isset($params['backup_id'])) {
|
670 |
$params['backup']['type'] = 'Migration';
|
|
|
671 |
$list = WPvivid_Setting::get_option('wpvivid_backup_list');
|
672 |
$list[$params['backup_id']] = $params['backup'];
|
673 |
$list[$params['backup_id']]['log'] = $wpvivid_pulgin->wpvivid_log->log_file;
|
@@ -791,11 +793,17 @@ class WPvivid_Send_to_site extends WPvivid_Remote
|
|
791 |
|
792 |
$rename = true;
|
793 |
|
794 |
-
if (!file_exists($file_path))
|
|
|
795 |
$file_path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $params['name'];
|
796 |
$rename = false;
|
|
|
797 |
}
|
798 |
-
|
|
|
|
|
|
|
|
|
799 |
if (!$offset) {
|
800 |
$ret['result'] = WPVIVID_SUCCESS;
|
801 |
$ret['file_status']['status'] = 'start';
|
108 |
$file_data['uploaded']=0;
|
109 |
$job_data[basename($file)]=$file_data;
|
110 |
}
|
111 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,WPVIVID_UPLOAD_UNDO,'Start uploading',$job_data);
|
112 |
+
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE);
|
113 |
}
|
114 |
|
115 |
foreach ($files as $file)
|
146 |
global $wpvivid_pulgin;
|
147 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Start uploading '.basename($file),'notice');
|
148 |
|
149 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,WPVIVID_UPLOAD_UNDO,'Start uploading '.basename($file).'.',$upload_job['job_data']);
|
150 |
|
151 |
$file_size=filesize($file);
|
152 |
$md5=md5_file($file);
|
163 |
$wpvivid_pulgin->wpvivid_log->WriteLog('upload finished','notice');
|
164 |
fclose($handle);
|
165 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
166 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
167 |
return array('result' =>WPVIVID_SUCCESS);
|
168 |
}
|
169 |
else if($ret['file_status']['status']=='continue')
|
246 |
$wpvivid_pulgin->wpvivid_log->WriteLog('upload finished','notice');
|
247 |
fclose($handle);
|
248 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
249 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SEND_TO_SITE,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
250 |
return array('result' =>WPVIVID_SUCCESS);
|
251 |
}
|
252 |
|
669 |
|
670 |
if (isset($params['backup']) && isset($params['backup_id'])) {
|
671 |
$params['backup']['type'] = 'Migration';
|
672 |
+
$params['backup']['local']['path']=WPvivid_Setting::get_backupdir();
|
673 |
$list = WPvivid_Setting::get_option('wpvivid_backup_list');
|
674 |
$list[$params['backup_id']] = $params['backup'];
|
675 |
$list[$params['backup_id']]['log'] = $wpvivid_pulgin->wpvivid_log->log_file;
|
793 |
|
794 |
$rename = true;
|
795 |
|
796 |
+
if (!file_exists($file_path))
|
797 |
+
{
|
798 |
$file_path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $params['name'];
|
799 |
$rename = false;
|
800 |
+
$offset=false;
|
801 |
}
|
802 |
+
else
|
803 |
+
{
|
804 |
+
$offset = filesize($file_path);
|
805 |
+
}
|
806 |
+
|
807 |
if (!$offset) {
|
808 |
$ret['result'] = WPVIVID_SUCCESS;
|
809 |
$ret['file_status']['status'] = 'start';
|
includes/customclass/class-wpvivid-sftpclass.php
CHANGED
@@ -296,7 +296,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
|
|
296 |
$file_data['uploaded']=0;
|
297 |
$job_data[basename($file)]=$file_data;
|
298 |
}
|
299 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,
|
300 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP);
|
301 |
}
|
302 |
|
@@ -334,7 +334,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
|
|
334 |
$this->current_file_name=basename($file);
|
335 |
$this -> current_file_size = filesize($file);
|
336 |
|
337 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,
|
338 |
|
339 |
$result = $conn->put(trailingslashit($path) . basename($file), $file, NET_SFTP_LOCAL_FILE| NET_SFTP_RESUME_START, -1, -1, array($this , 'upload_callback'));
|
340 |
|
@@ -342,7 +342,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
|
|
342 |
{
|
343 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
344 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
345 |
-
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,
|
346 |
break;
|
347 |
}
|
348 |
|
@@ -360,42 +360,63 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
|
|
360 |
|
361 |
public function download($file,$local_path,$callback = '')
|
362 |
{
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
$path = $this->options['path'];
|
371 |
-
$port = empty($this->options['port'])?22:$this->options['port'];
|
372 |
-
$local_path = trailingslashit($local_path).$file['file_name'];
|
373 |
-
$file_size = $file['size'];
|
374 |
-
$md5 = $file['md5'];
|
375 |
-
$remote_file_name = trailingslashit($path).$file['file_name'];
|
376 |
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
$stat = fstat($local_file);
|
389 |
-
$offset = $stat['size'];
|
390 |
-
$progress= floor(($offset/$file_size)* 100) ;
|
391 |
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
}
|
398 |
-
|
|
|
|
|
|
|
399 |
}
|
400 |
}
|
401 |
|
296 |
$file_data['uploaded']=0;
|
297 |
$job_data[basename($file)]=$file_data;
|
298 |
}
|
299 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,WPVIVID_UPLOAD_UNDO,'Start uploading',$job_data);
|
300 |
$upload_job=WPvivid_taskmanager::get_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP);
|
301 |
}
|
302 |
|
334 |
$this->current_file_name=basename($file);
|
335 |
$this -> current_file_size = filesize($file);
|
336 |
|
337 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,WPVIVID_UPLOAD_UNDO,'Start uploading '.basename($file).'.',$upload_job['job_data']);
|
338 |
|
339 |
$result = $conn->put(trailingslashit($path) . basename($file), $file, NET_SFTP_LOCAL_FILE| NET_SFTP_RESUME_START, -1, -1, array($this , 'upload_callback'));
|
340 |
|
342 |
{
|
343 |
$wpvivid_pulgin->wpvivid_log->WriteLog('Finished uploading '.basename($file),'notice');
|
344 |
$upload_job['job_data'][basename($file)]['uploaded']=1;
|
345 |
+
WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_SFTP,WPVIVID_UPLOAD_SUCCESS,'Uploading '.basename($file).' completed.',$upload_job['job_data']);
|
346 |
break;
|
347 |
}
|
348 |
|
360 |
|
361 |
public function download($file,$local_path,$callback = '')
|
362 |
{
|
363 |
+
try {
|
364 |
+
global $wpvivid_pulgin;
|
365 |
+
$this->callback = $callback;
|
366 |
+
$this->current_file_name = $file['file_name'];
|
367 |
+
$this->current_file_size = $file['size'];
|
368 |
+
|
369 |
+
$host = $this->options['host'];
|
370 |
+
$username = $this->options['username'];
|
371 |
+
$password = $this->options['password'];
|
372 |
+
$path = $this->options['path'];
|
373 |
+
$port = empty($this->options['port']) ? 22 : $this->options['port'];
|
374 |
+
$local_path = trailingslashit($local_path) . $file['file_name'];
|
375 |
+
$file_size = $file['size'];
|
376 |
+
$md5 = $file['md5'];
|
377 |
+
$remote_file_name = trailingslashit($path) . $file['file_name'];
|
378 |
+
|
379 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Connecting SFTP server.','notice');
|
380 |
+
$conn = $this->do_connect($host, $username, $password, $port);
|
381 |
+
$progress = 0;
|
382 |
+
if (!is_subclass_of($conn, 'Net_SSH2')) {
|
383 |
+
return $conn;
|
384 |
+
}
|
385 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Create local file.','notice');
|
386 |
+
$local_file = fopen($local_path, 'ab');
|
387 |
+
if (!$local_file) {
|
388 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Unable to create the local file. Please make sure the folder is writable and try again.');
|
389 |
+
}
|
390 |
+
$stat = fstat($local_file);
|
391 |
+
$offset = $stat['size'];
|
392 |
+
$progress = floor(($offset / $file_size) * 100);
|
393 |
|
394 |
+
$wpvivid_pulgin->wpvivid_download_log->WriteLog('Downloading file ' . $file['file_name'] . ', Size: ' . $file['size'] ,'notice');
|
395 |
+
$result = $conn->get($remote_file_name, $local_file, $offset, -1, array($this, 'download_callback'));
|
396 |
+
@fclose($local_file);
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
|
398 |
+
if(filesize($local_path) === $file['size']){
|
399 |
+
if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
|
400 |
+
$res = TRUE;
|
401 |
+
}
|
402 |
+
else{
|
403 |
+
$res = FALSE;
|
404 |
+
}
|
405 |
+
}
|
406 |
+
else{
|
407 |
+
$res = FALSE;
|
408 |
+
}
|
|
|
|
|
|
|
409 |
|
410 |
+
if ($result && $res) {
|
411 |
+
return array('result' => WPVIVID_SUCCESS);
|
412 |
+
} else {
|
413 |
+
return array('result' => WPVIVID_FAILED, 'error' => 'Downloading ' . $remote_file_name . ' failed. ' . $remote_file_name . ' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.');
|
414 |
+
}
|
415 |
+
}
|
416 |
+
catch (Exception $error){
|
417 |
+
$message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
|
418 |
+
error_log($message);
|
419 |
+
return array('result'=>WPVIVID_FAILED, 'error'=>$message);
|
420 |
}
|
421 |
}
|
422 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
=== Move
|
2 |
Contributors: wpvivid
|
3 |
Tags: move, clone, migrate, copy, backup, restore, auto backup, cloud backup
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.2
|
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 |
|
@@ -15,6 +15,12 @@ WPvivid Backup Plugin is the only free all-in-one backup, restore and migration
|
|
15 |
|
16 |
Clone or copy WordPress sites then move or migrate them to a new host (new domain). Off-site backup schedules, transfer backups to leading remote storage. All in one.
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
== Core Features ==
|
19 |
|
20 |
= 1. Easy Site Move or Migration (New Feature) =
|
@@ -93,7 +99,7 @@ We offer free support in 3 channels:
|
|
93 |
== Privacy Policy and GDPR Compliance ==
|
94 |
WPvivid Backup plugin is created and operated with full respect and protection of users personal information, and is in full compliance with General Data Protection Regulation(GDPR). Check out the following content to know the details:
|
95 |
= What personal data can WPvivid Backup plugin access and how is the data processed? =
|
96 |
-
|
97 |
In addition, the implementations of all migrations, backups and restores of your site happen completely on your website server, there are no data come across any of our servers in the whole process.
|
98 |
The only personal data currently we can access are the contact data when you contact us by email, which may include your name, email address and other contact details. The data will only be used for the purposes of handling and resolving your enquiry.
|
99 |
= How does WPvivid Backup plugin help users create a GDPR compliant backup? =
|
@@ -140,6 +146,11 @@ Yes, we do. Here are the guides for [copying your site to a new host](https://wp
|
|
140 |
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).
|
141 |
|
142 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
143 |
= 0.9.20 =
|
144 |
- Added an advanced section in settings page.
|
145 |
- Optimized the layout of settings page and display of some settings.
|
1 |
+
=== Move & Backup WordPress - WPvivid Backup Plugin ===
|
2 |
Contributors: wpvivid
|
3 |
Tags: move, clone, migrate, copy, backup, restore, auto backup, cloud backup
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.2
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 0.9.21
|
8 |
License: GPLv3 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
|
10 |
|
15 |
|
16 |
Clone or copy WordPress sites then move or migrate them to a new host (new domain). Off-site backup schedules, transfer backups to leading remote storage. All in one.
|
17 |
|
18 |
+
== Supported Page Builders ==
|
19 |
+
WPvivid Backup Plugin has been tested by our users to migrate well on websites built with:
|
20 |
+
1. [Elementor Page Builder](https://wordpress.org/plugins/elementor/)
|
21 |
+
2. [Page Builder by SiteOrigin](https://wordpress.org/plugins/siteorigin-panels/)
|
22 |
+
3. [WordPress Page Builder – Beaver Builder](https://wordpress.org/plugins/beaver-builder-lite-version/)
|
23 |
+
|
24 |
== Core Features ==
|
25 |
|
26 |
= 1. Easy Site Move or Migration (New Feature) =
|
99 |
== Privacy Policy and GDPR Compliance ==
|
100 |
WPvivid Backup plugin is created and operated with full respect and protection of users personal information, and is in full compliance with General Data Protection Regulation(GDPR). Check out the following content to know the details:
|
101 |
= What personal data can WPvivid Backup plugin access and how is the data processed? =
|
102 |
+
WPvivid Backup plugin currently only has a free version and is available to download from WordPress plugin repository. Thus, all the data related to the updates of the versions as well as the support forum for the plugin on WordPress.org is held by WordPress.org.
|
103 |
In addition, the implementations of all migrations, backups and restores of your site happen completely on your website server, there are no data come across any of our servers in the whole process.
|
104 |
The only personal data currently we can access are the contact data when you contact us by email, which may include your name, email address and other contact details. The data will only be used for the purposes of handling and resolving your enquiry.
|
105 |
= How does WPvivid Backup plugin help users create a GDPR compliant backup? =
|
146 |
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).
|
147 |
|
148 |
== Changelog ==
|
149 |
+
= 0.9.21 =
|
150 |
+
- Fixed: Special data in some database tables could not be replaced during a restore, which would cause failure of the restore.
|
151 |
+
- Fixed: Migration between sites that have different backup storage directories would fail.
|
152 |
+
- Fixed: The error establishing database connection occurred in some cases while loading the plugin page.
|
153 |
+
- Optimized the plugin code.
|
154 |
= 0.9.20 =
|
155 |
- Added an advanced section in settings page.
|
156 |
- Optimized the layout of settings page and display of some settings.
|
wpvivid-backuprestore.php
CHANGED
@@ -6,8 +6,8 @@
|
|
6 |
*
|
7 |
* @wordpress-plugin
|
8 |
* Plugin Name: WPvivid Backup Plugin
|
9 |
-
* Description:
|
10 |
-
* Version: 0.9.
|
11 |
* Author: WPvivid Team
|
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');
|
@@ -36,6 +36,7 @@ define('WPVIVID_PLUGIN_SLUG','WPvivid');
|
|
36 |
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',900);
|
41 |
define('WPVIVID_MEMORY_LIMIT','256M');
|
@@ -70,7 +71,6 @@ define('WPVIVID_DEFAULT_DOMAIN_INCLUDE', true);
|
|
70 |
//
|
71 |
define('WPVIVID_DEFAULT_ESTIMATE_BACKUP', true);
|
72 |
//Specify the folder and database to be backed up
|
73 |
-
|
74 |
define('WPVIVID_DEFAULT_SUBPACKAGE_PLUGIN_UPLOAD', false);
|
75 |
|
76 |
//define schedule hooks
|
6 |
*
|
7 |
* @wordpress-plugin
|
8 |
* Plugin Name: WPvivid Backup Plugin
|
9 |
+
* Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
|
10 |
+
* Version: 0.9.21
|
11 |
* Author: WPvivid Team
|
12 |
* Author URI: https://wpvivid.com
|
13 |
* License: GPL-3.0+
|
21 |
die;
|
22 |
}
|
23 |
|
24 |
+
define( 'WPVIVID_PLUGIN_VERSION', '0.9.21' );
|
25 |
//
|
26 |
define('WPVIVID_RESTORE_INIT','init');
|
27 |
define('WPVIVID_RESTORE_READY','ready');
|
36 |
define('WPVIVID_PLUGIN_NAME',plugin_basename(__FILE__));
|
37 |
define('WPVIVID_PLUGIN_URL',plugins_url('',__FILE__));
|
38 |
define('WPVIVID_PLUGIN_DIR',dirname(__FILE__));
|
39 |
+
define('WPVIVID_PLUGIN_IMAGES_URL',WPVIVID_PLUGIN_URL.'/admin/partials/images/');
|
40 |
//We set a long enough default execution time (10 min) to ensure that the backup process can be completed.
|
41 |
define('WPVIVID_MAX_EXECUTION_TIME',900);
|
42 |
define('WPVIVID_MEMORY_LIMIT','256M');
|
71 |
//
|
72 |
define('WPVIVID_DEFAULT_ESTIMATE_BACKUP', true);
|
73 |
//Specify the folder and database to be backed up
|
|
|
74 |
define('WPVIVID_DEFAULT_SUBPACKAGE_PLUGIN_UPLOAD', false);
|
75 |
|
76 |
//define schedule hooks
|