Migration, Backup, Staging – WPvivid - Version 0.9.48

Version Description

  • Redesigned the Download section for better UX.
  • Fixed the insufficient permission error that occurred when authenticating FTP in some cases.
  • Fixed the incorrect credential error that occurred when authenticating SFTP in some cases.
  • Successfully tested with WordPress 5.6.
Download this release

Release Info

Developer wpvivid
Plugin Icon 128x128 Migration, Backup, Staging – WPvivid
Version 0.9.48
Comparing to
See all releases

Code changes from version 0.9.47 to 0.9.48

admin/class-wpvivid-admin.php CHANGED
@@ -316,7 +316,7 @@ class WPvivid_Admin {
316
  public function add_action_links( $links )
317
  {
318
  $settings_link = array(
319
- '<a href="' . admin_url( 'admin.php?page=' . $this->plugin_name ) . '">' . __('Settings', $this->plugin_name) . '</a>',
320
  );
321
  return array_merge( $settings_link, $links );
322
  }
@@ -996,7 +996,7 @@ class WPvivid_Admin {
996
  var comment = jQuery('#wpvivid_debug_comment').val();
997
 
998
  var ajax_data = {
999
- 'action': 'Awpvivid_send_debug_info',
1000
  'user_mail': wpvivid_user_mail,
1001
  'server_type':server_type,
1002
  'host_provider':host_provider,
316
  public function add_action_links( $links )
317
  {
318
  $settings_link = array(
319
+ '<a href="' . admin_url( 'admin.php?page=' . apply_filters('wpvivid_white_label_slug', $this->plugin_name) ) . '">' . __('Settings', $this->plugin_name) . '</a>',
320
  );
321
  return array_merge( $settings_link, $links );
322
  }
996
  var comment = jQuery('#wpvivid_debug_comment').val();
997
 
998
  var ajax_data = {
999
+ 'action': 'wpvivid_send_debug_info',
1000
  'user_mail': wpvivid_user_mail,
1001
  'server_type':server_type,
1002
  'host_provider':host_provider,
admin/js/wpvivid-admin.js CHANGED
@@ -238,7 +238,7 @@ function wpvivid_check_runningtask(){
238
  running_backup_taskid='';
239
  }
240
  }
241
- if (jsonarray.download.length !== 0) {
242
  if(jsonarray.download.result === 'success') {
243
  b_has_data = true;
244
  task_retry_times = 0;
@@ -304,7 +304,7 @@ function wpvivid_check_runningtask(){
304
  b_has_data = true;
305
  alert(jsonarray.download.error);
306
  }
307
- }
308
  if (!b_has_data) {
309
  task_retry_times++;
310
  if (task_retry_times < 5) {
238
  running_backup_taskid='';
239
  }
240
  }
241
+ /*if (jsonarray.download.length !== 0) {
242
  if(jsonarray.download.result === 'success') {
243
  b_has_data = true;
244
  task_retry_times = 0;
304
  b_has_data = true;
305
  alert(jsonarray.download.error);
306
  }
307
+ }*/
308
  if (!b_has_data) {
309
  task_retry_times++;
310
  if (task_retry_times < 5) {
admin/partials/wpvivid-backup-restore-page-display.php CHANGED
@@ -1,5 +1,390 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function wpvivid_add_backup_type($html, $type_name)
4
  {
5
  $html .= '<label>
@@ -115,6 +500,7 @@ function wpvivid_backuppage_load_backuplist($backuplist_array){
115
  $backuplist_array['list_backup'] = array('index' => '1', 'tab_func' => 'wpvivid_backuppage_add_tab_backup', 'page_func' => 'wpvivid_backuppage_add_page_backup');
116
  $backuplist_array['list_log'] = array('index' => '3', 'tab_func' => 'wpvivid_backuppage_add_tab_log', 'page_func' => 'wpvivid_backuppage_add_page_log');
117
  $backuplist_array['list_restore'] = array('index' => '4', 'tab_func' => 'wpvivid_backuppage_add_tab_restore', 'page_func' => 'wpvivid_backuppage_add_page_restore');
 
118
  return $backuplist_array;
119
  }
120
 
@@ -146,6 +532,17 @@ function wpvivid_backuppage_add_tab_restore(){
146
  <?php
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
 
149
  function wpvivid_backuppage_add_page_backup(){
150
  $backuplist=WPvivid_Backuplist::get_backuplist();
151
  $display_backup_count = WPvivid_Setting::get_max_backup_count();
@@ -383,7 +780,7 @@ function wpvivid_backuppage_add_page_backup(){
383
  });
384
  }
385
 
386
- function wpvivid_initialize_download(backup_id, list_name){
387
  wpvivid_reset_backup_list(list_name);
388
  jQuery('#wpvivid_download_loading_'+backup_id).addClass('is-active');
389
  tmp_current_click_backupid = backup_id;
@@ -454,7 +851,7 @@ function wpvivid_backuppage_add_page_backup(){
454
  var error_message = wpvivid_output_ajaxerror('initializing download information', textStatus, errorThrown);
455
  alert(error_message);
456
  });
457
- }
458
 
459
  function wpvivid_reset_backup_list(list_name){
460
  jQuery('#'+list_name+' tr').each(function(i){
@@ -1479,6 +1876,323 @@ function wpvivid_backuppage_add_page_restore(){
1479
  <?php
1480
  }
1481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1482
  function wpvivid_backuppage_add_progress_module(){
1483
  ?>
1484
  <div class="postbox" id="wpvivid_postbox_backup_percent" style="display: none;">
1
  <?php
2
 
3
+ if ( ! class_exists( 'WP_List_Table' ) )
4
+ {
5
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
6
+ }
7
+
8
+ class WPvivid_Files_List extends WP_List_Table
9
+ {
10
+ public $page_num;
11
+ public $file_list;
12
+ public $backup_id;
13
+
14
+ public function __construct( $args = array() )
15
+ {
16
+ parent::__construct(
17
+ array(
18
+ 'plural' => 'files',
19
+ 'screen' => 'files'
20
+ )
21
+ );
22
+ }
23
+
24
+ protected function get_table_classes()
25
+ {
26
+ return array( 'widefat striped' );
27
+ }
28
+
29
+ public function print_column_headers( $with_id = true )
30
+ {
31
+ list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
32
+
33
+ if (!empty($columns['cb'])) {
34
+ static $cb_counter = 1;
35
+ $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>'
36
+ . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox"/>';
37
+ $cb_counter++;
38
+ }
39
+
40
+ foreach ( $columns as $column_key => $column_display_name )
41
+ {
42
+ $class = array( 'manage-column', "column-$column_key" );
43
+
44
+ if ( in_array( $column_key, $hidden ) )
45
+ {
46
+ $class[] = 'hidden';
47
+ }
48
+
49
+ if ( $column_key === $primary )
50
+ {
51
+ $class[] = 'column-primary';
52
+ }
53
+
54
+ if ( $column_key === 'cb' )
55
+ {
56
+ $class[] = 'check-column';
57
+ }
58
+
59
+ $tag = ( 'cb' === $column_key ) ? 'td' : 'th';
60
+ $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
61
+ $id = $with_id ? "id='$column_key'" : '';
62
+
63
+ if ( ! empty( $class ) )
64
+ {
65
+ $class = "class='" . join( ' ', $class ) . "'";
66
+ }
67
+
68
+ echo "<$tag $scope $id $class>$column_display_name</$tag>";
69
+ }
70
+ }
71
+
72
+ public function get_columns()
73
+ {
74
+ $columns = array();
75
+ $columns['wpvivid_file'] = __( 'File', 'wpvivid' );
76
+ return $columns;
77
+ }
78
+
79
+ public function _column_wpvivid_file( $file )
80
+ {
81
+ $html='<td class="tablelistcolumn">
82
+ <div style="padding:0 0 10px 0;">
83
+ <span>'. $file['key'].'</span>
84
+ </div>
85
+ <div class="wpvivid-download-status" style="padding:0;">';
86
+ if($file['status']=='completed')
87
+ {
88
+ $html.='<span>'.__('File Size: ', 'wpvivid').'</span><span class="wpvivid-element-space-right wpvivid-download-file-size">'.$file['size'].'</span><span class="wpvivid-element-space-right">|</span><span class=" wpvivid-element-space-right wpvivid-ready-download"><a style="cursor: pointer;">Download</a></span>';
89
+ }
90
+ else if($file['status']=='file_not_found')
91
+ {
92
+ $html.='<span>' . __('File not found', 'wpvivid') . '</span>';
93
+ }
94
+ else if($file['status']=='need_download')
95
+ {
96
+ $html.='<span>'.__('File Size: ', 'wpvivid').'</span><span class="wpvivid-element-space-right wpvivid-download-file-size">'.$file['size'].'</span><span class="wpvivid-element-space-right">|</span><span class="wpvivid-element-space-right"><a class="wpvivid-download" style="cursor: pointer;">Prepare to Download</a></span>';
97
+ }
98
+ else if($file['status']=='running')
99
+ {
100
+ $html.='<div class="wpvivid-element-space-bottom">
101
+ <span class="wpvivid-element-space-right">Retriving (remote storage to web server)</span><span class="wpvivid-element-space-right">|</span><span>File Size: </span><span class="wpvivid-element-space-right wpvivid-download-file-size">'.$file['size'].'</span><span class="wpvivid-element-space-right">|</span><span>Downloaded Size: </span><span>'.$file['downloaded_size'].'</span>
102
+ </div>
103
+ <div style="width:100%;height:10px; background-color:#dcdcdc;">
104
+ <div style="background-color:#0085ba; float:left;width:'.$file['progress_text'].'%;height:10px;"></div>
105
+ </div>';
106
+ }
107
+ else if($file['status']=='timeout')
108
+ {
109
+ $html.='<div class="wpvivid-element-space-bottom">
110
+ <span>Download timeout, please retry.</span>
111
+ </div>
112
+ <div>
113
+ <span>'.__('File Size: ', 'wpvivid').'</span><span class="wpvivid-element-space-right wpvivid-download-file-size">'.$file['size'].'</span><span class="wpvivid-element-space-right">|</span><span class="wpvivid-element-space-right"><a class="wpvivid-download" style="cursor: pointer;">Prepare to Download</a></span>
114
+ </div>';
115
+ }
116
+ else if($file['status']=='error')
117
+ {
118
+ $html.='<div class="wpvivid-element-space-bottom">
119
+ <span>'.$file['error'].'</span>
120
+ </div>
121
+ <div>
122
+ <span>'.__('File Size: ', 'wpvivid').'</span><span class="wpvivid-element-space-right wpvivid-download-file-size">'.$file['size'].'</span><span class="wpvivid-element-space-right">|</span><span class="wpvivid-element-space-right"><a class="wpvivid-download" style="cursor: pointer;">Prepare to Download</a></span>
123
+ </div>';
124
+ }
125
+
126
+ $html.='</div></td>';
127
+ echo $html;
128
+ //size
129
+ }
130
+
131
+ public function set_files_list($file_list,$backup_id,$page_num=1)
132
+ {
133
+ $this->file_list=$file_list;
134
+ $this->backup_id=$backup_id;
135
+ $this->page_num=$page_num;
136
+ }
137
+
138
+ public function get_pagenum()
139
+ {
140
+ if($this->page_num=='first')
141
+ {
142
+ $this->page_num=1;
143
+ }
144
+ else if($this->page_num=='last')
145
+ {
146
+ $this->page_num=$this->_pagination_args['total_pages'];
147
+ }
148
+ $pagenum = $this->page_num ? $this->page_num : 0;
149
+
150
+ if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
151
+ {
152
+ $pagenum = $this->_pagination_args['total_pages'];
153
+ }
154
+
155
+ return max( 1, $pagenum );
156
+ }
157
+
158
+ public function prepare_items()
159
+ {
160
+ $columns = $this->get_columns();
161
+ $hidden = array();
162
+ $sortable = array();
163
+ $this->_column_headers = array($columns, $hidden, $sortable);
164
+
165
+ $total_items =sizeof($this->file_list);
166
+
167
+ $this->set_pagination_args(
168
+ array(
169
+ 'total_items' => $total_items,
170
+ 'per_page' => 10,
171
+ )
172
+ );
173
+ }
174
+
175
+ public function has_items()
176
+ {
177
+ return !empty($this->file_list);
178
+ }
179
+
180
+ public function display_rows()
181
+ {
182
+ $this->_display_rows($this->file_list);
183
+ }
184
+
185
+ private function _display_rows($file_list)
186
+ {
187
+ $page=$this->get_pagenum();
188
+
189
+ $page_file_list=array();
190
+ $count=0;
191
+ while ( $count<$page )
192
+ {
193
+ $page_file_list = array_splice( $file_list, 0, 10);
194
+ $count++;
195
+ }
196
+ foreach ( $page_file_list as $key=>$file)
197
+ {
198
+ $file['key']=$key;
199
+ $this->single_row($file);
200
+ }
201
+ }
202
+
203
+ public function single_row($file)
204
+ {
205
+ ?>
206
+ <tr slug="<?php echo $file['key']?>">
207
+ <?php $this->single_row_columns( $file ); ?>
208
+ </tr>
209
+ <?php
210
+ }
211
+
212
+ protected function pagination( $which )
213
+ {
214
+ if ( empty( $this->_pagination_args ) )
215
+ {
216
+ return;
217
+ }
218
+
219
+ $total_items = $this->_pagination_args['total_items'];
220
+ $total_pages = $this->_pagination_args['total_pages'];
221
+ $infinite_scroll = false;
222
+ if ( isset( $this->_pagination_args['infinite_scroll'] ) )
223
+ {
224
+ $infinite_scroll = $this->_pagination_args['infinite_scroll'];
225
+ }
226
+
227
+ if ( 'top' === $which && $total_pages > 1 )
228
+ {
229
+ $this->screen->render_screen_reader_content( 'heading_pagination' );
230
+ }
231
+
232
+ $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
233
+
234
+ $current = $this->get_pagenum();
235
+
236
+ $page_links = array();
237
+
238
+ $total_pages_before = '<span class="paging-input">';
239
+ $total_pages_after = '</span></span>';
240
+
241
+ $disable_first = $disable_last = $disable_prev = $disable_next = false;
242
+
243
+ if ( $current == 1 ) {
244
+ $disable_first = true;
245
+ $disable_prev = true;
246
+ }
247
+ if ( $current == 2 ) {
248
+ $disable_first = true;
249
+ }
250
+ if ( $current == $total_pages ) {
251
+ $disable_last = true;
252
+ $disable_next = true;
253
+ }
254
+ if ( $current == $total_pages - 1 ) {
255
+ $disable_last = true;
256
+ }
257
+
258
+ if ( $disable_first ) {
259
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&laquo;</span>';
260
+ } else {
261
+ $page_links[] = sprintf(
262
+ "<div class='first-page button'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
263
+ __( 'First page' ),
264
+ '&laquo;'
265
+ );
266
+ }
267
+
268
+ if ( $disable_prev ) {
269
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&lsaquo;</span>';
270
+ } else {
271
+ $page_links[] = sprintf(
272
+ "<div class='prev-page button' value='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
273
+ $current,
274
+ __( 'Previous page' ),
275
+ '&lsaquo;'
276
+ );
277
+ }
278
+
279
+ if ( 'bottom' === $which ) {
280
+ $html_current_page = $current;
281
+ $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
282
+ } else {
283
+ $html_current_page = sprintf(
284
+ "%s<input class='current-page' id='current-page-selector-filelist' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
285
+ '<label for="current-page-selector-filelist" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
286
+ $current,
287
+ strlen( $total_pages )
288
+ );
289
+ }
290
+ $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
291
+ $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
292
+
293
+ if ( $disable_next ) {
294
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&rsaquo;</span>';
295
+ } else {
296
+ $page_links[] = sprintf(
297
+ "<div class='next-page button' value='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
298
+ $current,
299
+ __( 'Next page' ),
300
+ '&rsaquo;'
301
+ );
302
+ }
303
+
304
+ if ( $disable_last ) {
305
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&raquo;</span>';
306
+ } else {
307
+ $page_links[] = sprintf(
308
+ "<div class='last-page button'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
309
+ __( 'Last page' ),
310
+ '&raquo;'
311
+ );
312
+ }
313
+
314
+ $pagination_links_class = 'pagination-links';
315
+ if ( ! empty( $infinite_scroll ) ) {
316
+ $pagination_links_class .= ' hide-if-js';
317
+ }
318
+ $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
319
+
320
+ if ( $total_pages ) {
321
+ $page_class = $total_pages < 2 ? ' one-page' : '';
322
+ } else {
323
+ $page_class = ' no-pages';
324
+ }
325
+ $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
326
+
327
+ echo $this->_pagination;
328
+ }
329
+
330
+ protected function display_tablenav( $which ) {
331
+ $css_type = '';
332
+ if ( 'top' === $which ) {
333
+ wp_nonce_field( 'bulk-' . $this->_args['plural'] );
334
+ $css_type = 'margin: 0 0 10px 0';
335
+ }
336
+ else if( 'bottom' === $which ) {
337
+ $css_type = 'margin: 10px 0 0 0';
338
+ }
339
+
340
+ $total_pages = $this->_pagination_args['total_pages'];
341
+ if ( $total_pages >1)
342
+ {
343
+ ?>
344
+ <div class="tablenav <?php echo esc_attr( $which ); ?>" style="<?php esc_attr_e($css_type); ?>">
345
+ <?php
346
+ $this->extra_tablenav( $which );
347
+ $this->pagination( $which );
348
+ ?>
349
+
350
+ <br class="clear" />
351
+ </div>
352
+ <?php
353
+ }
354
+ }
355
+
356
+ public function display()
357
+ {
358
+ $singular = $this->_args['singular'];
359
+
360
+ $this->display_tablenav( 'top' );
361
+
362
+ $this->screen->render_screen_reader_content( 'heading_list' );
363
+ ?>
364
+ <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
365
+ <thead>
366
+ <tr>
367
+ <?php $this->print_column_headers(); ?>
368
+ </tr>
369
+ </thead>
370
+
371
+ <tbody id="the-list"
372
+ <?php
373
+ if ( $singular ) {
374
+ echo " data-wp-lists='list:$singular'";
375
+ }
376
+ ?>
377
+ >
378
+ <?php $this->display_rows_or_placeholder(); ?>
379
+ </tbody>
380
+
381
+ </table>
382
+ <?php
383
+ $this->display_tablenav( 'bottom' );
384
+ }
385
+ }
386
+
387
+
388
  function wpvivid_add_backup_type($html, $type_name)
389
  {
390
  $html .= '<label>
500
  $backuplist_array['list_backup'] = array('index' => '1', 'tab_func' => 'wpvivid_backuppage_add_tab_backup', 'page_func' => 'wpvivid_backuppage_add_page_backup');
501
  $backuplist_array['list_log'] = array('index' => '3', 'tab_func' => 'wpvivid_backuppage_add_tab_log', 'page_func' => 'wpvivid_backuppage_add_page_log');
502
  $backuplist_array['list_restore'] = array('index' => '4', 'tab_func' => 'wpvivid_backuppage_add_tab_restore', 'page_func' => 'wpvivid_backuppage_add_page_restore');
503
+ $backuplist_array['list_download'] = array('index' => '5', 'tab_func' => 'wpvivid_backuppage_add_tab_downlaod', 'page_func' => 'wpvivid_backuppage_add_page_downlaod');
504
  return $backuplist_array;
505
  }
506
 
532
  <?php
533
  }
534
 
535
+ function wpvivid_backuppage_add_tab_downlaod(){
536
+ ?>
537
+ <a href="#" id="wpvivid_tab_download" class="nav-tab backup-nav-tab delete" onclick="switchrestoreTabs(event,'page-download')" style="display: none;">
538
+ <div style="margin-right: 15px;"><?php _e('Download', 'wpvivid-backuprestore'); ?></div>
539
+ <div class="nav-tab-delete-img">
540
+ <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_download', 'backup', 'wpvivid_tab_backup');" />
541
+ </div>
542
+ </a>
543
+ <?php
544
+ }
545
+
546
  function wpvivid_backuppage_add_page_backup(){
547
  $backuplist=WPvivid_Backuplist::get_backuplist();
548
  $display_backup_count = WPvivid_Setting::get_max_backup_count();
780
  });
781
  }
782
 
783
+ /*function wpvivid_initialize_download(backup_id, list_name){
784
  wpvivid_reset_backup_list(list_name);
785
  jQuery('#wpvivid_download_loading_'+backup_id).addClass('is-active');
786
  tmp_current_click_backupid = backup_id;
851
  var error_message = wpvivid_output_ajaxerror('initializing download information', textStatus, errorThrown);
852
  alert(error_message);
853
  });
854
+ }*/
855
 
856
  function wpvivid_reset_backup_list(list_name){
857
  jQuery('#'+list_name+' tr').each(function(i){
1876
  <?php
1877
  }
1878
 
1879
+ function wpvivid_backuppage_add_page_downlaod(){
1880
+ ?>
1881
+ <div class="backup-tab-content wpvivid_tab_download" id="page-download" style="padding-top: 1em; display:none;">
1882
+ <div id="wpvivid_init_download_info">
1883
+ <div style="float: left; height: 20px; line-height: 20px; margin-top: 4px;">Initializing the download info</div>
1884
+ <div class="spinner" style="float: left;"></div>
1885
+ <div style="clear: both;"></div>
1886
+ </div>
1887
+ <div class="wpvivid-element-space-bottom" id="wpvivid_files_list">
1888
+ </div>
1889
+ </div>
1890
+
1891
+ <script>
1892
+ var wpvivid_download_files_list = wpvivid_download_files_list || {};
1893
+ wpvivid_download_files_list.backup_id='';
1894
+ wpvivid_download_files_list.wpvivid_download_file_array = Array();
1895
+ wpvivid_download_files_list.wpvivid_download_lock_array = Array();
1896
+ wpvivid_download_files_list.init=function(backup_id) {
1897
+ wpvivid_download_files_list.backup_id=backup_id;
1898
+ wpvivid_download_files_list.wpvivid_download_file_array.splice(0, wpvivid_download_files_list.wpvivid_download_file_array.length);
1899
+ };
1900
+
1901
+ wpvivid_download_files_list.add_download_queue=function(filename) {
1902
+ var download_file_size = jQuery("[slug='"+filename+"']").find('.wpvivid-download-status').find('.wpvivid-download-file-size').html();
1903
+ var tmp_html = '<div class="wpvivid-element-space-bottom">' +
1904
+ '<span class="wpvivid-element-space-right">Retriving (remote storage to web server)</span><span class="wpvivid-element-space-right">|</span><span>File Size: </span><span class="wpvivid-element-space-right">'+download_file_size+'</span><span class="wpvivid-element-space-right">|</span><span>Downloaded Size: </span><span>0</span>' +
1905
+ '</div>' +
1906
+ '<div style="width:100%;height:10px; background-color:#dcdcdc;">' +
1907
+ '<div style="background-color:#0085ba; float:left;width:0%;height:10px;"></div>' +
1908
+ '</div>';
1909
+ jQuery("[slug='"+filename+"']").find('.wpvivid-download-status').html(tmp_html);
1910
+ if(jQuery.inArray(filename, wpvivid_download_files_list.wpvivid_download_file_array) === -1) {
1911
+ wpvivid_download_files_list.wpvivid_download_file_array.push(filename);
1912
+ }
1913
+ var ajax_data = {
1914
+ 'action': 'wpvivid_prepare_download_backup',
1915
+ 'backup_id':wpvivid_download_files_list.backup_id,
1916
+ 'file_name':filename
1917
+ };
1918
+ wpvivid_post_request(ajax_data, function(data)
1919
+ {
1920
+ }, function(XMLHttpRequest, textStatus, errorThrown)
1921
+ {
1922
+ }, 0);
1923
+
1924
+ wpvivid_download_files_list.check_queue();
1925
+ };
1926
+
1927
+ wpvivid_download_files_list.check_queue=function() {
1928
+ if(jQuery.inArray(wpvivid_download_files_list.backup_id, wpvivid_download_files_list.wpvivid_download_lock_array) !== -1){
1929
+ return;
1930
+ }
1931
+ var ajax_data = {
1932
+ 'action': 'wpvivid_get_download_progress',
1933
+ 'backup_id':wpvivid_download_files_list.backup_id,
1934
+ };
1935
+ wpvivid_download_files_list.wpvivid_download_lock_array.push(wpvivid_download_files_list.backup_id);
1936
+ wpvivid_post_request(ajax_data, function(data)
1937
+ {
1938
+ wpvivid_download_files_list.wpvivid_download_lock_array.splice(jQuery.inArray(wpvivid_download_files_list.backup_id, wpvivid_download_files_list.wpvivid_download_file_array),1);
1939
+ var jsonarray = jQuery.parseJSON(data);
1940
+ if (jsonarray.result === 'success')
1941
+ {
1942
+ jQuery.each(jsonarray.files,function (index, value)
1943
+ {
1944
+ if(jQuery.inArray(index, wpvivid_download_files_list.wpvivid_download_file_array) !== -1) {
1945
+ if(value.status === 'timeout' || value.status === 'completed' || value.status === 'error'){
1946
+ wpvivid_download_files_list.wpvivid_download_file_array.splice(jQuery.inArray(index, wpvivid_download_files_list.wpvivid_download_file_array),1);
1947
+ }
1948
+ wpvivid_download_files_list.update_item(index, value);
1949
+ }
1950
+ });
1951
+
1952
+ //if(jsonarray.need_update)
1953
+ if(wpvivid_download_files_list.wpvivid_download_file_array.length > 0)
1954
+ {
1955
+ setTimeout(function()
1956
+ {
1957
+ wpvivid_download_files_list.check_queue();
1958
+ }, 3000);
1959
+ }
1960
+ }
1961
+ }, function(XMLHttpRequest, textStatus, errorThrown)
1962
+ {
1963
+ wpvivid_download_files_list.wpvivid_download_lock_array.splice(jQuery.inArray(wpvivid_download_files_list.backup_id, wpvivid_download_files_list.wpvivid_download_file_array),1);
1964
+ setTimeout(function()
1965
+ {
1966
+ wpvivid_download_files_list.check_queue();
1967
+ }, 3000);
1968
+ }, 0);
1969
+ };
1970
+
1971
+ wpvivid_download_files_list.update_item=function(index,file) {
1972
+ jQuery("[slug='"+index+"']").find('.wpvivid-download-status').html(file.html);
1973
+ };
1974
+
1975
+ wpvivid_download_files_list.download_now=function(filename) {
1976
+ wpvivid_location_href=true;
1977
+ location.href =ajaxurl+'?_wpnonce='+wpvivid_ajax_object.ajax_nonce+'&action=wpvivid_download_backup&backup_id='+wpvivid_download_files_list.backup_id+'&file_name='+filename;
1978
+ };
1979
+
1980
+ function wpvivid_initialize_download(backup_id, list_name){
1981
+ jQuery('#wpvivid_tab_download').show();
1982
+ wpvivid_click_switch_page('backup', 'wpvivid_tab_download', true);
1983
+ wpvivid_init_download_page(backup_id);
1984
+
1985
+
1986
+ /*wpvivid_reset_backup_list(list_name);
1987
+ jQuery('#wpvivid_download_loading_'+backup_id).addClass('is-active');
1988
+ tmp_current_click_backupid = backup_id;
1989
+ var ajax_data = {
1990
+ 'action':'wpvivid_init_download_page',
1991
+ 'backup_id':backup_id
1992
+ };
1993
+ wpvivid_post_request(ajax_data, function(data){
1994
+ try {
1995
+ var jsonarray = jQuery.parseJSON(data);
1996
+ jQuery('#wpvivid_download_loading_'+backup_id).removeClass('is-active');
1997
+ if (jsonarray.result === 'success') {
1998
+ jQuery('#wpvivid_file_part_' + backup_id).html("");
1999
+ var i = 0;
2000
+ var file_not_found = false;
2001
+ var file_name = '';
2002
+ jQuery.each(jsonarray.files, function (index, value) {
2003
+ i++;
2004
+ file_name = index;
2005
+ if (value.status === 'need_download') {
2006
+ jQuery('#wpvivid_file_part_' + backup_id).append(value.html);
2007
+ //tmp_current_click_backupid = '';
2008
+ }
2009
+ else if (value.status === 'running') {
2010
+ if (m_downloading_file_name === file_name) {
2011
+ wpvivid_lock_download(tmp_current_click_backupid);
2012
+ }
2013
+ jQuery('#wpvivid_file_part_' + backup_id).append(value.html);
2014
+ }
2015
+ else if (value.status === 'completed') {
2016
+ if (m_downloading_file_name === file_name) {
2017
+ wpvivid_unlock_download(tmp_current_click_backupid);
2018
+ m_downloading_id = '';
2019
+ m_downloading_file_name = '';
2020
+ }
2021
+ jQuery('#wpvivid_file_part_' + backup_id).append(value.html);
2022
+ //tmp_current_click_backupid = '';
2023
+ }
2024
+ else if (value.status === 'timeout') {
2025
+ if (m_downloading_file_name === file_name) {
2026
+ wpvivid_unlock_download(tmp_current_click_backupid);
2027
+ m_downloading_id = '';
2028
+ m_downloading_file_name = '';
2029
+ }
2030
+ jQuery('#wpvivid_file_part_' + backup_id).append(value.html);
2031
+ //tmp_current_click_backupid = '';
2032
+ }
2033
+ else if (value.status === 'file_not_found') {
2034
+ wpvivid_unlock_download(tmp_current_click_backupid);
2035
+ wpvivid_reset_backup_list(list_name);
2036
+ file_not_found = true;
2037
+ alert("Download failed, file not found. The file might has been moved, renamed or deleted. Please verify the file exists and try again.");
2038
+ //tmp_current_click_backupid = '';
2039
+ return false;
2040
+ }
2041
+ });
2042
+ if (file_not_found === false) {
2043
+ jQuery('#wpvivid_file_part_' + backup_id).append(jsonarray.place_html);
2044
+ }
2045
+ }
2046
+ }
2047
+ catch(err){
2048
+ alert(err);
2049
+ jQuery('#wpvivid_download_loading_'+backup_id).removeClass('is-active');
2050
+ }
2051
+ },function(XMLHttpRequest, textStatus, errorThrown){
2052
+ jQuery('#wpvivid_download_loading_'+backup_id).removeClass('is-active');
2053
+ var error_message = wpvivid_output_ajaxerror('initializing download information', textStatus, errorThrown);
2054
+ alert(error_message);
2055
+ });*/
2056
+ }
2057
+
2058
+ function wpvivid_init_download_page(backup_id){
2059
+ jQuery('#wpvivid_files_list').html('');
2060
+ jQuery('#wpvivid_init_download_info').show();
2061
+ jQuery('#wpvivid_init_download_info').find('.spinner').addClass('is-active');
2062
+ var ajax_data = {
2063
+ 'action':'wpvivid_init_download_page',
2064
+ 'backup_id':backup_id
2065
+ };
2066
+ var retry = '<input type="button" class="button button-primary" value="Retry the initialization" onclick="wpvivid_init_download_page(\''+backup_id+'\');" />';
2067
+
2068
+ wpvivid_post_request(ajax_data, function(data)
2069
+ {
2070
+ jQuery('#wpvivid_init_download_info').hide();
2071
+ jQuery('#wpvivid_init_download_info').find('.spinner').removeClass('is-active');
2072
+ try
2073
+ {
2074
+ var jsonarray = jQuery.parseJSON(data);
2075
+ if (jsonarray.result === 'success')
2076
+ {
2077
+ wpvivid_download_files_list.init(backup_id);
2078
+ var need_check_queue = false;
2079
+ jQuery.each(jsonarray.files,function (index, value)
2080
+ {
2081
+ if(value.status === 'running'){
2082
+ if(jQuery.inArray(index, wpvivid_download_files_list.wpvivid_download_file_array) === -1) {
2083
+ wpvivid_download_files_list.wpvivid_download_file_array.push(index);
2084
+ need_check_queue = true;
2085
+ }
2086
+ }
2087
+ });
2088
+ if(need_check_queue) {
2089
+ wpvivid_download_files_list.check_queue();
2090
+ }
2091
+ jQuery('#wpvivid_files_list').html(jsonarray.html);
2092
+ }
2093
+ else{
2094
+ alert(jsonarray.error);
2095
+ jQuery('#wpvivid_files_list').html(retry);
2096
+ }
2097
+ }
2098
+ catch(err)
2099
+ {
2100
+ alert(err);
2101
+ jQuery('#wpvivid_files_list').html(retry);
2102
+ }
2103
+ },function(XMLHttpRequest, textStatus, errorThrown)
2104
+ {
2105
+ jQuery('#wpvivid_init_download_info').hide();
2106
+ jQuery('#wpvivid_init_download_info').find('.spinner').removeClass('is-active');
2107
+ var error_message = wpvivid_output_ajaxerror('initializing download information', textStatus, errorThrown);
2108
+ alert(error_message);
2109
+ jQuery('#wpvivid_files_list').html(retry);
2110
+ });
2111
+ }
2112
+
2113
+ function wpvivid_download_change_page(page)
2114
+ {
2115
+ var backup_id=wpvivid_download_files_list.backup_id;
2116
+
2117
+ var ajax_data = {
2118
+ 'action':'wpvivid_get_download_page_ex',
2119
+ 'backup_id':backup_id,
2120
+ 'page':page
2121
+ };
2122
+
2123
+ jQuery('#wpvivid_files_list').html('');
2124
+ jQuery('#wpvivid_init_download_info').show();
2125
+ jQuery('#wpvivid_init_download_info').find('.spinner').addClass('is-active');
2126
+
2127
+ wpvivid_post_request_addon(ajax_data, function(data)
2128
+ {
2129
+ jQuery('#wpvivid_init_download_info').hide();
2130
+ jQuery('#wpvivid_init_download_info').find('.spinner').removeClass('is-active');
2131
+ try
2132
+ {
2133
+ var jsonarray = jQuery.parseJSON(data);
2134
+ if (jsonarray.result === 'success')
2135
+ {
2136
+ jQuery('#wpvivid_files_list').html(jsonarray.html);
2137
+ }
2138
+ else{
2139
+ alert(jsonarray.error);
2140
+ }
2141
+ }
2142
+ catch(err)
2143
+ {
2144
+ alert(err);
2145
+ }
2146
+ },function(XMLHttpRequest, textStatus, errorThrown)
2147
+ {
2148
+ jQuery('#wpvivid_init_download_info').hide();
2149
+ jQuery('#wpvivid_init_download_info').find('.spinner').removeClass('is-active');
2150
+ var error_message = wpvivid_output_ajaxerror('initializing download information', textStatus, errorThrown);
2151
+ alert(error_message);
2152
+ });
2153
+ }
2154
+
2155
+ jQuery('#wpvivid_files_list').on("click",'.wpvivid-download',function()
2156
+ {
2157
+ var Obj=jQuery(this);
2158
+ var file_name=Obj.closest('tr').attr('slug');
2159
+ wpvivid_download_files_list.add_download_queue(file_name);
2160
+ });
2161
+ jQuery('#wpvivid_files_list').on("click",'.wpvivid-ready-download',function()
2162
+ {
2163
+ var Obj=jQuery(this);
2164
+ var file_name=Obj.closest('tr').attr('slug');
2165
+ wpvivid_download_files_list.download_now(file_name);
2166
+ });
2167
+
2168
+ jQuery('#wpvivid_files_list').on("click",'.first-page',function() {
2169
+ wpvivid_download_change_page('first');
2170
+ });
2171
+
2172
+ jQuery('#wpvivid_files_list').on("click",'.prev-page',function() {
2173
+ var page=parseInt(jQuery(this).attr('value'));
2174
+ wpvivid_download_change_page(page-1);
2175
+ });
2176
+
2177
+ jQuery('#wpvivid_files_list').on("click",'.next-page',function() {
2178
+ var page=parseInt(jQuery(this).attr('value'));
2179
+ wpvivid_download_change_page(page+1);
2180
+ });
2181
+
2182
+ jQuery('#wpvivid_files_list').on("click",'.last-page',function() {
2183
+ wpvivid_download_change_page('last');
2184
+ });
2185
+
2186
+ jQuery('#wpvivid_files_list').on("keypress", '.current-page', function(){
2187
+ if(event.keyCode === 13){
2188
+ var page = jQuery(this).val();
2189
+ wpvivid_download_change_page(page);
2190
+ }
2191
+ });
2192
+ </script>
2193
+ <?php
2194
+ }
2195
+
2196
  function wpvivid_backuppage_add_progress_module(){
2197
  ?>
2198
  <div class="postbox" id="wpvivid_postbox_backup_percent" style="display: none;">
includes/class-wpvivid-backup-uploader.php CHANGED
@@ -749,7 +749,7 @@ class Wpvivid_BackupUploader
749
  {
750
  var backuplist_count = data;
751
  if(backuplist_count >= backup_max_count){
752
- alert("The maximum number for listing backups is reached, please manually remove a backup from backups list to start uploading.");
753
  }
754
  else {
755
  jQuery("#wpvivid_upload_submit_btn").prop('disabled', true);
749
  {
750
  var backuplist_count = data;
751
  if(backuplist_count >= backup_max_count){
752
+ alert("The backup retention limit for localhost(web server) is reached, please either increase the retention from WPvivid General Settings, or manually delete some old backups.");
753
  }
754
  else {
755
  jQuery("#wpvivid_upload_submit_btn").prop('disabled', true);
includes/class-wpvivid.php CHANGED
@@ -301,6 +301,8 @@ class WPvivid {
301
  add_action('wp_ajax_wpvivid_view_log',array( $this,'view_log'));
302
  //Prepare download backup files
303
  add_action('wp_ajax_wpvivid_prepare_download_backup',array( $this,'prepare_download_backup'));
 
 
304
  //Download backup from site
305
  add_action('wp_ajax_wpvivid_download_backup',array( $this,'download_backup'));
306
  //Delete backup record
@@ -309,6 +311,8 @@ class WPvivid {
309
  add_action('wp_ajax_wpvivid_delete_backup_array',array( $this,'delete_backup_array'));
310
  //
311
  add_action('wp_ajax_wpvivid_init_download_page',array( $this,'init_download_page'));
 
 
312
  //Set security lock for backup record
313
  add_action('wp_ajax_wpvivid_set_security_lock',array( $this,'set_security_lock'));
314
  //Delete task
@@ -2156,7 +2160,7 @@ class WPvivid {
2156
  *
2157
  * @since 0.9.1
2158
  */
2159
- public function init_download_page()
2160
  {
2161
  $this->ajax_check_security();
2162
  try {
@@ -2173,7 +2177,218 @@ class WPvivid {
2173
  die();
2174
  }
2175
  die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2176
  }
 
2177
  /**
2178
  * prepare download backup
2179
  *
@@ -2239,6 +2454,95 @@ class WPvivid {
2239
  die();
2240
  }
2241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2242
  public function deal_prepare_download_shutdown_error()
2243
  {
2244
  if($this->end_shutdown_function==false) {
301
  add_action('wp_ajax_wpvivid_view_log',array( $this,'view_log'));
302
  //Prepare download backup files
303
  add_action('wp_ajax_wpvivid_prepare_download_backup',array( $this,'prepare_download_backup'));
304
+ //Get download progress
305
+ add_action('wp_ajax_wpvivid_get_download_progress',array($this,'get_download_progress'));
306
  //Download backup from site
307
  add_action('wp_ajax_wpvivid_download_backup',array( $this,'download_backup'));
308
  //Delete backup record
311
  add_action('wp_ajax_wpvivid_delete_backup_array',array( $this,'delete_backup_array'));
312
  //
313
  add_action('wp_ajax_wpvivid_init_download_page',array( $this,'init_download_page'));
314
+ //Download backuplist change page
315
+ add_action('wp_ajax_wpvivid_get_download_page_ex',array($this,'get_download_page_ex'));
316
  //Set security lock for backup record
317
  add_action('wp_ajax_wpvivid_set_security_lock',array( $this,'set_security_lock'));
318
  //Delete task
2160
  *
2161
  * @since 0.9.1
2162
  */
2163
+ /*public function init_download_page()
2164
  {
2165
  $this->ajax_check_security();
2166
  try {
2177
  die();
2178
  }
2179
  die();
2180
+ }*/
2181
+
2182
+ /**
2183
+ * return initialization download page data
2184
+ *
2185
+ * @var string $task_id
2186
+ *
2187
+ * @since 0.9.48
2188
+ */
2189
+ public function init_download_page()
2190
+ {
2191
+ $this->ajax_check_security();
2192
+ try {
2193
+ if (isset($_POST['backup_id']) && !empty($_POST['backup_id']) && is_string($_POST['backup_id'])) {
2194
+ $backup_id = sanitize_key($_POST['backup_id']);
2195
+ $backup = WPvivid_Backuplist::get_backup_by_id($backup_id);
2196
+ if ($backup === false) {
2197
+ $ret['result'] = WPVIVID_FAILED;
2198
+ $ret['error'] = 'backup id not found';
2199
+ echo json_encode($ret);
2200
+ die();
2201
+ }
2202
+
2203
+ $backup_item = new WPvivid_Backup_Item($backup);
2204
+
2205
+ $backup_files = $backup_item->get_download_backup_files($backup_id);
2206
+
2207
+ if ($backup_files['result'] == WPVIVID_SUCCESS) {
2208
+ $ret['result'] = WPVIVID_SUCCESS;
2209
+
2210
+ $remote = $backup_item->get_remote();
2211
+
2212
+ foreach ($backup_files['files'] as $file) {
2213
+ $path = $backup_item->get_local_path() . $file['file_name'];
2214
+
2215
+ if (file_exists($path)) {
2216
+ if (filesize($path) == $file['size']) {
2217
+ if (WPvivid_taskmanager::get_download_task_v2($file['file_name']))
2218
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2219
+ $ret['files'][$file['file_name']]['status'] = 'completed';
2220
+ $ret['files'][$file['file_name']]['size'] = size_format(filesize($path), 2);
2221
+ $ret['files'][$file['file_name']]['download_path'] = $path;
2222
+ $download_url = $backup_item->get_local_url() . $file['file_name'];
2223
+ $ret['files'][$file['file_name']]['download_url'] = $download_url;
2224
+
2225
+ continue;
2226
+ }
2227
+ }
2228
+ $ret['files'][$file['file_name']]['size'] = size_format($file['size'], 2);
2229
+
2230
+ if (empty($remote)) {
2231
+ $ret['files'][$file['file_name']]['status'] = 'file_not_found';
2232
+ } else {
2233
+ $task = WPvivid_taskmanager::get_download_task_v2($file['file_name']);
2234
+ if ($task === false) {
2235
+ $ret['files'][$file['file_name']]['status'] = 'need_download';
2236
+ } else {
2237
+ $ret['result'] = WPVIVID_SUCCESS;
2238
+ if ($task['status'] === 'running') {
2239
+ $ret['files'][$file['file_name']]['status'] = 'running';
2240
+ $ret['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2241
+ if (file_exists($path)) {
2242
+ $ret['files'][$file['file_name']]['downloaded_size'] = size_format(filesize($path), 2);
2243
+ } else {
2244
+ $ret['files'][$file['file_name']]['downloaded_size'] = '0';
2245
+ }
2246
+ } elseif ($task['status'] === 'timeout') {
2247
+ $ret['files'][$file['file_name']]['status'] = 'timeout';
2248
+ $ret['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2249
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2250
+ } elseif ($task['status'] === 'completed') {
2251
+ $ret['files'][$file['file_name']]['status'] = 'completed';
2252
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2253
+ } elseif ($task['status'] === 'error') {
2254
+ $ret['files'][$file['file_name']]['status'] = 'error';
2255
+ $ret['files'][$file['file_name']]['error'] = $task['error'];
2256
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2257
+ }
2258
+ }
2259
+ }
2260
+ }
2261
+ } else {
2262
+ $ret = $backup_files;
2263
+ }
2264
+
2265
+
2266
+ if (!class_exists('WPvivid_Files_List'))
2267
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-backup-restore-page-display.php';
2268
+
2269
+ $files_list = new WPvivid_Files_List();
2270
+
2271
+ $files_list->set_files_list($ret['files'], $backup_id);
2272
+ $files_list->prepare_items();
2273
+ ob_start();
2274
+ $files_list->display();
2275
+ $ret['html'] = ob_get_clean();
2276
+
2277
+ echo json_encode($ret);
2278
+ }
2279
+ }
2280
+ catch (Exception $error) {
2281
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
2282
+ error_log($message);
2283
+ echo json_encode(array('result'=>'failed','error'=>$message));
2284
+ }
2285
+ die();
2286
+ }
2287
+
2288
+ public function get_download_page_ex()
2289
+ {
2290
+ $this->ajax_check_security();
2291
+ try {
2292
+ if (isset($_POST['backup_id']) && !empty($_POST['backup_id']) && is_string($_POST['backup_id'])) {
2293
+ if (isset($_POST['page'])) {
2294
+ $page = $_POST['page'];
2295
+ } else {
2296
+ $page = 1;
2297
+ }
2298
+
2299
+ $backup_id = sanitize_key($_POST['backup_id']);
2300
+ $backup = WPvivid_Backuplist::get_backup_by_id($backup_id);
2301
+ if ($backup === false) {
2302
+ $ret['result'] = WPVIVID_FAILED;
2303
+ $ret['error'] = 'backup id not found';
2304
+ echo json_encode($ret);
2305
+ die();
2306
+ }
2307
+
2308
+ $backup_item = new WPvivid_Backup_Item($backup);
2309
+
2310
+ $backup_files = $backup_item->get_download_backup_files($backup_id);
2311
+
2312
+ if ($backup_files['result'] == WPVIVID_SUCCESS) {
2313
+ $ret['result'] = WPVIVID_SUCCESS;
2314
+
2315
+ $remote = $backup_item->get_remote();
2316
+
2317
+ foreach ($backup_files['files'] as $file) {
2318
+ $path = $backup_item->get_local_path() . $file['file_name'];
2319
+
2320
+ if (file_exists($path)) {
2321
+ if (filesize($path) == $file['size']) {
2322
+ if (WPvivid_taskmanager::get_download_task_v2($file['file_name']))
2323
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2324
+ $ret['files'][$file['file_name']]['status'] = 'completed';
2325
+ $ret['files'][$file['file_name']]['size'] = size_format(filesize($path), 2);
2326
+ $ret['files'][$file['file_name']]['download_path'] = $path;
2327
+ $download_url = $backup_item->get_local_url() . $file['file_name'];
2328
+ $ret['files'][$file['file_name']]['download_url'] = $download_url;
2329
+
2330
+ continue;
2331
+ }
2332
+ }
2333
+ $ret['files'][$file['file_name']]['size'] = size_format($file['size'], 2);
2334
+
2335
+ if (empty($remote)) {
2336
+ $ret['files'][$file['file_name']]['status'] = 'file_not_found';
2337
+ } else {
2338
+ $task = WPvivid_taskmanager::get_download_task_v2($file['file_name']);
2339
+ if ($task === false) {
2340
+ $ret['files'][$file['file_name']]['status'] = 'need_download';
2341
+ } else {
2342
+ $ret['result'] = WPVIVID_SUCCESS;
2343
+ if ($task['status'] === 'running') {
2344
+ $ret['files'][$file['file_name']]['status'] = 'running';
2345
+ $ret['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2346
+ if (file_exists($path)) {
2347
+ $ret['files'][$file['file_name']]['downloaded_size'] = size_format(filesize($path), 2);
2348
+ } else {
2349
+ $ret['files'][$file['file_name']]['downloaded_size'] = '0';
2350
+ }
2351
+ } elseif ($task['status'] === 'timeout') {
2352
+ $ret['files'][$file['file_name']]['status'] = 'timeout';
2353
+ $ret['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2354
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2355
+ } elseif ($task['status'] === 'completed') {
2356
+ $ret['files'][$file['file_name']]['status'] = 'completed';
2357
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2358
+ } elseif ($task['status'] === 'error') {
2359
+ $ret['files'][$file['file_name']]['status'] = 'error';
2360
+ $ret['files'][$file['file_name']]['error'] = $task['error'];
2361
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2362
+ }
2363
+ }
2364
+ }
2365
+ }
2366
+ } else {
2367
+ $ret = $backup_files;
2368
+ }
2369
+
2370
+ if (!class_exists('WPvivid_Files_List'))
2371
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-backup-restore-page-display.php';
2372
+
2373
+ $files_list = new WPvivid_Files_List();
2374
+
2375
+ $files_list->set_files_list($ret['files'], $backup_id, $page);
2376
+ $files_list->prepare_items();
2377
+ ob_start();
2378
+ $files_list->display();
2379
+ $ret['html'] = ob_get_clean();
2380
+
2381
+ echo json_encode($ret);
2382
+ }
2383
+ }
2384
+ catch (Exception $error) {
2385
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
2386
+ error_log($message);
2387
+ echo json_encode(array('result'=>'failed','error'=>$message));
2388
+ }
2389
+ die();
2390
  }
2391
+
2392
  /**
2393
  * prepare download backup
2394
  *
2454
  die();
2455
  }
2456
 
2457
+ public function get_download_progress()
2458
+ {
2459
+ $this->ajax_check_security();
2460
+ try {
2461
+ if (isset($_POST['backup_id'])) {
2462
+ $backup_id = sanitize_key($_POST['backup_id']);
2463
+ $ret['result'] = WPVIVID_SUCCESS;
2464
+ $ret['files'] = array();
2465
+ $ret['need_update'] = false;
2466
+
2467
+ $backup = WPvivid_Backuplist::get_backup_by_id($backup_id);
2468
+ if ($backup === false) {
2469
+ $ret['result'] = WPVIVID_FAILED;
2470
+ $ret['error'] = 'backup id not found';
2471
+ return $ret;
2472
+ }
2473
+
2474
+ $backup_item = new WPvivid_Backup_Item($backup);
2475
+
2476
+ $backup_files = $backup_item->get_download_backup_files($backup_id);
2477
+
2478
+ foreach ($backup_files['files'] as $file) {
2479
+ $path = $backup_item->get_local_path() . $file['file_name'];
2480
+ if (file_exists($path)) {
2481
+ $downloaded_size = size_format(filesize($path), 2);
2482
+ } else {
2483
+ $downloaded_size = '0';
2484
+ }
2485
+ $file['size'] = size_format($file['size'], 2);
2486
+
2487
+ $task = WPvivid_taskmanager::get_download_task_v2($file['file_name']);
2488
+ if ($task === false) {
2489
+ $ret['files'][$file['file_name']]['status'] = 'need_download';
2490
+ $ret['files'][$file['file_name']]['html'] = '<div class="wpvivid-element-space-bottom">
2491
+ <span class="wpvivid-element-space-right">Retriving (remote storage to web server)</span><span class="wpvivid-element-space-right">|</span><span>File Size: </span><span class="wpvivid-element-space-right">' . $file['size'] . '</span><span class="wpvivid-element-space-right">|</span><span>Downloaded Size: </span><span>0</span>
2492
+ </div>
2493
+ <div style="width:100%;height:10px; background-color:#dcdcdc;">
2494
+ <div style="background-color:#0085ba; float:left;width:0%;height:10px;"></div>
2495
+ </div>';
2496
+ $ret['need_update'] = true;
2497
+ } else {
2498
+ if ($task['status'] === 'running') {
2499
+ $ret['files'][$file['file_name']]['status'] = 'running';
2500
+ $ret['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2501
+ $ret['files'][$file['file_name']]['html'] = '<div class="wpvivid-element-space-bottom">
2502
+ <span class="wpvivid-element-space-right">Retriving (remote storage to web server)</span><span class="wpvivid-element-space-right">|</span><span>File Size: </span><span class="wpvivid-element-space-right">' . $file['size'] . '</span><span class="wpvivid-element-space-right">|</span><span>Downloaded Size: </span><span>' . $downloaded_size . '</span>
2503
+ </div>
2504
+ <div style="width:100%;height:10px; background-color:#dcdcdc;">
2505
+ <div style="background-color:#0085ba; float:left;width:' . $task['progress_text'] . '%;height:10px;"></div>
2506
+ </div>';
2507
+ $ret['need_update'] = true;
2508
+ } elseif ($task['status'] === 'timeout') {
2509
+ $ret['files'][$file['file_name']]['status'] = 'timeout';
2510
+ $ret['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2511
+ $ret['files'][$file['file_name']]['html'] = '<div class="wpvivid-element-space-bottom">
2512
+ <span>Download timeout, please retry.</span>
2513
+ </div>
2514
+ <div>
2515
+ <span>' . __('File Size: ', 'wpvivid') . '</span><span class="wpvivid-element-space-right">' . $file['size'] . '</span><span class="wpvivid-element-space-right">|</span><span class="wpvivid-element-space-right"><a class="wpvivid-download" style="cursor: pointer;">Prepare to Download</a></span>
2516
+ </div>';
2517
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2518
+ } elseif ($task['status'] === 'completed') {
2519
+ $ret['files'][$file['file_name']]['status'] = 'completed';
2520
+ $ret['files'][$file['file_name']]['html'] = '<span>' . __('File Size: ', 'wpvivid') . '</span><span class="wpvivid-element-space-right">' . $file['size'] . '</span><span class="wpvivid-element-space-right">|</span><span class="wpvivid-element-space-right wpvivid-ready-download"><a style="cursor: pointer;">Download</a></span>';
2521
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2522
+ } elseif ($task['status'] === 'error') {
2523
+ $ret['files'][$file['file_name']]['status'] = 'error';
2524
+ $ret['files'][$file['file_name']]['error'] = $task['error'];
2525
+ $ret['files'][$file['file_name']]['html'] = '<div class="wpvivid-element-space-bottom">
2526
+ <span>' . $task['error'] . '</span>
2527
+ </div>
2528
+ <div>
2529
+ <span>' . __('File Size: ', 'wpvivid') . '</span><span class="wpvivid-element-space-right">' . $file['size'] . '</span><span class="wpvivid-element-space-right">|</span><span class="wpvivid-element-space-right"><a class="wpvivid-download" style="cursor: pointer;">Prepare to Download</a></span>
2530
+ </div>';
2531
+ WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
2532
+ }
2533
+ }
2534
+ }
2535
+ echo json_encode($ret);
2536
+ }
2537
+ }
2538
+ catch (Exception $error) {
2539
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
2540
+ error_log($message);
2541
+ echo json_encode(array('result'=>'failed','error'=>$message));
2542
+ }
2543
+ die();
2544
+ }
2545
+
2546
  public function deal_prepare_download_shutdown_error()
2547
  {
2548
  if($this->end_shutdown_function==false) {
includes/customclass/class-wpvivid-ftpclass.php CHANGED
@@ -414,14 +414,32 @@ class WPvivid_FTPClass extends WPvivid_Remote{
414
  }
415
  }
416
  public function do_chdir($conn,$path){
 
417
  if(!@ftp_chdir($conn,$path))
418
  {
419
- if ( ! ftp_mkdir( $conn, $path ) ) {
420
- return array('result'=>WPVIVID_FAILED,'error'=>'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
 
 
 
 
 
 
 
 
 
 
 
421
  }
422
- if (!@ftp_chdir($conn,$path)){
 
 
423
  return array('result'=>WPVIVID_FAILED,'error'=>'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
424
  }
 
 
 
 
425
  }
426
  $temp_file = md5(rand());
427
  $temp_path = trailingslashit(WP_CONTENT_DIR).WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.$temp_file;
414
  }
415
  }
416
  public function do_chdir($conn,$path){
417
+ @ftp_chdir($conn,'/');
418
  if(!@ftp_chdir($conn,$path))
419
  {
420
+ $parts = explode('/',$path);
421
+ foreach($parts as $part){
422
+ if($part !== '') {
423
+ if (!@ftp_chdir($conn, $part)) {
424
+ if (!ftp_mkdir($conn, $part)) {
425
+ return array('result' => WPVIVID_FAILED, 'error' => 'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
426
+ }
427
+
428
+ if (!@ftp_chdir($conn, $part)) {
429
+ return array('result' => WPVIVID_FAILED, 'error' => 'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
430
+ }
431
+ }
432
+ }
433
  }
434
+
435
+ /*if ( ! ftp_mkdir( $conn, $path ) )
436
+ {
437
  return array('result'=>WPVIVID_FAILED,'error'=>'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
438
  }
439
+ if (!@ftp_chdir($conn,$path))
440
+ {
441
+ return array('result'=>WPVIVID_FAILED,'error'=>'Failed to create a backup. Make sure you have sufficient privileges to perform the operation.');
442
+ }*/
443
  }
444
  $temp_file = md5(rand());
445
  $temp_path = trailingslashit(WP_CONTENT_DIR).WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.$temp_file;
includes/customclass/class-wpvivid-sftpclass.php CHANGED
@@ -358,7 +358,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
358
  return $ret;
359
  }
360
 
361
- $this->options['password']=sanitize_text_field($this->options['password']);
362
 
363
  if(empty($this->options['password']))
364
  {
358
  return $ret;
359
  }
360
 
361
+ //$this->options['password']=sanitize_text_field($this->options['password']);
362
 
363
  if(empty($this->options['password']))
364
  {
includes/upload-cleaner/class-wpvivid-upload-cleaner-setting.php CHANGED
@@ -905,7 +905,7 @@ class WPvivid_Uploads_Cleaner_Setting
905
  <div class="postbox schedule-tab-block setting-page-content">
906
  <div class="wpvivid-element-space-bottom">
907
  <label for="wpvivid_uc_scan_file_types">
908
- <input style="margin: 4px;" id="wpvivid_uc_scan_file_types" type="checkbox" option="setting" name="wpvivid_uc_scan_file_types" <?php esc_attr_e($quick_scan); ?> />
909
  <span><strong><?php _e('Enable Quick Scan', 'wpvivid-backuprestore'); ?></strong></span>
910
  </label>
911
  </div>
905
  <div class="postbox schedule-tab-block setting-page-content">
906
  <div class="wpvivid-element-space-bottom">
907
  <label for="wpvivid_uc_scan_file_types">
908
+ <input style="margin: 4px;" id="wpvivid_uc_quick_scan" type="checkbox" option="setting" name="wpvivid_uc_quick_scan" <?php esc_attr_e($quick_scan); ?> />
909
  <span><strong><?php _e('Enable Quick Scan', 'wpvivid-backuprestore'); ?></strong></span>
910
  </label>
911
  </div>
includes/upload-cleaner/class-wpvivid-uploads-scanner.php CHANGED
@@ -421,7 +421,7 @@ class WPvivid_Uploads_Scanner
421
  {
422
  $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' );
423
  $html = do_shortcode( $html );
424
- $html = wp_make_content_images_responsive( $html );
425
 
426
  if ( !class_exists("DOMDocument") )
427
  {
@@ -456,7 +456,7 @@ class WPvivid_Uploads_Scanner
456
 
457
  $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' );
458
  $html = do_shortcode( $html );
459
- $html = wp_make_content_images_responsive( $html );
460
 
461
  if ( !class_exists("DOMDocument") )
462
  {
421
  {
422
  $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' );
423
  $html = do_shortcode( $html );
424
+ $html = wp_filter_content_tags( $html );
425
 
426
  if ( !class_exists("DOMDocument") )
427
  {
456
 
457
  $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' );
458
  $html = do_shortcode( $html );
459
+ $html = wp_filter_content_tags( $html );
460
 
461
  if ( !class_exists("DOMDocument") )
462
  {
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, cleaner, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
- Tested up to: 5.5.3
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.47
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -181,10 +181,16 @@ Thank you for translating WPvivid Backup Plugin to your languages!
181
 
182
  * [Andrew Galas](https://profiles.wordpress.org/andrewgalas) (Polish)
183
  * [Shohei OKADA](https://ja.gravatar.com/silversword0630) (Japanese)
184
- * Francesco Tosi (Italian)
185
- * Valentin Lyong (Bulgarian)
 
186
 
187
  == Changelog ==
 
 
 
 
 
188
  = 0.9.47 =
189
  - Added support for Amazon S3 South Africa region.
190
  - Fixed: Folder would not be backed up when it's name matches regex: ^uploads.*$.
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, cleaner, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
+ Tested up to: 5.6
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.48
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
181
 
182
  * [Andrew Galas](https://profiles.wordpress.org/andrewgalas) (Polish)
183
  * [Shohei OKADA](https://ja.gravatar.com/silversword0630) (Japanese)
184
+ * [Francesco Tosi](https://profiles.wordpress.org/seventhose/) (Italian)
185
+ * [Valentin Lyong](https://profiles.wordpress.org/icedge/) (Bulgarian)
186
+ * [Daniel Wilczkowiak](https://profiles.wordpress.org/virtual03/) (German)
187
 
188
  == Changelog ==
189
+ = 0.9.48 =
190
+ - Redesigned the Download section for better UX.
191
+ - Fixed the insufficient permission error that occurred when authenticating FTP in some cases.
192
+ - Fixed the incorrect credential error that occurred when authenticating SFTP in some cases.
193
+ - Successfully tested with WordPress 5.6.
194
  = 0.9.47 =
195
  - Added support for Amazon S3 South Africa region.
196
  - Fixed: Folder would not be backed up when it's name matches regex: ^uploads.*$.
wpvivid-backuprestore.php CHANGED
@@ -7,7 +7,7 @@
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.47
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.47' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');
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.48
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.48' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');