Migration, Backup, Staging – WPvivid - Version 0.9.69

Version Description

  • Updated: For security reasons, adding Google Drive, Dropbox, OneDrive now needs to get authentication first.
  • Updated: Changed time in a log file to local time.
  • Fixed the curl 60 error that could appear when backing up to Google Drive in some cases.
  • Fixed: Disabling backup splitting did not take effect on PHP 8 sites.
  • Fixed: Uploading backups to Dropbox failed in some cases.
  • Fixed some bugs in the plugin code.
  • Optimized the plugin code.
Download this release

Release Info

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

Code changes from version 0.9.68 to 0.9.69

admin/partials/wpvivid-admin-display.php CHANGED
@@ -119,6 +119,7 @@ foreach ($page_array as $page_name){
119
  document.getElementById(contentName).style.display = "block";
120
  evt.currentTarget.className += " nav-tab-active";
121
  jQuery( document ).trigger( 'wpvivid-switch-tabs', contentName );
 
122
  }
123
  function switchrestoreTabs(evt,contentName) {
124
  // Declare all variables
@@ -180,6 +181,43 @@ foreach ($page_array as $page_name){
180
  document.getElementById(contentName).style.display = "block";
181
  evt.currentTarget.className += " nav-tab-active";
182
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  function wpvivid_getrequest()
184
  {
185
  wpvivid_click_switch_page('wrap', wpvivid_page_request, false);
@@ -216,6 +254,21 @@ foreach ($page_array as $page_name){
216
  <?php
217
  }
218
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  });
220
 
221
  </script>
119
  document.getElementById(contentName).style.display = "block";
120
  evt.currentTarget.className += " nav-tab-active";
121
  jQuery( document ).trigger( 'wpvivid-switch-tabs', contentName );
122
+ //nav-tab-active
123
  }
124
  function switchrestoreTabs(evt,contentName) {
125
  // Declare all variables
181
  document.getElementById(contentName).style.display = "block";
182
  evt.currentTarget.className += " nav-tab-active";
183
  }
184
+ function switchstorageTabs(remote_type,storage_page_id)
185
+ {
186
+ var i, tabcontent, tablinks,contentName;
187
+ contentName='storage-page';
188
+ // Get all elements with class="tabcontent" and hide them
189
+ tabcontent = document.getElementsByClassName("wrap-tab-content");
190
+ for (i = 0; i < tabcontent.length; i++) {
191
+ tabcontent[i].style.display = "none";
192
+ }
193
+
194
+ // Get all elements with class="wrap-nav-tab" and remove the class "active"
195
+ tablinks = document.getElementsByClassName("wrap-nav-tab");
196
+ for (i = 0; i < tablinks.length; i++) {
197
+ tablinks[i].className = tablinks[i].className.replace(" nav-tab-active", "");
198
+ }
199
+
200
+ // Show the current tab, and add an "nav-tab-active" class to the button that opened the tab
201
+ document.getElementById(contentName).style.display = "block";
202
+ jQuery('#wpvivid_tab_remote_storage').addClass('nav-tab-active');
203
+ jQuery( document ).trigger( 'wpvivid-switch-tabs', contentName );
204
+ start_select_remote_storage(remote_type,storage_page_id);
205
+
206
+ }
207
+
208
+ function start_select_remote_storage(remote_type, storage_page_id)
209
+ {
210
+ var i, tablecontent, tablinks;
211
+ tablinks = document.getElementsByClassName("storage-providers");
212
+ for (i = 0; i < tablinks.length; i++) {
213
+ tablinks[i].className = tablinks[i].className.replace("storage-providers-active", "");
214
+ }
215
+ jQuery("div[remote_type='"+remote_type+"']").addClass('storage-providers-active');
216
+
217
+ jQuery(".storage-account-page").hide();
218
+ jQuery("#"+storage_page_id).show();
219
+ }
220
+
221
  function wpvivid_getrequest()
222
  {
223
  wpvivid_click_switch_page('wrap', wpvivid_page_request, false);
254
  <?php
255
  }
256
  ?>
257
+
258
+ <?php
259
+ if (isset($_GET['main_tab']))
260
+ {
261
+ $tab=esc_html($_GET['main_tab']);
262
+
263
+ if($tab=='storage')
264
+ {
265
+ $sub_tab=isset($_GET['sub_tab'])?$_GET['sub_tab']:'googledrive';
266
+ $sub_page=isset($_GET['sub_page'])?$_GET['sub_page']:'storage_account_google_drive';
267
+ echo "switchstorageTabs('$sub_tab','$sub_page');";
268
+ }
269
+ }
270
+ ?>
271
+ //switchTabs(event,'storage-page')
272
  });
273
 
274
  </script>
admin/partials/wpvivid-backup-restore-page-display.php CHANGED
@@ -1636,6 +1636,7 @@ function wpvivid_backuppage_add_page_restore(){
1636
  var ajax_data={
1637
  'action':'wpvivid_get_restore_progress',
1638
  'wpvivid_restore' : '1',
 
1639
  };
1640
 
1641
  if(wpvivid_restore_timeout){
1636
  var ajax_data={
1637
  'action':'wpvivid_get_restore_progress',
1638
  'wpvivid_restore' : '1',
1639
+ 'backup_id':m_restore_backup_id,
1640
  };
1641
 
1642
  if(wpvivid_restore_timeout){
admin/partials/wpvivid-settings-page-display.php CHANGED
@@ -298,7 +298,15 @@ function wpvivid_email_report()
298
  function wpvivid_clean_junk()
299
  {
300
  global $wpvivid_plugin;
301
- $junk_file=$wpvivid_plugin->_junk_files_info();
 
 
 
 
 
 
 
 
302
  ?>
303
  <div class="postbox schedule-tab-block" id="wpvivid_clean_junk">
304
  <div>
@@ -430,6 +438,11 @@ function wpvivid_clean_junk()
430
  });
431
  }
432
  }
 
 
 
 
 
433
  </script>
434
  <?php
435
  }
@@ -613,17 +626,17 @@ function wpvivid_advanced_settings()
613
  <div style="padding-top: 10px;">
614
  <div><strong><?php _e('Compress Files Every', 'wpvivid-backuprestore'); ?></strong></div>
615
  <div class="setting-tab-block">
616
- <input type="text" placeholder="400" option="setting" name="max_file_size" id="wpvivid_max_zip" class="all-options" value="<?php esc_attr_e(str_replace('M', '', $general_setting['options']['wpvivid_compress_setting']['max_file_size']), 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/\D/g,'')" />MB
617
  <div><p><?php _e( 'Some web hosting providers limit large zip files (e.g. 200MB), and therefore splitting your backup into many parts is an ideal way to avoid hitting the limitation if you are running a big website. Please try to adjust the value if you are encountering backup errors. If you use a value of 0 MB, any backup files won\'t be split.', 'wpvivid-backuprestore' ); ?></div></p>
618
  </div>
619
  <div><strong><?php _e('Exclude the files which are larger than', 'wpvivid-backuprestore'); ?></strong></div>
620
  <div class="setting-tab-block">
621
- <input type="text" placeholder="400" option="setting" name="exclude_file_size" id="wpvivid_ignore_large" class="all-options" value="<?php esc_attr_e($general_setting['options']['wpvivid_compress_setting']['exclude_file_size'], 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/\D/g,'')" />MB
622
  <div><p><?php _e( 'Using the option will ignore the file larger than the certain size in MB when backing up, \'0\' (zero) means unlimited.', 'wpvivid-backuprestore' ); ?></p></div>
623
  </div>
624
  <div><strong><?php _e('PHP script execution timeout for backup', 'wpvivid-backuprestore'); ?></strong></div>
625
  <div class="setting-tab-block">
626
- <input type="text" placeholder="600" option="setting" name="max_execution_time" id="wpvivid_option_timeout" class="all-options" value="<?php esc_attr_e($general_setting['options']['wpvivid_common_setting']['max_execution_time'], 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/\D/g,'')" />Seconds
627
  <div><p><?php _e( 'The time-out is not your server PHP time-out. With the execution time exhausted, our plugin will shut the process of backup down. If the progress of backup encounters a time-out, that means you have a medium or large sized website, please try to scale the value bigger.', 'wpvivid-backuprestore' ); ?></p></div>
628
  </div>
629
  <div><strong><?php _e('PHP script execution timeout for restore', 'wpvivid-backuprestore'); ?></strong></div>
@@ -643,7 +656,7 @@ function wpvivid_advanced_settings()
643
  </div>
644
  <div><strong><?php _e('Chunk Size', 'wpvivid-backuprestore'); ?></strong></div>
645
  <div class="setting-tab-block">
646
- <input type="text" placeholder="2" option="setting" name="migrate_size" class="all-options" value="<?php esc_attr_e($general_setting['options']['wpvivid_common_setting']['migrate_size']); ?>" onkeyup="value=value.replace(/\D/g,'')" />KB
647
  <div><p><?php _e('e.g.  if you choose a chunk size of 2MB, a 8MB file will use 4 chunks. Decreasing this value will break the ISP\'s transmission limit, for example:512KB', 'wpvivid-backuprestore'); ?></p></div>
648
  </div>
649
  <div>
298
  function wpvivid_clean_junk()
299
  {
300
  global $wpvivid_plugin;
301
+ //$junk_file=$wpvivid_plugin->_junk_files_info();
302
+ $junk_file['sum_size']=0;
303
+ $junk_file['log_dir_size']=0;
304
+ $junk_file['backup_dir_size'] =0;
305
+ $junk_file['log_path'] = $log_dir = $wpvivid_plugin->wpvivid_log->GetSaveLogFolder();
306
+ $dir = WPvivid_Setting::get_backupdir();
307
+ $junk_file['old_files_path'] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . WPVIVID_DEFAULT_ROLLBACK_DIR;
308
+ $dir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $dir;
309
+ $junk_file['junk_path'] = $dir;
310
  ?>
311
  <div class="postbox schedule-tab-block" id="wpvivid_clean_junk">
312
  <div>
438
  });
439
  }
440
  }
441
+
442
+ jQuery(document).ready(function ()
443
+ {
444
+ wpvivid_calculate_diskspaceused();
445
+ });
446
  </script>
447
  <?php
448
  }
626
  <div style="padding-top: 10px;">
627
  <div><strong><?php _e('Compress Files Every', 'wpvivid-backuprestore'); ?></strong></div>
628
  <div class="setting-tab-block">
629
+ <input type="text" placeholder="200" option="setting" name="max_file_size" id="wpvivid_max_zip" class="all-options" value="<?php esc_attr_e(str_replace('M', '', $general_setting['options']['wpvivid_compress_setting']['max_file_size']), 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/\D/g,'')" />MB
630
  <div><p><?php _e( 'Some web hosting providers limit large zip files (e.g. 200MB), and therefore splitting your backup into many parts is an ideal way to avoid hitting the limitation if you are running a big website. Please try to adjust the value if you are encountering backup errors. If you use a value of 0 MB, any backup files won\'t be split.', 'wpvivid-backuprestore' ); ?></div></p>
631
  </div>
632
  <div><strong><?php _e('Exclude the files which are larger than', 'wpvivid-backuprestore'); ?></strong></div>
633
  <div class="setting-tab-block">
634
+ <input type="text" placeholder="0" option="setting" name="exclude_file_size" id="wpvivid_ignore_large" class="all-options" value="<?php esc_attr_e($general_setting['options']['wpvivid_compress_setting']['exclude_file_size'], 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/\D/g,'')" />MB
635
  <div><p><?php _e( 'Using the option will ignore the file larger than the certain size in MB when backing up, \'0\' (zero) means unlimited.', 'wpvivid-backuprestore' ); ?></p></div>
636
  </div>
637
  <div><strong><?php _e('PHP script execution timeout for backup', 'wpvivid-backuprestore'); ?></strong></div>
638
  <div class="setting-tab-block">
639
+ <input type="text" placeholder="900" option="setting" name="max_execution_time" id="wpvivid_option_timeout" class="all-options" value="<?php esc_attr_e($general_setting['options']['wpvivid_common_setting']['max_execution_time'], 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/\D/g,'')" />Seconds
640
  <div><p><?php _e( 'The time-out is not your server PHP time-out. With the execution time exhausted, our plugin will shut the process of backup down. If the progress of backup encounters a time-out, that means you have a medium or large sized website, please try to scale the value bigger.', 'wpvivid-backuprestore' ); ?></p></div>
641
  </div>
642
  <div><strong><?php _e('PHP script execution timeout for restore', 'wpvivid-backuprestore'); ?></strong></div>
656
  </div>
657
  <div><strong><?php _e('Chunk Size', 'wpvivid-backuprestore'); ?></strong></div>
658
  <div class="setting-tab-block">
659
+ <input type="text" placeholder="2048" option="setting" name="migrate_size" class="all-options" value="<?php esc_attr_e($general_setting['options']['wpvivid_common_setting']['migrate_size']); ?>" onkeyup="value=value.replace(/\D/g,'')" />KB
660
  <div><p><?php _e('e.g.  if you choose a chunk size of 2MB, a 8MB file will use 4 chunks. Decreasing this value will break the ISP\'s transmission limit, for example:512KB', 'wpvivid-backuprestore'); ?></p></div>
661
  </div>
662
  <div>
includes/class-wpvivid-compress-default.php CHANGED
@@ -27,7 +27,7 @@ abstract class Wpvivid_Compress_Default{
27
  }
28
  public function filesplit($max_size,$files){
29
  $packages = array();
30
- if($max_size == 0 || empty($max_size)){
31
  $packages[] = $files;
32
  }else{
33
  $sizenum = 0;
27
  }
28
  public function filesplit($max_size,$files){
29
  $packages = array();
30
+ if($max_size == 0 || $max_size === '0M' || empty($max_size)){
31
  $packages[] = $files;
32
  }else{
33
  $sizenum = 0;
includes/class-wpvivid-log.php CHANGED
@@ -28,7 +28,8 @@ class WPvivid_Log
28
  @unlink( $this->log_file);
29
  }
30
  $this->log_file_handle = fopen($this->log_file, 'a');
31
- $time =date("Y-m-d H:i:s",time());
 
32
  $text='Log created: '.$time."\n";
33
  $text.='Type: '.$describe."\n";
34
  fwrite($this->log_file_handle,$text);
@@ -59,7 +60,8 @@ class WPvivid_Log
59
  {
60
  if ($this->log_file_handle)
61
  {
62
- $time =date("Y-m-d H:i:s",time());
 
63
  $text='['.$time.']'.'['.$type.']'.$log."\n";
64
  fwrite($this->log_file_handle,$text );
65
  }
@@ -166,7 +168,8 @@ class WPvivid_Log
166
  $log.=' is_multisite:0';
167
  }
168
 
169
- $time =date("Y-m-d H:i:s",time());
 
170
  $text='['.$time.']'.'[notice]'.$log."\n";
171
  fwrite($this->log_file_handle,$text );
172
  }
28
  @unlink( $this->log_file);
29
  }
30
  $this->log_file_handle = fopen($this->log_file, 'a');
31
+ $offset=get_option('gmt_offset');
32
+ $time =date("Y-m-d H:i:s",time()+$offset*60*60);
33
  $text='Log created: '.$time."\n";
34
  $text.='Type: '.$describe."\n";
35
  fwrite($this->log_file_handle,$text);
60
  {
61
  if ($this->log_file_handle)
62
  {
63
+ $offset=get_option('gmt_offset');
64
+ $time =date("Y-m-d H:i:s",time()+$offset*60*60);
65
  $text='['.$time.']'.'['.$type.']'.$log."\n";
66
  fwrite($this->log_file_handle,$text );
67
  }
168
  $log.=' is_multisite:0';
169
  }
170
 
171
+ $offset=get_option('gmt_offset');
172
+ $time =date("Y-m-d H:i:s",time()+$offset*60*60);
173
  $text='['.$time.']'.'[notice]'.$log."\n";
174
  fwrite($this->log_file_handle,$text );
175
  }
includes/class-wpvivid-mysqldump.php CHANGED
@@ -116,7 +116,7 @@ class WPvivid_Mysqldump
116
  'databases' => false,
117
  'default-character-set' => WPvivid_Mysqldump::UTF8,
118
  'disable-keys' => true,
119
- 'extended-insert' => true,
120
  'events' => false,
121
  'hex-blob' => true, /* faster than escaped content */
122
  'net_buffer_length' => self::MAXLINESIZE,
116
  'databases' => false,
117
  'default-character-set' => WPvivid_Mysqldump::UTF8,
118
  'disable-keys' => true,
119
+ 'extended-insert' => false,
120
  'events' => false,
121
  'hex-blob' => true, /* faster than escaped content */
122
  'net_buffer_length' => self::MAXLINESIZE,
includes/class-wpvivid.php CHANGED
@@ -364,8 +364,6 @@ class WPvivid {
364
  add_action('wp_ajax_wpvivid_get_restore_progress',array( $this,'get_restore_progress'));
365
  add_action('wp_ajax_wpvivid_get_download_restore_progress',array( $this,'download_restore_progress'));
366
  //When restoring the database use wp_ajax_nopriv_
367
- add_action('wp_ajax_nopriv_wpvivid_init_restore_page',array( $this,'init_restore_page'));
368
- add_action('wp_ajax_nopriv_wpvivid_delete_last_restore_data',array( $this,'delete_last_restore_data'));
369
  add_action('wp_ajax_nopriv_wpvivid_restore',array( $this,'restore'));
370
  add_action('wp_ajax_nopriv_wpvivid_get_restore_progress',array( $this,'get_restore_progress'));
371
  add_action('wp_ajax_wpvivid_list_tasks',array( $this,'list_tasks'));
@@ -1227,14 +1225,7 @@ class WPvivid {
1227
  $this->end_shutdown_function=true;
1228
  die();
1229
  }
1230
- catch (Error $e)
1231
- {
1232
- //catch error and stop task recording history
1233
- $this->deal_task_error($task_id,'error',$e);
1234
- $this->wpvivid_log->CloseFile();
1235
- $this->end_shutdown_function=true;
1236
- die();
1237
- }
1238
  $this->end_shutdown_function=true;
1239
  die();
1240
  }
@@ -1393,7 +1384,13 @@ class WPvivid {
1393
  $this->update_last_backup_task($task_msg);
1394
  }
1395
  WPvivid_Schedule::clear_monitor_schedule($task['id']);
1396
- WPvivid_mail_report::send_report_mail($task);
 
 
 
 
 
 
1397
  }
1398
 
1399
  function wpvivid_mark_task($task)
@@ -3645,6 +3642,8 @@ class WPvivid {
3645
  */
3646
  public function restore()
3647
  {
 
 
3648
  $this->end_shutdown_function=false;
3649
  register_shutdown_function(array($this,'deal_restore_shutdown_error'));
3650
  if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id']))
@@ -3654,6 +3653,11 @@ class WPvivid {
3654
  }
3655
 
3656
  $backup_id=sanitize_key($_POST['backup_id']);
 
 
 
 
 
3657
 
3658
  $this->restore_data=new WPvivid_restore_data();
3659
 
@@ -3845,10 +3849,26 @@ class WPvivid {
3845
  */
3846
  public function get_restore_progress()
3847
  {
3848
- try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3849
  $this->restore_data = new WPvivid_restore_data();
3850
 
3851
- if ($this->restore_data->has_restore()) {
 
3852
  $ret['result'] = 'success';
3853
  $ret['status'] = $this->restore_data->get_restore_status();
3854
  if ($ret['status'] == WPVIVID_RESTORE_ERROR) {
@@ -4890,7 +4910,7 @@ class WPvivid {
4890
  $ret['result']=WPVIVID_FAILED;
4891
  if(!isset($data['max_file_size']))
4892
  {
4893
- $ret['error']=__('The maximum zip file size is required.', 'wpvivid-backuprestore');
4894
  return $ret;
4895
  }
4896
 
@@ -4898,36 +4918,181 @@ class WPvivid {
4898
 
4899
  if(empty($data['max_file_size']) && $data['max_file_size'] != '0')
4900
  {
4901
- $ret['error']=__('The maximum zip file size is required.', 'wpvivid-backuprestore');
4902
  return $ret;
4903
  }
4904
 
4905
  if(!isset($data['exclude_file_size']))
4906
  {
4907
- $ret['error']=__('The size for excluded files is required.', 'wpvivid-backuprestore');
4908
  }
4909
 
4910
  $data['exclude_file_size']=sanitize_text_field($data['exclude_file_size']);
4911
 
4912
  if(empty($data['exclude_file_size']) && $data['exclude_file_size'] != '0')
4913
  {
4914
- $ret['error']=__('The size for excluded files is required.', 'wpvivid-backuprestore');
4915
  return $ret;
4916
  }
4917
 
4918
  if(!isset($data['max_execution_time']))
4919
  {
4920
- $ret['error']=__('The maximum execution time for PHP script is required.', 'wpvivid-backuprestore');
4921
  }
4922
 
4923
  $data['max_execution_time']=sanitize_text_field($data['max_execution_time']);
4924
 
4925
  if(empty($data['max_execution_time']) && $data['max_execution_time'] != '0')
4926
  {
4927
- $ret['error']=__('The maximum execution time for PHP script is required.', 'wpvivid-backuprestore');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4928
  return $ret;
4929
  }
4930
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4931
  if(!isset($data['path']))
4932
  {
4933
  $ret['error']=__('The local storage path is required.', 'wpvivid-backuprestore');
@@ -5237,7 +5402,7 @@ class WPvivid {
5237
  }
5238
  else{
5239
  $offset=get_option('gmt_offset');
5240
- $localtime = strtotime($value['time']) + $offset * 60 * 60;
5241
  $value['time'] = date('F-d-Y H:i:s',$localtime);
5242
  }
5243
  if (empty($value['des'])) {
364
  add_action('wp_ajax_wpvivid_get_restore_progress',array( $this,'get_restore_progress'));
365
  add_action('wp_ajax_wpvivid_get_download_restore_progress',array( $this,'download_restore_progress'));
366
  //When restoring the database use wp_ajax_nopriv_
 
 
367
  add_action('wp_ajax_nopriv_wpvivid_restore',array( $this,'restore'));
368
  add_action('wp_ajax_nopriv_wpvivid_get_restore_progress',array( $this,'get_restore_progress'));
369
  add_action('wp_ajax_wpvivid_list_tasks',array( $this,'list_tasks'));
1225
  $this->end_shutdown_function=true;
1226
  die();
1227
  }
1228
+
 
 
 
 
 
 
 
1229
  $this->end_shutdown_function=true;
1230
  die();
1231
  }
1384
  $this->update_last_backup_task($task_msg);
1385
  }
1386
  WPvivid_Schedule::clear_monitor_schedule($task['id']);
1387
+
1388
+ $backup_task=new WPvivid_Backup_Task($task['id']);
1389
+ $res=$backup_task->get_backup_result();
1390
+ if(!empty($res['files']))
1391
+ {
1392
+ WPvivid_mail_report::send_report_mail($task);
1393
+ }
1394
  }
1395
 
1396
  function wpvivid_mark_task($task)
3642
  */
3643
  public function restore()
3644
  {
3645
+ check_ajax_referer( 'wpvivid_ajax', 'nonce' );
3646
+
3647
  $this->end_shutdown_function=false;
3648
  register_shutdown_function(array($this,'deal_restore_shutdown_error'));
3649
  if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id']))
3653
  }
3654
 
3655
  $backup_id=sanitize_key($_POST['backup_id']);
3656
+ $backup=WPvivid_Backuplist::get_backup_by_id($backup_id);
3657
+ if($backup===false)
3658
+ {
3659
+ die();
3660
+ }
3661
 
3662
  $this->restore_data=new WPvivid_restore_data();
3663
 
3849
  */
3850
  public function get_restore_progress()
3851
  {
3852
+ try
3853
+ {
3854
+ check_ajax_referer( 'wpvivid_ajax', 'nonce' );
3855
+ if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id']))
3856
+ {
3857
+ $this->end_shutdown_function=true;
3858
+ die();
3859
+ }
3860
+
3861
+ $backup_id=sanitize_key($_POST['backup_id']);
3862
+ $backup=WPvivid_Backuplist::get_backup_by_id($backup_id);
3863
+ if($backup===false)
3864
+ {
3865
+ die();
3866
+ }
3867
+
3868
  $this->restore_data = new WPvivid_restore_data();
3869
 
3870
+ if ($this->restore_data->has_restore())
3871
+ {
3872
  $ret['result'] = 'success';
3873
  $ret['status'] = $this->restore_data->get_restore_status();
3874
  if ($ret['status'] == WPVIVID_RESTORE_ERROR) {
4910
  $ret['result']=WPVIVID_FAILED;
4911
  if(!isset($data['max_file_size']))
4912
  {
4913
+ $ret['error']=__('The value of \'Compress file every\' can\'t be empty.', 'wpvivid-backuprestore');
4914
  return $ret;
4915
  }
4916
 
4918
 
4919
  if(empty($data['max_file_size']) && $data['max_file_size'] != '0')
4920
  {
4921
+ $ret['error']=__('The value of \'Compress file every\' can\'t be empty.', 'wpvivid-backuprestore');
4922
  return $ret;
4923
  }
4924
 
4925
  if(!isset($data['exclude_file_size']))
4926
  {
4927
+ $ret['error']=__('The value of \'Exclude files which are lager than\' can\'t be empty.', 'wpvivid-backuprestore');
4928
  }
4929
 
4930
  $data['exclude_file_size']=sanitize_text_field($data['exclude_file_size']);
4931
 
4932
  if(empty($data['exclude_file_size']) && $data['exclude_file_size'] != '0')
4933
  {
4934
+ $ret['error']=__('The value of \'Exclude files which are lager than\' can\'t be empty.', 'wpvivid-backuprestore');
4935
  return $ret;
4936
  }
4937
 
4938
  if(!isset($data['max_execution_time']))
4939
  {
4940
+ $ret['error']=__('The value of \'PHP scripts execution timeout for backup\' can\'t be empty.', 'wpvivid-backuprestore');
4941
  }
4942
 
4943
  $data['max_execution_time']=sanitize_text_field($data['max_execution_time']);
4944
 
4945
  if(empty($data['max_execution_time']) && $data['max_execution_time'] != '0')
4946
  {
4947
+ $ret['error']=__('The value of \'PHP scripts execution timeout for backup\' can\'t be empty.', 'wpvivid-backuprestore');
4948
+ return $ret;
4949
+ }
4950
+
4951
+ //
4952
+ if(!isset($data['restore_max_execution_time']))
4953
+ {
4954
+ $ret['error']=__('The value of \'PHP scripts execution timeout for restore\' can\'t be empty.', 'wpvivid-backuprestore');
4955
+ }
4956
+ $data['restore_max_execution_time']=sanitize_text_field($data['restore_max_execution_time']);
4957
+ if(empty($data['restore_max_execution_time']) && $data['restore_max_execution_time'] != '0')
4958
+ {
4959
+ $ret['error']=__('The value of \'PHP scripts execution timeout for restore\' can\'t be empty.', 'wpvivid-backuprestore');
4960
+ return $ret;
4961
+ }
4962
+
4963
+ if(!isset($data['memory_limit']))
4964
+ {
4965
+ $ret['error']=__('The value of \'PHP memory limit for backup\' can\'t be empty.', 'wpvivid-backuprestore');
4966
+ }
4967
+ $data['memory_limit']=sanitize_text_field($data['memory_limit']);
4968
+ if(empty($data['memory_limit']) && $data['memory_limit'] != '0')
4969
+ {
4970
+ $ret['error']=__('The value of \'PHP memory limit for backup\' can\'t be empty.', 'wpvivid-backuprestore');
4971
+ return $ret;
4972
+ }
4973
+
4974
+ if(!isset($data['restore_memory_limit']))
4975
+ {
4976
+ $ret['error']=__('The value of \'PHP memory limit for restoration\' can\'t be empty.', 'wpvivid-backuprestore');
4977
+ }
4978
+ $data['restore_memory_limit']=sanitize_text_field($data['restore_memory_limit']);
4979
+ if(empty($data['restore_memory_limit']) && $data['restore_memory_limit'] != '0')
4980
+ {
4981
+ $ret['error']=__('The value of \'PHP memory limit for restoration\' can\'t be empty.', 'wpvivid-backuprestore');
4982
+ return $ret;
4983
+ }
4984
+
4985
+ if(!isset($data['migrate_size']))
4986
+ {
4987
+ $ret['error']=__('The value of \'Chunk Size\' can\'t be empty.', 'wpvivid-backuprestore');
4988
+ }
4989
+ $data['migrate_size']=sanitize_text_field($data['migrate_size']);
4990
+ if(empty($data['migrate_size']) && $data['migrate_size'] != '0')
4991
+ {
4992
+ $ret['error']=__('The value of \'Chunk Size\' can\'t be empty.', 'wpvivid-backuprestore');
4993
+ return $ret;
4994
+ }
4995
+
4996
+ if(!isset($data['wpvivid_uc_scan_limit']))
4997
+ {
4998
+ $ret['error']=__('The value of \'Posts Quantity Processed Per Request\' can\'t be empty.', 'wpvivid-backuprestore');
4999
+ }
5000
+ $data['wpvivid_uc_scan_limit']=sanitize_text_field($data['wpvivid_uc_scan_limit']);
5001
+ if(empty($data['wpvivid_uc_scan_limit']) && $data['wpvivid_uc_scan_limit'] != '0')
5002
+ {
5003
+ $ret['error']=__('The value of \'Posts Quantity Processed Per Request\' can\'t be empty.', 'wpvivid-backuprestore');
5004
  return $ret;
5005
  }
5006
 
5007
+ if(!isset($data['wpvivid_uc_files_limit']))
5008
+ {
5009
+ $ret['error']=__('The value of \'Media Files Quantity Processed Per Request\' can\'t be empty.', 'wpvivid-backuprestore');
5010
+ }
5011
+ $data['wpvivid_uc_files_limit']=sanitize_text_field($data['wpvivid_uc_files_limit']);
5012
+ if(empty($data['wpvivid_uc_files_limit']) && $data['wpvivid_uc_files_limit'] != '0')
5013
+ {
5014
+ $ret['error']=__('The value of \'Media Files Quantity Processed Per Request\' can\'t be empty.', 'wpvivid-backuprestore');
5015
+ return $ret;
5016
+ }
5017
+
5018
+ if(!isset($data['staging_db_insert_count']))
5019
+ {
5020
+ $ret['error']=__('The value of \'DB Copy Count\' can\'t be empty.', 'wpvivid-backuprestore');
5021
+ }
5022
+ $data['staging_db_insert_count']=sanitize_text_field($data['staging_db_insert_count']);
5023
+ if(empty($data['staging_db_insert_count']) && $data['staging_db_insert_count'] != '0')
5024
+ {
5025
+ $ret['error']=__('The value of \'DB Copy Count\' can\'t be empty.', 'wpvivid-backuprestore');
5026
+ return $ret;
5027
+ }
5028
+
5029
+ if(!isset($data['staging_db_replace_count']))
5030
+ {
5031
+ $ret['error']=__('The value of \'DB Replace Count\' can\'t be empty.', 'wpvivid-backuprestore');
5032
+ }
5033
+ $data['staging_db_replace_count']=sanitize_text_field($data['staging_db_replace_count']);
5034
+ if(empty($data['staging_db_replace_count']) && $data['staging_db_replace_count'] != '0')
5035
+ {
5036
+ $ret['error']=__('The value of \'DB Replace Count\' can\'t be empty.', 'wpvivid-backuprestore');
5037
+ return $ret;
5038
+ }
5039
+
5040
+ if(!isset($data['staging_file_copy_count']))
5041
+ {
5042
+ $ret['error']=__('The value of \'File Copy Count\' can\'t be empty.', 'wpvivid-backuprestore');
5043
+ }
5044
+ $data['staging_file_copy_count']=sanitize_text_field($data['staging_file_copy_count']);
5045
+ if(empty($data['staging_file_copy_count']) && $data['staging_file_copy_count'] != '0')
5046
+ {
5047
+ $ret['error']=__('The value of \'File Copy Count\' can\'t be empty.', 'wpvivid-backuprestore');
5048
+ return $ret;
5049
+ }
5050
+
5051
+ if(!isset($data['staging_exclude_file_size']))
5052
+ {
5053
+ $ret['error']=__('The value of \'Max Files Size\' can\'t be empty.', 'wpvivid-backuprestore');
5054
+ }
5055
+ $data['staging_exclude_file_size']=sanitize_text_field($data['staging_exclude_file_size']);
5056
+ if(empty($data['staging_exclude_file_size']) && $data['staging_exclude_file_size'] != '0')
5057
+ {
5058
+ $ret['error']=__('The value of \'Max Files Size\' can\'t be empty.', 'wpvivid-backuprestore');
5059
+ return $ret;
5060
+ }
5061
+
5062
+ if(!isset($data['staging_memory_limit']))
5063
+ {
5064
+ $ret['error']=__('The value of \'Staging Memeory Limit\' can\'t be empty.', 'wpvivid-backuprestore');
5065
+ }
5066
+ $data['staging_memory_limit']=sanitize_text_field($data['staging_memory_limit']);
5067
+ if(empty($data['staging_memory_limit']) && $data['staging_memory_limit'] != '0')
5068
+ {
5069
+ $ret['error']=__('The value of \'Staging Memeory Limit\' can\'t be empty.', 'wpvivid-backuprestore');
5070
+ return $ret;
5071
+ }
5072
+
5073
+ if(!isset($data['staging_max_execution_time']))
5074
+ {
5075
+ $ret['error']=__('The value of \'PHP Scripts Execution Timeout\' can\'t be empty.', 'wpvivid-backuprestore');
5076
+ }
5077
+ $data['staging_max_execution_time']=sanitize_text_field($data['staging_max_execution_time']);
5078
+ if(empty($data['staging_max_execution_time']) && $data['staging_max_execution_time'] != '0')
5079
+ {
5080
+ $ret['error']=__('The value of \'PHP Scripts Execution Timeout\' can\'t be empty.', 'wpvivid-backuprestore');
5081
+ return $ret;
5082
+ }
5083
+
5084
+ if(!isset($data['staging_request_timeout']))
5085
+ {
5086
+ $ret['error']=__('The value of \'Delay Between Requests\' can\'t be empty.', 'wpvivid-backuprestore');
5087
+ }
5088
+ $data['staging_request_timeout']=sanitize_text_field($data['staging_request_timeout']);
5089
+ if(empty($data['staging_request_timeout']) && $data['staging_request_timeout'] != '0')
5090
+ {
5091
+ $ret['error']=__('The value of \'Delay Between Requests\' can\'t be empty.', 'wpvivid-backuprestore');
5092
+ return $ret;
5093
+ }
5094
+ //
5095
+
5096
  if(!isset($data['path']))
5097
  {
5098
  $ret['error']=__('The local storage path is required.', 'wpvivid-backuprestore');
5402
  }
5403
  else{
5404
  $offset=get_option('gmt_offset');
5405
+ $localtime = strtotime($value['time'])/* + $offset * 60 * 60*/;
5406
  $value['time'] = date('F-d-Y H:i:s',$localtime);
5407
  }
5408
  if (empty($value['des'])) {
includes/customclass/class-wpvivid-base-dropbox.php CHANGED
@@ -48,9 +48,9 @@ class Dropbox_Base{
48
  $remote_options['expires_in'] = $result['data']['expires_in'];
49
  $remote_options['created'] = time();
50
  WPvivid_Setting::update_remote_option($this->option['id'],$remote_options);
51
- $this -> access_token = $this->option['access_token'];
52
- $this -> created = $this->option['created'];
53
- $this -> expires_in = $this->option['expires_in'];
54
  $this -> refresh_token = $this->option['refresh_token'];
55
 
56
  $ret['result']='success';
@@ -83,7 +83,7 @@ class Dropbox_Base{
83
  $postdata = $file_data;
84
 
85
  $returnData = $this ->postRequest($endpoint, $headers, $postdata);
86
- if(preg_match( "/Invalid or expired token. Please remove .* from the storage list and re-authenticate it/", $returnData, $matches ))
87
  {
88
  $ret=$this->check_token();
89
  if($ret['result']=='failed')
@@ -107,7 +107,7 @@ class Dropbox_Base{
107
  );
108
 
109
  $returnData = $this ->postRequest($endpoint, $headers,null);
110
- if(preg_match( "/Invalid or expired token. Please remove .* from the storage list and re-authenticate it/", $returnData, $matches ))
111
  {
112
  $ret=$this->check_token();
113
  if($ret['result']=='failed')
@@ -131,7 +131,7 @@ class Dropbox_Base{
131
  );
132
 
133
  $returnData = $this ->postRequest($endpoint, $headers, $postdata);
134
- if(preg_match( "/Invalid or expired token. Please remove .* from the storage list and re-authenticate it/", $returnData, $matches ))
135
  {
136
  $ret=$this->check_token();
137
  if($ret['result']=='failed')
48
  $remote_options['expires_in'] = $result['data']['expires_in'];
49
  $remote_options['created'] = time();
50
  WPvivid_Setting::update_remote_option($this->option['id'],$remote_options);
51
+ $this -> access_token = $remote_options['access_token'];
52
+ $this -> created = $remote_options['created'];
53
+ $this -> expires_in = $remote_options['expires_in'];
54
  $this -> refresh_token = $this->option['refresh_token'];
55
 
56
  $ret['result']='success';
83
  $postdata = $file_data;
84
 
85
  $returnData = $this ->postRequest($endpoint, $headers, $postdata);
86
+ if(isset($returnData['error_summary']) && preg_match( "/Invalid or expired token. Please remove .* from the storage list and re-authenticate it/", $returnData['error_summary'], $matches ))
87
  {
88
  $ret=$this->check_token();
89
  if($ret['result']=='failed')
107
  );
108
 
109
  $returnData = $this ->postRequest($endpoint, $headers,null);
110
+ if(isset($returnData['error_summary']) && preg_match( "/Invalid or expired token. Please remove .* from the storage list and re-authenticate it/", $returnData['error_summary'], $matches ))
111
  {
112
  $ret=$this->check_token();
113
  if($ret['result']=='failed')
131
  );
132
 
133
  $returnData = $this ->postRequest($endpoint, $headers, $postdata);
134
+ if(isset($returnData['error_summary']) && preg_match( "/Invalid or expired token. Please remove .* from the storage list and re-authenticate it/", $returnData['error_summary'], $matches ))
135
  {
136
  $ret=$this->check_token();
137
  if($ret['result']=='failed')
includes/customclass/class-wpvivid-dropbox.php CHANGED
@@ -17,6 +17,7 @@ class WPvivid_Dropbox extends WPvivid_Remote
17
  private $upload_chunk_size = 2097152;
18
  private $download_chunk_size = 2097152;
19
  private $redirect_url = 'https://auth.wpvivid.com/dropbox_v3/';
 
20
  public function __construct($options = array())
21
  {
22
  if(empty($options))
@@ -24,6 +25,9 @@ class WPvivid_Dropbox extends WPvivid_Remote
24
  if(!defined('WPVIVID_INIT_STORAGE_TAB_DROPBOX'))
25
  {
26
  add_action('init', array($this, 'handle_auth_actions'));
 
 
 
27
  add_action('wpvivid_delete_remote_token',array($this,'revoke'));
28
 
29
  add_filter('wpvivid_remote_register', array($this, 'init_remotes'),10);
@@ -40,6 +44,7 @@ class WPvivid_Dropbox extends WPvivid_Remote
40
  }else{
41
  $this -> options = $options;
42
  }
 
43
  }
44
 
45
  public function pre_add_remote($remote,$id)
@@ -334,26 +339,10 @@ class WPvivid_Dropbox extends WPvivid_Remote
334
  if($_GET['action'] === 'wpvivid_dropbox_auth')
335
  {
336
  try {
337
- if (!isset($_GET['name']) || empty($_GET['name']))
338
- {
339
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore').'</p></div>';
340
- return;
341
- }
342
-
343
- $alias_name = sanitize_text_field($_GET['name']);
344
-
345
- $remoteslist = WPvivid_Setting::get_all_remote_options();
346
- foreach ($remoteslist as $key => $value)
347
- {
348
- if (isset($value['name']) && $value['name'] == $alias_name)
349
- {
350
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
351
- return;
352
- }
353
- }
354
- $default = sanitize_text_field($_GET['bdefault']);
355
  $auth_id = uniqid('wpvivid-auth-');
356
- $state = admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_dropbox_finish_auth&name=' . $alias_name . '&bdefault=' . $default.'&auth_id='.$auth_id;
 
 
357
  $url = Dropbox_Base::getUrl($this->redirect_url, $state);
358
  header('Location: ' . filter_var($url, FILTER_SANITIZE_URL));
359
  }
@@ -365,108 +354,44 @@ class WPvivid_Dropbox extends WPvivid_Remote
365
  {
366
  try {
367
  $remoteslist = WPvivid_Setting::get_all_remote_options();
368
- foreach ($remoteslist as $key => $value) {
369
- if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id'])) {
 
 
370
  _e('<div class="notice notice-success is-dismissible"><p>You have authenticated the Dropbox account as your remote storage.</p></div>');
371
  return;
372
  }
373
  }
374
- if (!isset($_POST['code'])) {
375
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_dropbox_drive&result=error&resp_msg=' . 'Get Dropbox token failed.');
376
- } else {
377
- global $wpvivid_plugin;
378
- $remote_options['type'] = WPVIVID_REMOTE_DROPBOX;
379
- $remote_options['access_token']= sanitize_text_field($_POST['code']);
380
- $remote_options['expires_in'] = sanitize_text_field($_POST['expires_in']);
381
- $remote_options['refresh_token'] = sanitize_text_field($_POST['refresh_token']);
382
- $remote_options['created']=time();
383
- $remote_options['name'] = sanitize_text_field($_GET['name']);
384
- $remote_options['path'] = WPVIVID_DROPBOX_DEFAULT_FOLDER;
385
- $remote_options['default'] = sanitize_text_field($_GET['bdefault']);
386
- $remote_options['auth_id'] = sanitize_text_field($_GET['auth_id']);
387
- $ret = $wpvivid_plugin->remote_collection->add_remote($remote_options);
388
- if ($ret['result'] == 'success') {
389
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_dropbox_drive&result=success');
390
- return;
391
- } else {
392
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_dropbox_drive&result=error&resp_msg=' . $ret['error']);
393
- return;
394
- }
395
- }
396
- }
397
- catch (Exception $e){
398
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
399
- }
400
- }
401
- else if($_GET['action']=='wpvivid_dropbox_drive')
402
- {
403
- try {
404
- if (isset($_GET['result'])) {
405
- if ($_GET['result'] == 'success') {
406
- add_action('show_notice', array($this, 'wpvivid_show_notice_add_dropbox_success'));
407
- } else if ($_GET['result'] == 'error') {
408
- add_action('show_notice', array($this, 'wpvivid_show_notice_add_dropbox_error'));
409
- }
410
- }
411
- }
412
- catch (Exception $e){
413
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
414
- }
415
- }
416
- else if($_GET['action'] === 'wpvivid_dropbox_update_auth')
417
- {
418
- try {
419
- if (!isset($_GET['name']) || empty($_GET['name'])) {
420
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore').'</p></div>';
421
- return;
422
- }
423
 
424
- $alias_name = sanitize_text_field($_GET['name']);
425
- $id = sanitize_text_field($_GET['id']);
426
- $auth_id = uniqid('wpvivid-auth-');
427
- $remoteslist = WPvivid_Setting::get_all_remote_options();
428
- foreach ($remoteslist as $key => $value) {
429
- if (isset($value['name']) && $value['name'] == $alias_name && $key != $id) {
430
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
431
- return;
432
- }
433
  }
434
- $state = admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_dropbox_finish_update_auth&name=' . $alias_name . '&id=' . $id.'&auth_id='.$auth_id;
435
- $url = Dropbox_Base::getUrl($this->redirect_url, $state);
436
- header('Location: ' . filter_var($url, FILTER_SANITIZE_URL));
437
- }
438
- catch (Exception $e){
439
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
440
- }
441
- }
442
- else if($_GET['action'] === 'wpvivid_dropbox_finish_update_auth')
443
- {
444
- try {
445
- $remoteslist = WPvivid_Setting::get_all_remote_options();
446
- foreach ($remoteslist as $key => $value) {
447
- if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id'])) {
448
- _e('<div class="notice notice-success is-dismissible"><p>You have successfully updated the storage alias.</p></div>');
449
- return;
 
 
 
 
 
450
  }
451
- }
452
- if (!isset($_POST['code'])) {
453
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_dropbox_drive_update&result=error&resp_msg=' . 'Get Dropbox token failed.');
454
- } else {
455
- global $wpvivid_plugin;
456
- $remote_options['type'] = WPVIVID_REMOTE_DROPBOX;
457
- $remote_options['access_token']= sanitize_text_field($_POST['code']);
458
- $remote_options['expires_in'] = sanitize_text_field($_POST['expires_in']);
459
- $remote_options['refresh_token'] = sanitize_text_field($_POST['refresh_token']);
460
- $remote_options['created']=time();
461
- $remote_options['name'] = sanitize_text_field($_GET['name']);
462
- $remote_options['path'] = WPVIVID_DROPBOX_DEFAULT_FOLDER;
463
- $remote_options['auth_id'] = sanitize_text_field($_GET['auth_id']);
464
- $ret = $wpvivid_plugin->remote_collection->update_remote($remote_options['auth_id'], $remote_options);
465
- if ($ret['result'] == 'success') {
466
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_dropbox_drive_update&result=success');
467
- return;
468
- } else {
469
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_dropbox_drive_update&result=error&resp_msg=' . $ret['error']);
470
  return;
471
  }
472
  }
@@ -475,14 +400,14 @@ class WPvivid_Dropbox extends WPvivid_Remote
475
  echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
476
  }
477
  }
478
- else if($_GET['action']=='wpvivid_dropbox_drive_update')
479
  {
480
  try {
481
  if (isset($_GET['result'])) {
482
  if ($_GET['result'] == 'success') {
483
- add_action('show_notice', array($this, 'wpvivid_show_notice_edit_dropbox_success'));
484
  } else if ($_GET['result'] == 'error') {
485
- add_action('show_notice', array($this, 'wpvivid_show_notice_edit_dropbox_error'));
486
  }
487
  }
488
  }
@@ -501,14 +426,6 @@ class WPvivid_Dropbox extends WPvivid_Remote
501
  $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Add Dropbox Remote');
502
  echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
503
  }
504
- public function wpvivid_show_notice_edit_dropbox_success(){
505
- echo '<div class="notice notice-success is-dismissible"><p>'.__('You have successfully updated the storage alias.', 'wpvivid-backuprestore').'</p></div>';
506
- }
507
- public function wpvivid_show_notice_edit_dropbox_error(){
508
- global $wpvivid_plugin;
509
- $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Update Dropbox Remote');
510
- echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
511
- }
512
 
513
  public function wpvivid_add_storage_tab_dropbox(){
514
  ?>
@@ -520,130 +437,222 @@ class WPvivid_Dropbox extends WPvivid_Remote
520
  public function wpvivid_add_storage_page_dropbox(){
521
  global $wpvivid_plugin;
522
  $root_path=apply_filters('wpvivid_get_root_path', WPVIVID_REMOTE_DROPBOX);
523
- ?>
524
- <div id="storage_account_dropbox" class="storage-account-page" style="display:none;">
525
- <div style="background-color:#f1f1f1; padding: 10px;">
526
- <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Dropbox authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
527
- </div>
528
- <div style="padding: 10px 10px 10px 0;">
529
- <strong><?php _e('Enter Your Dropbox Information', 'wpvivid-backuprestore'); ?></strong>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
  </div>
531
- <table class="wp-list-table widefat plugins" style="width:100%;">
532
- <tbody>
533
- <tr>
534
- <td class="plugin-title column-primary">
535
- <div class="wpvivid-storage-form">
536
- <input type="text" class="regular-text" autocomplete="off" option="dropbox" name="name" placeholder="<?php esc_attr_e('Enter a unique alias: e.g. Dropbox-001', 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
537
- </div>
538
- </td>
539
- <td class="column-description desc">
540
- <div class="wpvivid-storage-form-desc">
541
- <i><?php _e('A name to help you identify the storage if you have multiple remote storage connected.', 'wpvivid-backuprestore'); ?></i>
542
- </div>
543
- </td>
544
- </tr>
545
- <tr>
546
- <td class="plugin-title column-primary">
547
- <div class="wpvivid-storage-form">
548
- <input type="text" class="regular-text" autocomplete="off" option="dropbox" name="path" value="<?php esc_attr_e($root_path.WPVIVID_DROPBOX_DEFAULT_FOLDER); ?>" readonly="readonly" />
549
- </div>
550
- </td>
551
- <td class="column-description desc">
552
- <div class="wpvivid-storage-form-desc">
553
- <i><?php _e('All backups will be uploaded to this directory.', 'wpvivid-backuprestore'); ?></i>
554
- </div>
555
- </td>
556
- </tr>
557
- <tr>
558
- <td class="plugin-title column-primary">
559
- <div class="wpvivid-storage-form">
560
- <input type="text" class="regular-text" autocomplete="off" value="mywebsite01" readonly="readonly" />
561
- </div>
562
- </td>
563
- <td class="column-description desc">
564
- <div class="wpvivid-storage-form-desc">
565
- <a href="https://docs.wpvivid.com/wpvivid-backup-pro-dropbox-custom-folder-name.html"><?php _e('Pro feature: Create a directory for storing the backups of the site', 'wpvivid-backuprestore'); ?></a>
566
- </div>
567
- </td>
568
- </tr>
569
- <tr>
570
- <td class="plugin-title column-primary">
571
- <div class="wpvivid-storage-select">
572
- <label>
573
- <input type="checkbox" option="dropbox" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid-backuprestore'); ?>
574
- </label>
575
- </div>
576
- </td>
577
- <td class="column-description desc">
578
- <div class="wpvivid-storage-form-desc">
579
- <i><?php _e('Once checked, all this sites backups sent to a remote storage destination will be uploaded to this storage by default.', 'wpvivid-backuprestore'); ?></i>
580
- </div>
581
- </td>
582
- </tr>
583
- <tr>
584
- <td class="plugin-title column-primary">
585
- <div class="wpvivid-storage-form">
586
- <input onclick="wpvivid_dropbox_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Authenticate with Dropbox', 'wpvivid-backuprestore'); ?>">
587
- </div>
588
- </td>
589
- <td class="column-description desc">
590
- <div class="wpvivid-storage-form-desc">
591
- <i><?php _e('Click the button to get Dropbox authentication and add it to the storage list below.', 'wpvivid-backuprestore'); ?></i>
592
- </div>
593
- </td>
594
- </tr>
595
- </tbody>
596
- </table>
597
- </div>
598
- <script>
599
- function wpvivid_check_dropbox_storage_alias(storage_alias){
600
- var find = 1;
601
- jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
602
- jQuery(this).children('td').each(function (j) {
603
- if (j == 3) {
604
- if (jQuery(this).text() == storage_alias) {
605
- find = -1;
606
- return false;
607
  }
608
- }
609
  });
 
 
 
 
 
 
610
  });
611
- return find;
612
- }
613
- function wpvivid_dropbox_auth()
614
- {
615
- wpvivid_settings_changed = false;
616
- var name='';
617
- var path = '';
618
- var bdefault = '0';
619
- jQuery("input:checkbox[option=dropbox]").each(function(){
620
- var key = jQuery(this).prop('name');
621
- if(jQuery(this).prop('checked')) {
622
- bdefault = '1';
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  }
624
- else {
625
- bdefault = '0';
626
  }
627
- });
628
- jQuery('input:text[option=dropbox]').each(function()
629
- {
630
- var type = jQuery(this).prop('name');
631
- if(type == 'name'){
632
- name = jQuery(this).val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
633
  }
634
- });
635
- if(name == ''){
636
- alert(wpvividlion.remotealias);
637
- }
638
- else if(wpvivid_check_dropbox_storage_alias(name) === -1){
639
- alert(wpvividlion.remoteexist);
640
  }
641
- else{
642
- location.href ='<?php echo admin_url().'admin.php?page=WPvivid'.'&action=wpvivid_dropbox_auth&name='?>'+name+'<?php echo '&bdefault='?>'+bdefault;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  }
644
- }
645
- </script>
646
- <?php
647
  }
648
  public function wpvivid_edit_storage_page_dropbox()
649
  {
@@ -651,7 +660,7 @@ class WPvivid_Dropbox extends WPvivid_Remote
651
  ?>
652
  <div id="remote_storage_edit_dropbox" class="postbox storage-account-block remote-storage-edit" style="display:none;">
653
  <div style="padding: 0 10px 10px 0;">
654
- <strong><?php _e('Enter Your Dropbox Information', 'wpvivid-backuprestore'); ?></strong>
655
  </div>
656
  <table class="wp-list-table widefat plugins" style="width:100%;">
657
  <tbody>
@@ -670,7 +679,7 @@ class WPvivid_Dropbox extends WPvivid_Remote
670
  <tr>
671
  <td class="plugin-title column-primary">
672
  <div class="wpvivid-storage-form">
673
- <input onclick="wpvivid_dropbox_update_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Save Changes', 'wpvivid-backuprestore'); ?>">
674
  </div>
675
  </td>
676
  <td class="column-description desc">
@@ -746,4 +755,73 @@ class WPvivid_Dropbox extends WPvivid_Remote
746
  }
747
  return $storage_type;
748
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749
  }
17
  private $upload_chunk_size = 2097152;
18
  private $download_chunk_size = 2097152;
19
  private $redirect_url = 'https://auth.wpvivid.com/dropbox_v3/';
20
+ public $add_remote;
21
  public function __construct($options = array())
22
  {
23
  if(empty($options))
25
  if(!defined('WPVIVID_INIT_STORAGE_TAB_DROPBOX'))
26
  {
27
  add_action('init', array($this, 'handle_auth_actions'));
28
+ //wpvivid_dropbox_add_remote
29
+ add_action('wp_ajax_wpvivid_dropbox_add_remote',array( $this,'finish_add_remote'));
30
+
31
  add_action('wpvivid_delete_remote_token',array($this,'revoke'));
32
 
33
  add_filter('wpvivid_remote_register', array($this, 'init_remotes'),10);
44
  }else{
45
  $this -> options = $options;
46
  }
47
+ $this->add_remote=false;
48
  }
49
 
50
  public function pre_add_remote($remote,$id)
339
  if($_GET['action'] === 'wpvivid_dropbox_auth')
340
  {
341
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  $auth_id = uniqid('wpvivid-auth-');
343
+ $state = admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_dropbox_finish_auth&main_tab=storage&sub_tab=dropbox&sub_page=storage_account_dropbox&auth_id='.$auth_id;
344
+ $remote_options['auth_id']=$auth_id;
345
+ update_option('wpvivid_tmp_remote_options',$remote_options);
346
  $url = Dropbox_Base::getUrl($this->redirect_url, $state);
347
  header('Location: ' . filter_var($url, FILTER_SANITIZE_URL));
348
  }
354
  {
355
  try {
356
  $remoteslist = WPvivid_Setting::get_all_remote_options();
357
+ foreach ($remoteslist as $key => $value)
358
+ {
359
+ if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id']))
360
+ {
361
  _e('<div class="notice notice-success is-dismissible"><p>You have authenticated the Dropbox account as your remote storage.</p></div>');
362
  return;
363
  }
364
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
 
366
+ $tmp_options=get_option('wpvivid_tmp_remote_options',false);
367
+ if($tmp_options===false)
368
+ {
369
+ return;
 
 
 
 
 
370
  }
371
+ else
372
+ {
373
+ if($tmp_options['auth_id']===sanitize_text_field($_GET['auth_id']))
374
+ {
375
+ if(empty($_POST['code']))
376
+ {
377
+ if(empty($tmp_options['access_token']))
378
+ {
379
+ header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_dropbox_drive&result=error&resp_msg=' . 'Get Dropbox token failed.');
380
+ return;
381
+ }
382
+ }
383
+ else
384
+ {
385
+ $tmp_options['type'] = WPVIVID_REMOTE_DROPBOX;
386
+ $tmp_options['access_token']= sanitize_text_field($_POST['code']);
387
+ $tmp_options['expires_in'] = sanitize_text_field($_POST['expires_in']);
388
+ $tmp_options['refresh_token'] = sanitize_text_field($_POST['refresh_token']);
389
+ update_option('wpvivid_tmp_remote_options',$tmp_options);
390
+ }
391
+ $this->add_remote=true;
392
  }
393
+ else
394
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  return;
396
  }
397
  }
400
  echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
401
  }
402
  }
403
+ else if($_GET['action']=='wpvivid_dropbox_drive')
404
  {
405
  try {
406
  if (isset($_GET['result'])) {
407
  if ($_GET['result'] == 'success') {
408
+ add_action('show_notice', array($this, 'wpvivid_show_notice_add_dropbox_success'));
409
  } else if ($_GET['result'] == 'error') {
410
+ add_action('show_notice', array($this, 'wpvivid_show_notice_add_dropbox_error'));
411
  }
412
  }
413
  }
426
  $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Add Dropbox Remote');
427
  echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
428
  }
 
 
 
 
 
 
 
 
429
 
430
  public function wpvivid_add_storage_tab_dropbox(){
431
  ?>
437
  public function wpvivid_add_storage_page_dropbox(){
438
  global $wpvivid_plugin;
439
  $root_path=apply_filters('wpvivid_get_root_path', WPVIVID_REMOTE_DROPBOX);
440
+
441
+ $remote = get_option('wpvivid_upload_setting');
442
+ if($this->add_remote)
443
+ {
444
+ ?>
445
+ <div id="storage_account_dropbox" class="storage-account-page" style="display:none;">
446
+ <div style="background-color:#f1f1f1; padding: 10px;">
447
+ <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Dropbox authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
448
+ </div>
449
+ <div style="color:#8bc34a; padding: 10px 10px 10px 0;">
450
+ <strong>Authentication is done, please continue to enter the storge information, then click 'Add Now' button to save it.</strong>
451
+ </div>
452
+ <div style="padding: 10px 10px 10px 0;">
453
+ <strong><?php _e('Enter Your Dropbox Information', 'wpvivid-backuprestore'); ?></strong>
454
+ </div>
455
+ <table class="wp-list-table widefat plugins" style="width:100%;">
456
+ <tbody>
457
+ <tr>
458
+ <td class="plugin-title column-primary">
459
+ <div class="wpvivid-storage-form">
460
+ <input type="text" class="regular-text" autocomplete="off" option="dropbox" name="name" placeholder="<?php esc_attr_e('Enter a unique alias: e.g. Dropbox-001', 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
461
+ </div>
462
+ </td>
463
+ <td class="column-description desc">
464
+ <div class="wpvivid-storage-form-desc">
465
+ <i><?php _e('A name to help you identify the storage if you have multiple remote storage connected.', 'wpvivid-backuprestore'); ?></i>
466
+ </div>
467
+ </td>
468
+ </tr>
469
+ <tr>
470
+ <td class="plugin-title column-primary">
471
+ <div class="wpvivid-storage-form">
472
+ <input type="text" class="regular-text" autocomplete="off" option="dropbox" name="path" value="<?php esc_attr_e($root_path.WPVIVID_DROPBOX_DEFAULT_FOLDER); ?>" readonly="readonly" />
473
+ </div>
474
+ </td>
475
+ <td class="column-description desc">
476
+ <div class="wpvivid-storage-form-desc">
477
+ <i><?php _e('All backups will be uploaded to this directory.', 'wpvivid-backuprestore'); ?></i>
478
+ </div>
479
+ </td>
480
+ </tr>
481
+ <tr>
482
+ <td class="plugin-title column-primary">
483
+ <div class="wpvivid-storage-form">
484
+ <input type="text" class="regular-text" autocomplete="off" value="mywebsite01" readonly="readonly" />
485
+ </div>
486
+ </td>
487
+ <td class="column-description desc">
488
+ <div class="wpvivid-storage-form-desc">
489
+ <a href="https://docs.wpvivid.com/wpvivid-backup-pro-dropbox-custom-folder-name.html"><?php _e('Pro feature: Create a directory for storing the backups of the site', 'wpvivid-backuprestore'); ?></a>
490
+ </div>
491
+ </td>
492
+ </tr>
493
+ <tr>
494
+ <td class="plugin-title column-primary">
495
+ <div class="wpvivid-storage-select">
496
+ <label>
497
+ <input type="checkbox" option="dropbox" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid-backuprestore'); ?>
498
+ </label>
499
+ </div>
500
+ </td>
501
+ <td class="column-description desc">
502
+ <div class="wpvivid-storage-form-desc">
503
+ <i><?php _e('Once checked, all this sites backups sent to a remote storage destination will be uploaded to this storage by default.', 'wpvivid-backuprestore'); ?></i>
504
+ </div>
505
+ </td>
506
+ </tr>
507
+ <tr>
508
+ <td class="plugin-title column-primary">
509
+ <div class="wpvivid-storage-form">
510
+ <input id="wpvivid_dropbox_auth" class="button-primary" type="submit" value="<?php esc_attr_e('Add Now', 'wpvivid-backuprestore'); ?>">
511
+ </div>
512
+ </td>
513
+ <td class="column-description desc">
514
+ <div class="wpvivid-storage-form-desc">
515
+ <i><?php _e('Click the button to add the storage.', 'wpvivid-backuprestore'); ?></i>
516
+ </div>
517
+ </td>
518
+ </tr>
519
+ </tbody>
520
+ </table>
521
  </div>
522
+ <script>
523
+ function wpvivid_check_dropbox_storage_alias(storage_alias)
524
+ {
525
+ var find = 1;
526
+ jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
527
+ jQuery(this).children('td').each(function (j) {
528
+ if (j == 3) {
529
+ if (jQuery(this).text() == storage_alias) {
530
+ find = -1;
531
+ return false;
532
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
533
  }
534
+ });
535
  });
536
+ return find;
537
+ }
538
+
539
+ jQuery('#wpvivid_dropbox_auth').click(function()
540
+ {
541
+ wpvivid_dropbox_auth();
542
  });
543
+
544
+ function wpvivid_dropbox_auth()
545
+ {
546
+ wpvivid_settings_changed = false;
547
+ var name='';
548
+ var path = '';
549
+ var bdefault = '0';
550
+ jQuery("input:checkbox[option=dropbox]").each(function(){
551
+ var key = jQuery(this).prop('name');
552
+ if(jQuery(this).prop('checked')) {
553
+ bdefault = '1';
554
+ }
555
+ else {
556
+ bdefault = '0';
557
+ }
558
+ });
559
+ jQuery('input:text[option=dropbox]').each(function()
560
+ {
561
+ var type = jQuery(this).prop('name');
562
+ if(type == 'name'){
563
+ name = jQuery(this).val();
564
+ }
565
+ });
566
+ if(name == ''){
567
+ alert(wpvividlion.remotealias);
568
  }
569
+ else if(wpvivid_check_dropbox_storage_alias(name) === -1){
570
+ alert(wpvividlion.remoteexist);
571
  }
572
+ else{
573
+ var ajax_data;
574
+ var remote_from = wpvivid_ajax_data_transfer('dropbox');
575
+ ajax_data = {
576
+ 'action': 'wpvivid_dropbox_add_remote',
577
+ 'remote': remote_from
578
+ };
579
+ jQuery('#wpvivid_dropbox_auth').css({'pointer-events': 'none', 'opacity': '0.4'});
580
+ jQuery('#wpvivid_remote_notice').html('');
581
+ wpvivid_post_request(ajax_data, function (data)
582
+ {
583
+ try
584
+ {
585
+ var jsonarray = jQuery.parseJSON(data);
586
+ if (jsonarray.result === 'success')
587
+ {
588
+ jQuery('#wpvivid_dropbox_auth').css({'pointer-events': 'auto', 'opacity': '1'});
589
+ jQuery('input:text[option=dropbox]').each(function(){
590
+ jQuery(this).val('');
591
+ });
592
+ jQuery('input:password[option=dropbox]').each(function(){
593
+ jQuery(this).val('');
594
+ });
595
+ wpvivid_handle_remote_storage_data(data);
596
+ location.href='admin.php?page=WPvivid&action=wpvivid_dropbox_drive&main_tab=storage&sub_tab=dropbox&sub_page=storage_account_dropbox&result=success';
597
+ }
598
+ else if (jsonarray.result === 'failed')
599
+ {
600
+ jQuery('#wpvivid_remote_notice').html(jsonarray.notice);
601
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
602
+ }
603
+ }
604
+ catch (err)
605
+ {
606
+ alert(err);
607
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
608
+ }
609
+
610
+ }, function (XMLHttpRequest, textStatus, errorThrown)
611
+ {
612
+ var error_message = wpvivid_output_ajaxerror('adding the remote storage', textStatus, errorThrown);
613
+ alert(error_message);
614
+ jQuery('#wpvivid_dropbox_auth').css({'pointer-events': 'auto', 'opacity': '1'});
615
+ });
616
  }
 
 
 
 
 
 
617
  }
618
+ </script>
619
+ <?php
620
+ }
621
+ else
622
+ {
623
+ ?>
624
+ <div id="storage_account_dropbox" class="storage-account-page" style="display:none;">
625
+ <div style="background-color:#f1f1f1; padding: 10px;">
626
+ <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Dropbox authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
627
+ </div>
628
+ <div style="padding: 10px 10px 10px 0;">
629
+ <strong><?php _e('Enter Your Dropbox Information', 'wpvivid-backuprestore'); ?></strong>
630
+ </div>
631
+ <table class="wp-list-table widefat plugins" style="width:100%;">
632
+ <tbody>
633
+ <tr>
634
+ <td class="plugin-title column-primary">
635
+ <div class="wpvivid-storage-form">
636
+ <input onclick="wpvivid_dropbox_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Authenticate with Dropbox', 'wpvivid-backuprestore'); ?>">
637
+ </div>
638
+ </td>
639
+ <td class="column-description desc">
640
+ <div class="wpvivid-storage-form-desc">
641
+ <i><?php _e('Click to get Dropbox authentication.', 'wpvivid-backuprestore'); ?></i>
642
+ </div>
643
+ </td>
644
+ </tr>
645
+ </tbody>
646
+ </table>
647
+ </div>
648
+ <script>
649
+ function wpvivid_dropbox_auth()
650
+ {
651
+ location.href ='<?php echo admin_url().'admin.php?page=WPvivid'.'&action=wpvivid_dropbox_auth'?>';
652
  }
653
+ </script>
654
+ <?php
655
+ }
656
  }
657
  public function wpvivid_edit_storage_page_dropbox()
658
  {
660
  ?>
661
  <div id="remote_storage_edit_dropbox" class="postbox storage-account-block remote-storage-edit" style="display:none;">
662
  <div style="padding: 0 10px 10px 0;">
663
+ <strong><?php _e('To add Dropbox, please get Dropbox authentication first. Once authenticated, you will be redirected to this page, then you can add storage information and save it', 'wpvivid-backuprestore'); ?></strong>
664
  </div>
665
  <table class="wp-list-table widefat plugins" style="width:100%;">
666
  <tbody>
679
  <tr>
680
  <td class="plugin-title column-primary">
681
  <div class="wpvivid-storage-form">
682
+ <input class="button-primary" type="submit" option="edit-remote" value="<?php esc_attr_e('Save Changes', 'wpvivid-backuprestore'); ?>">
683
  </div>
684
  </td>
685
  <td class="column-description desc">
755
  }
756
  return $storage_type;
757
  }
758
+
759
+ public function finish_add_remote()
760
+ {
761
+ global $wpvivid_plugin;
762
+ $wpvivid_plugin->ajax_check_security();
763
+ try {
764
+ if (empty($_POST) || !isset($_POST['remote']) || !is_string($_POST['remote'])) {
765
+ die();
766
+ }
767
+
768
+ $tmp_remote_options =get_option('wpvivid_tmp_remote_options',array());
769
+ delete_option('wpvivid_tmp_remote_options');
770
+ if(empty($tmp_remote_options)||$tmp_remote_options['type']!==WPVIVID_REMOTE_DROPBOX)
771
+ {
772
+ die();
773
+ }
774
+
775
+ $json = $_POST['remote'];
776
+ $json = stripslashes($json);
777
+ $remote_options = json_decode($json, true);
778
+ if (is_null($remote_options)) {
779
+ die();
780
+ }
781
+
782
+ $remote_options['created']=time();
783
+ $remote_options['path'] = WPVIVID_DROPBOX_DEFAULT_FOLDER;
784
+ $remote_options=array_merge($remote_options,$tmp_remote_options);
785
+
786
+ $ret = $wpvivid_plugin->remote_collection->add_remote($remote_options);
787
+
788
+ if ($ret['result'] == 'success') {
789
+ $html = '';
790
+ $html = apply_filters('wpvivid_add_remote_storage_list', $html);
791
+ $ret['html'] = $html;
792
+ $pic = '';
793
+ $pic = apply_filters('wpvivid_schedule_add_remote_pic', $pic);
794
+ $ret['pic'] = $pic;
795
+ $dir = '';
796
+ $dir = apply_filters('wpvivid_get_remote_directory', $dir);
797
+ $ret['dir'] = $dir;
798
+ $schedule_local_remote = '';
799
+ $schedule_local_remote = apply_filters('wpvivid_schedule_local_remote', $schedule_local_remote);
800
+ $ret['local_remote'] = $schedule_local_remote;
801
+ $remote_storage = '';
802
+ $remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
803
+ $ret['remote_storage'] = $remote_storage;
804
+ $remote_select_part = '';
805
+ $remote_select_part = apply_filters('wpvivid_remote_storage_select_part', $remote_select_part);
806
+ $ret['remote_select_part'] = $remote_select_part;
807
+ $default = array();
808
+ $remote_array = apply_filters('wpvivid_archieve_remote_array', $default);
809
+ $ret['remote_array'] = $remote_array;
810
+ $success_msg = __('You have successfully added a remote storage.', 'wpvivid-backuprestore');
811
+ $ret['notice'] = apply_filters('wpvivid_add_remote_notice', true, $success_msg);
812
+ }
813
+ else{
814
+ $ret['notice'] = apply_filters('wpvivid_add_remote_notice', false, $ret['error']);
815
+ }
816
+
817
+ }
818
+ catch (Exception $error) {
819
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
820
+ error_log($message);
821
+ echo json_encode(array('result'=>'failed','error'=>$message));
822
+ die();
823
+ }
824
+ echo json_encode($ret);
825
+ die();
826
+ }
827
  }
includes/customclass/class-wpvivid-google-drive.php CHANGED
@@ -22,6 +22,8 @@ class Wpvivid_Google_drive extends WPvivid_Remote
22
 
23
  public $google_drive_secrets;
24
 
 
 
25
  public function __construct($options=array())
26
  {
27
  if(empty($options))
@@ -29,6 +31,8 @@ class Wpvivid_Google_drive extends WPvivid_Remote
29
  if(!defined('WPVIVID_INIT_STORAGE_TAB_GOOGLE_DRIVE'))
30
  {
31
  add_action('init', array($this, 'handle_auth_actions'));
 
 
32
 
33
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_google_drive'), 10);
34
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_google_drive'), 10);
@@ -46,6 +50,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
46
  {
47
  $this->options=$options;
48
  }
 
49
  $this->google_drive_secrets = array("web"=>array(
50
  "client_id"=>"134809148507-32crusepgace4h6g47ota99jjrvf4j1u.apps.googleusercontent.com",
51
  "project_id"=>"wpvivid-auth",
@@ -69,237 +74,123 @@ class Wpvivid_Google_drive extends WPvivid_Remote
69
 
70
  public function handle_auth_actions()
71
  {
72
- if (isset($_GET['action']) && isset($_GET['page']))
73
  {
74
- if($_GET['page'] === 'WPvivid')
75
  {
76
- if($_GET['action']=='wpvivid_google_drive_auth')
77
- {
78
- if(!isset($_GET['name'])||empty($_GET['name']))
79
- {
80
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore').'</p></div>';
81
- return;
82
- }
83
-
84
- $alias_name=sanitize_text_field($_GET['name']);
85
- $auth_id = uniqid('wpvivid-auth-');
86
- $default = sanitize_text_field($_GET['default']);
87
-
88
- $remoteslist=WPvivid_Setting::get_all_remote_options();
89
- foreach ($remoteslist as $key=>$value)
90
- {
91
- if(isset($value['name'])&&$value['name'] == $alias_name)
92
- {
93
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
94
- return;
95
- }
96
- }
97
- $res = $this -> compare_php_version();
98
- if($res['result'] == WPVIVID_FAILED){
99
- echo '<div class="notice notice-warning is-dismissible"><p>'.$res['error'].'</p></div>';
100
- return ;
101
- }
102
- try {
103
- include_once WPVIVID_PLUGIN_DIR . '/vendor/autoload.php';
104
- $client = new Google_Client();
105
- $client->setAuthConfig($this->google_drive_secrets);
106
- $client->setApprovalPrompt('force');
107
- $client->addScope(Google_Service_Drive::DRIVE_FILE);
108
- $client->setAccessType('offline');
109
- $client->setState(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_google_drive_finish_auth&name=' . $alias_name . '&default=' . $default.'&auth_id='.$auth_id);
110
- $auth_url = $client->createAuthUrl();
111
- header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
112
- }
113
- catch (Exception $e){
114
- if($e->getMessage() === 'file does not exist'){
115
- $error_msg = __('Authentication failed, the client_secrets.json file is missing. Please make sure the client_secrets.json file is in wpvivid-backuprestore\includes\customclass directory.', 'wpvivid-backuprestore');
116
- echo '<div class="notice notice-error"><p>'.$error_msg.'</p></div>';
117
- }
118
- else if($e->getMessage() === 'invalid json for auth config'){
119
- $error_msg = __('Authentication failed, the format of the client_secrets.json file is incorrect. Please delete and re-install the plugin to recreate the file.', 'wpvivid-backuprestore');
120
- echo '<div class="notice notice-error"><p>'.$error_msg.'</p></div>';
121
- }
122
- else{
123
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
124
- }
125
- }
126
  }
127
- else if($_GET['action']=='wpvivid_google_drive_finish_auth')
128
- {
129
- file_put_contents('D:\page.txt', json_encode($_GET));
130
- try {
131
-
132
- if(isset($_GET['error']))
133
- {
134
- header('Location: '.admin_url().'admin.php?page='.WPVIVID_PLUGIN_SLUG.'&action=wpvivid_google_drive&result=error&resp_msg='.sanitize_text_field($_GET['error']));
135
-
136
- return;
137
- }
138
- $remoteslist = WPvivid_Setting::get_all_remote_options();
139
- foreach ($remoteslist as $key => $value) {
140
- if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id'])) {
141
- _e('<div class="notice notice-success is-dismissible"><p>You have authenticated the Google Drive account as your remote storage.</p></div>');
142
- return;
143
- }
144
- }
145
- if(isset($_POST) && !empty($_POST) && !isset($_POST['refresh_token']))
146
- {
147
- $err = 'No refresh token was received from Google, which means that you entered client secret incorrectly, or that you did not re-authenticated yet after you corrected it. Please authenticate again.';
148
- header('Location: '.admin_url().'admin.php?page='.WPVIVID_PLUGIN_SLUG.'&action=wpvivid_google_drive&result=error&resp_msg='.$err);
149
-
150
- return;
151
- }
152
-
153
- global $wpvivid_plugin;
154
-
155
- $remote_options['type'] = WPVIVID_REMOTE_GOOGLEDRIVE;
156
- $remote_options['token']['access_token'] = sanitize_text_field($_POST['access_token']);
157
- $remote_options['token']['expires_in'] = sanitize_text_field($_POST['expires_in']);
158
- $remote_options['token']['refresh_token'] = sanitize_text_field($_POST['refresh_token']);
159
- $remote_options['token']['scope'] = sanitize_text_field($_POST['scope']);
160
- $remote_options['token']['token_type'] = sanitize_text_field($_POST['token_type']);
161
- $remote_options['token']['created'] = sanitize_text_field($_POST['created']);
162
- $remote_options['name'] = sanitize_text_field($_GET['name']);
163
- $remote_options['default'] = sanitize_text_field($_GET['default']);
164
- $remote_options['path'] = WPVIVID_GOOGLEDRIVE_DEFAULT_FOLDER;
165
- $remote_options['auth_id'] = sanitize_text_field($_GET['auth_id']);
166
- $ret = $wpvivid_plugin->remote_collection->add_remote($remote_options);
167
-
168
- if ($ret['result'] == 'success') {
169
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_google_drive&result=success');
170
- return;
171
- } else {
172
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_google_drive&result=error&resp_msg=' . $ret['error']);
173
- return;
174
- }
175
- }
176
- catch (Exception $e){
177
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
178
- }
179
  }
180
- else if($_GET['action']=='wpvivid_google_drive')
181
- {
182
- try {
183
- if (isset($_GET['result'])) {
184
- if ($_GET['result'] == 'success') {
185
- add_action('show_notice', array($this, 'wpvivid_show_notice_add_google_drive_success'));
186
- } else if ($_GET['result'] == 'error') {
187
- add_action('show_notice', array($this, 'wpvivid_show_notice_add_google_drive_error'));
188
- }
189
- }
190
  }
191
- catch (Exception $e){
192
  echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
193
  }
194
  }
195
- else if($_GET['action']=='wpvivid_google_drive_update_auth')
 
 
 
196
  {
197
- if(!isset($_GET['name'])||empty($_GET['name']))
198
  {
199
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore').'</p></div>';
200
  return;
201
  }
202
 
203
- $alias_name=sanitize_text_field($_GET['name']);
204
- $id = sanitize_text_field($_GET['id']);
205
- $auth_id = uniqid('wpvivid-auth-');
206
-
207
- $remoteslist=WPvivid_Setting::get_all_remote_options();
208
- foreach ($remoteslist as $key=>$value)
209
  {
210
- if(isset($value['name'])&&$value['name'] == $alias_name&&$key!=$id)
211
  {
212
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
213
  return;
214
  }
215
  }
216
 
217
- try {
218
- include_once WPVIVID_PLUGIN_DIR . '/vendor/autoload.php';
219
- $client = new Google_Client();
220
- $client->setAuthConfig($this->google_drive_secrets);
221
- $client->setApprovalPrompt('force');
222
- $client->addScope(Google_Service_Drive::DRIVE_FILE);
223
- $client->setAccessType('offline');
224
- $client->setState(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_google_drive_finish_update_auth&name=' . $alias_name . '&id=' . $id.'&auth_id='.$auth_id);
225
- $auth_url = $client->createAuthUrl();
226
- header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
227
- }
228
- catch (Exception $e){
229
- if($e->getMessage() === 'file does not exist'){
230
- $error_msg = __('Authentication failed, the client_secrets.json file is missing. Please make sure the client_secrets.json file is in wpvivid-backuprestore\includes\customclass directory.', 'wpvivid-backuprestore');
231
- echo '<div class="notice notice-error"><p>'.$error_msg.'</p></div>';
232
- }
233
- else if($e->getMessage() === 'invalid json for auth config'){
234
- $error_msg = __('Authentication failed, the format of the client_secrets.json file is incorrect. Please delete and re-install the plugin to recreate the file.', 'wpvivid-backuprestore');
235
- echo '<div class="notice notice-error"><p>'.$error_msg.'</p></div>';
236
- }
237
- else{
238
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
239
- }
240
  }
241
- }
242
- else if($_GET['action']=='wpvivid_google_drive_finish_update_auth')
243
- {
244
- try {
245
- if(isset($_GET['error']))
246
  {
247
- header('Location: '.admin_url().'admin.php?page='.WPVIVID_PLUGIN_SLUG.'&action=wpvivid_google_drive_update&result=error&resp_msg='.sanitize_text_field($_GET['error']));
 
 
 
 
 
248
 
249
- return;
250
- }
251
- $remoteslist = WPvivid_Setting::get_all_remote_options();
252
- foreach ($remoteslist as $key => $value) {
253
- if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id'])) {
254
- _e('<div class="notice notice-success is-dismissible"><p>You have successfully updated the storage alias.</p></div>');
255
- return;
256
  }
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
-
259
- global $wpvivid_plugin;
260
-
261
- $remote_options['type'] = WPVIVID_REMOTE_GOOGLEDRIVE;
262
- $remote_options['token']['access_token'] = sanitize_text_field($_POST['access_token']);
263
- $remote_options['token']['expires_in'] = sanitize_text_field($_POST['expires_in']);
264
- $remote_options['token']['refresh_token'] = sanitize_text_field($_POST['refresh_token']);
265
- $remote_options['token']['scope'] = sanitize_text_field($_POST['scope']);
266
- $remote_options['token']['token_type'] = sanitize_text_field($_POST['token_type']);
267
- $remote_options['token']['created'] = sanitize_text_field($_POST['created']);
268
- $remote_options['name'] = sanitize_text_field($_GET['name']);
269
- $remote_options['path'] = WPVIVID_GOOGLEDRIVE_DEFAULT_FOLDER;
270
- $remote_options['auth_id'] = sanitize_text_field($_GET['auth_id']);
271
- $ret = $wpvivid_plugin->remote_collection->update_remote($remote_options['auth_id'], $remote_options);
272
-
273
- if ($ret['result'] == 'success') {
274
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_google_drive_update&result=success');
275
- return;
276
- } else {
277
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_google_drive_update&result=error&resp_msg=' . $ret['error']);
278
  return;
279
  }
280
  }
281
- catch (Exception $e){
282
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
283
- }
284
  }
285
- else if($_GET['action']=='wpvivid_google_drive_update')
286
- {
287
- try {
288
- if (isset($_GET['result'])) {
289
- if ($_GET['result'] == 'success') {
290
- add_action('show_notice', array($this, 'wpvivid_show_notice_edit_google_drive_success'));
291
- } else if ($_GET['result'] == 'error') {
292
- add_action('show_notice', array($this, 'wpvivid_show_notice_edit_google_drive_error'));
293
- }
 
 
 
294
  }
295
  }
296
- catch (Exception $e){
297
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
298
- }
299
  }
300
  }
301
  }
302
  }
 
303
  public function wpvivid_show_notice_add_google_drive_success(){
304
  echo '<div class="notice notice-success is-dismissible"><p>'.__('You have authenticated the Google Drive account as your remote storage.', 'wpvivid-backuprestore').'</p></div>';
305
  }
@@ -308,14 +199,6 @@ class Wpvivid_Google_drive extends WPvivid_Remote
308
  $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Add Google Drive Remote');
309
  echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
310
  }
311
- public function wpvivid_show_notice_edit_google_drive_success(){
312
- echo '<div class="notice notice-success is-dismissible"><p>'.__('You have successfully updated the storage alias.', 'wpvivid-backuprestore').'</p></div>';
313
- }
314
- public function wpvivid_show_notice_edit_google_drive_error(){
315
- global $wpvivid_plugin;
316
- $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Update Google Drive Remote');
317
- echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
318
- }
319
 
320
  public function wpvivid_add_storage_tab_google_drive()
321
  {
@@ -330,133 +213,224 @@ class Wpvivid_Google_drive extends WPvivid_Remote
330
  {
331
  global $wpvivid_plugin;
332
  $root_path=apply_filters('wpvivid_get_root_path', WPVIVID_REMOTE_GOOGLEDRIVE);
333
- ?>
334
- <div id="storage_account_google_drive" class="storage-account-page">
335
- <div style="background-color:#f1f1f1; padding: 10px;">
336
- <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Google Drive authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
337
- </div>
338
- <div style="padding: 10px 10px 10px 0;">
339
- <strong><?php _e('Enter Your Google Drive Information', 'wpvivid-backuprestore'); ?></strong>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  </div>
341
- <table class="wp-list-table widefat plugins" style="width:100%;">
342
- <tbody>
343
- <tr>
344
- <td class="plugin-title column-primary">
345
- <div class="wpvivid-storage-form">
346
- <input type="text" class="regular-text" autocomplete="off" option="googledrive" name="name" placeholder="<?php esc_attr_e('Enter a unique alias: e.g. Google Drive-001', 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
347
- </div>
348
- </td>
349
- <td class="column-description desc">
350
- <div class="wpvivid-storage-form-desc">
351
- <i><?php _e('A name to help you identify the storage if you have multiple remote storage connected.', 'wpvivid-backuprestore'); ?></i>
352
- </div>
353
- </td>
354
- </tr>
355
- <tr>
356
- <td class="plugin-title column-primary">
357
- <div class="wpvivid-storage-form">
358
- <input type="text" class="regular-text" autocomplete="off" option="googledrive" name="path" value="<?php esc_attr_e($root_path.WPVIVID_GOOGLEDRIVE_DEFAULT_FOLDER); ?>" readonly="readonly" />
359
- </div>
360
- </td>
361
- <td class="column-description desc">
362
- <div class="wpvivid-storage-form-desc">
363
- <i><?php _e('All backups will be uploaded to this directory.', 'wpvivid-backuprestore'); ?></i>
364
- </div>
365
- </td>
366
- </tr>
367
- <tr>
368
- <td class="plugin-title column-primary">
369
- <div class="wpvivid-storage-form">
370
- <input type="text" class="regular-text" autocomplete="off" value="mywebsite01" readonly="readonly" />
371
- </div>
372
- </td>
373
- <td class="column-description desc">
374
- <div class="wpvivid-storage-form-desc">
375
- <a href="https://docs.wpvivid.com/wpvivid-backup-pro-google-drive-custom-folder-name.html"><?php _e('Pro feature: Create a directory for storing the backups of the site', 'wpvivid-backuprestore'); ?></a>
376
- </div>
377
- </td>
378
- </tr>
379
- <tr>
380
- <td class="plugin-title column-primary">
381
- <div class="wpvivid-storage-select">
382
- <label>
383
- <input type="checkbox" option="googledrive" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid-backuprestore'); ?>
384
- </label>
385
- </div>
386
- </td>
387
- <td class="column-description desc">
388
- <div class="wpvivid-storage-form-desc">
389
- <i><?php _e('Once checked, all this sites backups sent to a remote storage destination will be uploaded to this storage by default.', 'wpvivid-backuprestore'); ?></i>
390
- </div>
391
- </td>
392
- </tr>
393
- <tr>
394
- <td class="plugin-title column-primary">
395
- <div class="wpvivid-storage-form">
396
- <input onclick="wpvivid_google_drive_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Authenticate with Google Drive', 'wpvivid-backuprestore'); ?>" />
397
- </div>
398
- </td>
399
- <td class="column-description desc">
400
- <div class="wpvivid-storage-form-desc">
401
- <i><?php _e('Click the button to get Google authentication and add it to the storage list below.', 'wpvivid-backuprestore'); ?></i>
402
- </div>
403
- </td>
404
- </tr>
405
- </tbody>
406
- </table>
407
- </div>
408
- <script>
409
- function wpvivid_check_google_drive_storage_alias(storage_alias){
410
- var find = 1;
411
- jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
412
- jQuery(this).children('td').each(function (j) {
413
- if (j == 3) {
414
- if (jQuery(this).text() == storage_alias) {
415
- find = -1;
416
- return false;
417
  }
418
- }
419
  });
 
 
 
 
 
420
  });
421
- return find;
422
- }
423
- function wpvivid_google_drive_auth()
424
- {
425
- wpvivid_settings_changed = false;
426
- var name='';
427
- var path='';
428
- jQuery('input:text[option=googledrive]').each(function()
429
  {
430
- var key = jQuery(this).prop('name');
431
- if(key==='name')
 
 
432
  {
433
- name = jQuery(this).val();
434
- }
435
- });
 
 
 
436
 
437
- var remote_default='0';
438
 
439
- jQuery('input:checkbox[option=googledrive]').each(function()
440
- {
441
- if(jQuery(this).prop('checked')) {
442
- remote_default='1';
 
 
 
 
 
 
 
443
  }
444
- else {
445
- remote_default='0';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  }
447
- });
448
- if(name == ''){
449
- alert(wpvividlion.remotealias);
450
- }
451
- else if(wpvivid_check_google_drive_storage_alias(name) === -1){
452
- alert(wpvividlion.remoteexist);
453
  }
454
- else {
455
- location.href = '<?php echo admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_google_drive_auth&name='?>' + name + '&default=' + remote_default;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
  }
457
- }
458
- </script>
459
- <?php
 
460
  }
461
 
462
  public function wpvivid_edit_storage_page_google_drive()
@@ -483,7 +457,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
483
  <tr>
484
  <td class="plugin-title column-primary">
485
  <div class="wpvivid-storage-form">
486
- <input onclick="wpvivid_google_drive_update_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Save Changes', 'wpvivid-backuprestore'); ?>" />
487
  </div>
488
  </td>
489
  <td class="column-description desc">
@@ -1064,4 +1038,72 @@ class Wpvivid_Google_drive extends WPvivid_Remote
1064
  }
1065
  return array('result' => WPVIVID_SUCCESS);
1066
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1067
  }
22
 
23
  public $google_drive_secrets;
24
 
25
+ public $add_remote;
26
+
27
  public function __construct($options=array())
28
  {
29
  if(empty($options))
31
  if(!defined('WPVIVID_INIT_STORAGE_TAB_GOOGLE_DRIVE'))
32
  {
33
  add_action('init', array($this, 'handle_auth_actions'));
34
+ //wpvivid_google_drive_add_remote
35
+ add_action('wp_ajax_wpvivid_google_drive_add_remote',array( $this,'finish_add_remote'));
36
 
37
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_google_drive'), 10);
38
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_google_drive'), 10);
50
  {
51
  $this->options=$options;
52
  }
53
+ $this->add_remote=false;
54
  $this->google_drive_secrets = array("web"=>array(
55
  "client_id"=>"134809148507-32crusepgace4h6g47ota99jjrvf4j1u.apps.googleusercontent.com",
56
  "project_id"=>"wpvivid-auth",
74
 
75
  public function handle_auth_actions()
76
  {
77
+ if(isset($_GET['action']))
78
  {
79
+ if($_GET['action']=='wpvivid_google_drive_auth')
80
  {
81
+ $auth_id = uniqid('wpvivid-auth-');
82
+ $res = $this -> compare_php_version();
83
+ if($res['result'] == WPVIVID_FAILED){
84
+ echo '<div class="notice notice-warning is-dismissible"><p>'.$res['error'].'</p></div>';
85
+ return ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
+ try {
88
+ include_once WPVIVID_PLUGIN_DIR . '/vendor/autoload.php';
89
+ $client = new Google_Client();
90
+ $client->setAuthConfig($this->google_drive_secrets);
91
+ $client->setApprovalPrompt('force');
92
+ $client->addScope(Google_Service_Drive::DRIVE_FILE);
93
+ $client->setAccessType('offline');
94
+ $client->setState(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_google_drive_finish_auth&main_tab=storage&sub_tab=googledrive&sub_page=storage_account_google_drive&auth_id='.$auth_id);
95
+ $auth_url = $client->createAuthUrl();
96
+ $remote_options['auth_id']=$auth_id;
97
+ update_option('wpvivid_tmp_remote_options',$remote_options);
98
+ header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
+ catch (Exception $e){
101
+ if($e->getMessage() === 'file does not exist'){
102
+ $error_msg = __('Authentication failed, the client_secrets.json file is missing. Please make sure the client_secrets.json file is in wpvivid-backuprestore\includes\customclass directory.', 'wpvivid-backuprestore');
103
+ echo '<div class="notice notice-error"><p>'.$error_msg.'</p></div>';
104
+ }
105
+ else if($e->getMessage() === 'invalid json for auth config'){
106
+ $error_msg = __('Authentication failed, the format of the client_secrets.json file is incorrect. Please delete and re-install the plugin to recreate the file.', 'wpvivid-backuprestore');
107
+ echo '<div class="notice notice-error"><p>'.$error_msg.'</p></div>';
 
 
108
  }
109
+ else{
110
  echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
111
  }
112
  }
113
+ }
114
+ else if($_GET['action']=='wpvivid_google_drive_finish_auth')
115
+ {
116
+ try
117
  {
118
+ if(isset($_GET['error']))
119
  {
120
+ header('Location: '.admin_url().'admin.php?page='.WPVIVID_PLUGIN_SLUG.'&action=wpvivid_google_drive&main_tab=storage&sub_tab=googledrive&sub_page=storage_account_google_drive&result=error&resp_msg='.sanitize_text_field($_GET['error']));
121
  return;
122
  }
123
 
124
+ $remoteslist = WPvivid_Setting::get_all_remote_options();
125
+ foreach ($remoteslist as $key => $value)
 
 
 
 
126
  {
127
+ if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id']))
128
  {
129
+ _e('<div class="notice notice-success is-dismissible"><p>You have authenticated the Google Drive account as your remote storage.</p></div>');
130
  return;
131
  }
132
  }
133
 
134
+ $tmp_options=get_option('wpvivid_tmp_remote_options',false);
135
+ if($tmp_options===false)
136
+ {
137
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
+ else
140
+ {
141
+ if($tmp_options['auth_id']===$_GET['auth_id'])
 
 
142
  {
143
+ if(empty($_POST['refresh_token']))
144
+ {
145
+ if(empty($tmp_options['token']['refresh_token']))
146
+ {
147
+ $err = 'No refresh token was received from Google, which means that you entered client secret incorrectly, or that you did not re-authenticated yet after you corrected it. Please authenticate again.';
148
+ header('Location: '.admin_url().'admin.php?page='.WPVIVID_PLUGIN_SLUG.'&action=wpvivid_google_drive&main_tab=storage&sub_tab=googledrive&sub_page=storage_account_google_drive&result=error&resp_msg='.$err);
149
 
150
+ return;
151
+ }
 
 
 
 
 
152
  }
153
+ else
154
+ {
155
+ $tmp_options['type'] = WPVIVID_REMOTE_GOOGLEDRIVE;
156
+ $tmp_options['token']['access_token'] = sanitize_text_field($_POST['access_token']);
157
+ $tmp_options['token']['expires_in'] = sanitize_text_field($_POST['expires_in']);
158
+ $tmp_options['token']['refresh_token'] = sanitize_text_field($_POST['refresh_token']);
159
+ $tmp_options['token']['scope'] = sanitize_text_field($_POST['scope']);
160
+ $tmp_options['token']['token_type'] = sanitize_text_field($_POST['token_type']);
161
+ $tmp_options['token']['created'] = sanitize_text_field($_POST['created']);
162
+ update_option('wpvivid_tmp_remote_options',$tmp_options);
163
+ }
164
+ $this->add_remote=true;
165
  }
166
+ else
167
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  return;
169
  }
170
  }
 
 
 
171
  }
172
+ catch (Exception $e){
173
+ echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
174
+ }
175
+ }
176
+ else if($_GET['action']=='wpvivid_google_drive')
177
+ {
178
+ try {
179
+ if (isset($_GET['result'])) {
180
+ if ($_GET['result'] == 'success') {
181
+ add_action('show_notice', array($this, 'wpvivid_show_notice_add_google_drive_success'));
182
+ } else if ($_GET['result'] == 'error') {
183
+ add_action('show_notice', array($this, 'wpvivid_show_notice_add_google_drive_error'));
184
  }
185
  }
186
+ }
187
+ catch (Exception $e){
188
+ _e('<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>');
189
  }
190
  }
191
  }
192
  }
193
+
194
  public function wpvivid_show_notice_add_google_drive_success(){
195
  echo '<div class="notice notice-success is-dismissible"><p>'.__('You have authenticated the Google Drive account as your remote storage.', 'wpvivid-backuprestore').'</p></div>';
196
  }
199
  $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Add Google Drive Remote');
200
  echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
201
  }
 
 
 
 
 
 
 
 
202
 
203
  public function wpvivid_add_storage_tab_google_drive()
204
  {
213
  {
214
  global $wpvivid_plugin;
215
  $root_path=apply_filters('wpvivid_get_root_path', WPVIVID_REMOTE_GOOGLEDRIVE);
216
+ if($this->add_remote)
217
+ {
218
+ ?>
219
+ <div id="storage_account_google_drive" class="storage-account-page">
220
+ <div style="background-color:#f1f1f1; padding: 10px;">
221
+ <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Google Drive authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
222
+ </div>
223
+ <div style="color:#8bc34a; padding: 10px 10px 10px 0;">
224
+ <strong>Authentication is done, please continue to enter the storge information, then click 'Add Now' button to save it.</strong>
225
+ </div>
226
+ <div style="padding: 10px 10px 10px 0;">
227
+ <strong><?php _e('Enter Your Google Drive Information', 'wpvivid-backuprestore'); ?></strong>
228
+ </div>
229
+ <table class="wp-list-table widefat plugins" style="width:100%;">
230
+ <tbody>
231
+ <tr>
232
+ <td class="plugin-title column-primary">
233
+ <div class="wpvivid-storage-form">
234
+ <input type="text" class="regular-text" autocomplete="off" option="googledrive" name="name" placeholder="<?php esc_attr_e('Enter a unique alias: e.g. Google Drive-001', 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
235
+ </div>
236
+ </td>
237
+ <td class="column-description desc">
238
+ <div class="wpvivid-storage-form-desc">
239
+ <i><?php _e('A name to help you identify the storage if you have multiple remote storage connected.', 'wpvivid-backuprestore'); ?></i>
240
+ </div>
241
+ </td>
242
+ </tr>
243
+ <tr>
244
+ <td class="plugin-title column-primary">
245
+ <div class="wpvivid-storage-form">
246
+ <input type="text" class="regular-text" autocomplete="off" name="path" value="<?php esc_attr_e($root_path.WPVIVID_GOOGLEDRIVE_DEFAULT_FOLDER); ?>" readonly="readonly" />
247
+ </div>
248
+ </td>
249
+ <td class="column-description desc">
250
+ <div class="wpvivid-storage-form-desc">
251
+ <i><?php _e('All backups will be uploaded to this directory.', 'wpvivid-backuprestore'); ?></i>
252
+ </div>
253
+ </td>
254
+ </tr>
255
+ <tr>
256
+ <td class="plugin-title column-primary">
257
+ <div class="wpvivid-storage-form">
258
+ <input type="text" class="regular-text" autocomplete="off" value="mywebsite01" readonly="readonly" />
259
+ </div>
260
+ </td>
261
+ <td class="column-description desc">
262
+ <div class="wpvivid-storage-form-desc">
263
+ <a href="https://docs.wpvivid.com/wpvivid-backup-pro-google-drive-custom-folder-name.html"><?php _e('Pro feature: Create a directory for storing the backups of the site', 'wpvivid-backuprestore'); ?></a>
264
+ </div>
265
+ </td>
266
+ </tr>
267
+ <tr>
268
+ <td class="plugin-title column-primary">
269
+ <div class="wpvivid-storage-select">
270
+ <label>
271
+ <input type="checkbox" option="googledrive" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid-backuprestore'); ?>
272
+ </label>
273
+ </div>
274
+ </td>
275
+ <td class="column-description desc">
276
+ <div class="wpvivid-storage-form-desc">
277
+ <i><?php _e('Once checked, all this sites backups sent to a remote storage destination will be uploaded to this storage by default.', 'wpvivid-backuprestore'); ?></i>
278
+ </div>
279
+ </td>
280
+ </tr>
281
+ <tr>
282
+ <td class="plugin-title column-primary">
283
+ <div class="wpvivid-storage-form">
284
+ <input id="wpvivid_google_drive_auth" class="button-primary" type="submit" value="<?php esc_attr_e('Add Now', 'wpvivid-backuprestore'); ?>" />
285
+ </div>
286
+ </td>
287
+ <td class="column-description desc">
288
+ <div class="wpvivid-storage-form-desc">
289
+ <i><?php _e('Click the button to add the storage.', 'wpvivid-backuprestore'); ?></i>
290
+ </div>
291
+ </td>
292
+ </tr>
293
+ </tbody>
294
+ </table>
295
  </div>
296
+ <script>
297
+ function wpvivid_check_google_drive_storage_alias(storage_alias){
298
+ var find = 1;
299
+ jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
300
+ jQuery(this).children('td').each(function (j) {
301
+ if (j == 3) {
302
+ if (jQuery(this).text() == storage_alias) {
303
+ find = -1;
304
+ return false;
305
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
+ });
308
  });
309
+ return find;
310
+ }
311
+ jQuery('#wpvivid_google_drive_auth').click(function()
312
+ {
313
+ wpvivid_google_drive_auth();
314
  });
315
+
316
+ function wpvivid_google_drive_auth()
 
 
 
 
 
 
317
  {
318
+ wpvivid_settings_changed = false;
319
+ var name='';
320
+ var path='';
321
+ jQuery('input:text[option=googledrive]').each(function()
322
  {
323
+ var key = jQuery(this).prop('name');
324
+ if(key==='name')
325
+ {
326
+ name = jQuery(this).val();
327
+ }
328
+ });
329
 
330
+ var remote_default='0';
331
 
332
+ jQuery('input:checkbox[option=googledrive]').each(function()
333
+ {
334
+ if(jQuery(this).prop('checked')) {
335
+ remote_default='1';
336
+ }
337
+ else {
338
+ remote_default='0';
339
+ }
340
+ });
341
+ if(name == ''){
342
+ alert(wpvividlion.remotealias);
343
  }
344
+ else if(wpvivid_check_google_drive_storage_alias(name) === -1)
345
+ {
346
+ alert(wpvividlion.remoteexist);
347
+ }
348
+ else
349
+ {
350
+ var ajax_data;
351
+ var remote_from = wpvivid_ajax_data_transfer('googledrive');
352
+ ajax_data = {
353
+ 'action': 'wpvivid_google_drive_add_remote',
354
+ 'remote': remote_from
355
+ };
356
+ jQuery('#wpvivid_google_drive_auth').css({'pointer-events': 'none', 'opacity': '0.4'});
357
+ jQuery('#wpvivid_remote_notice').html('');
358
+ wpvivid_post_request(ajax_data, function (data)
359
+ {
360
+ try
361
+ {
362
+ var jsonarray = jQuery.parseJSON(data);
363
+ if (jsonarray.result === 'success')
364
+ {
365
+ jQuery('#wpvivid_google_drive_auth').css({'pointer-events': 'auto', 'opacity': '1'});
366
+ jQuery('input:text[option=googledrive]').each(function(){
367
+ jQuery(this).val('');
368
+ });
369
+ jQuery('input:password[option=googledrive]').each(function(){
370
+ jQuery(this).val('');
371
+ });
372
+ wpvivid_handle_remote_storage_data(data);
373
+ location.href='admin.php?page=WPvivid&action=wpvivid_google_drive&main_tab=storage&sub_tab=googledrive&sub_page=storage_account_google_drive&result=success';
374
+ }
375
+ else if (jsonarray.result === 'failed')
376
+ {
377
+ jQuery('#wpvivid_remote_notice').html(jsonarray.notice);
378
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
379
+ }
380
+ }
381
+ catch (err)
382
+ {
383
+ alert(err);
384
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
385
+ }
386
+
387
+ }, function (XMLHttpRequest, textStatus, errorThrown)
388
+ {
389
+ var error_message = wpvivid_output_ajaxerror('adding the remote storage', textStatus, errorThrown);
390
+ alert(error_message);
391
+ jQuery('#wpvivid_google_drive_auth').css({'pointer-events': 'auto', 'opacity': '1'});
392
+ });
393
  }
 
 
 
 
 
 
394
  }
395
+ </script>
396
+ <?php
397
+ }
398
+ else
399
+ {
400
+ ?>
401
+ <div id="storage_account_google_drive" class="storage-account-page">
402
+ <div style="background-color:#f1f1f1; padding: 10px;">
403
+ <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Google Drive authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
404
+ </div>
405
+ <div style="padding: 10px 10px 10px 0;">
406
+ <strong><?php _e('To add Google Drive, please get Google authentication first. Once authenticated, you will be redirected to this page, then you can add storage information and save it', 'wpvivid-backuprestore'); ?></strong>
407
+ </div>
408
+ <table class="wp-list-table widefat plugins" style="width:100%;">
409
+ <tbody>
410
+ <tr>
411
+ <td class="plugin-title column-primary">
412
+ <div class="wpvivid-storage-form">
413
+ <input onclick="wpvivid_google_drive_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Authenticate with Google Drive', 'wpvivid-backuprestore'); ?>" />
414
+ </div>
415
+ </td>
416
+ <td class="column-description desc">
417
+ <div class="wpvivid-storage-form-desc">
418
+ <i><?php _e('Click to get Google authentication.', 'wpvivid-backuprestore'); ?></i>
419
+ </div>
420
+ </td>
421
+ </tr>
422
+ </tbody>
423
+ </table>
424
+ </div>
425
+ <script>
426
+ function wpvivid_google_drive_auth()
427
+ {
428
+ location.href = '<?php echo admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_google_drive_auth'?>';
429
  }
430
+ </script>
431
+ <?php
432
+ }
433
+
434
  }
435
 
436
  public function wpvivid_edit_storage_page_google_drive()
457
  <tr>
458
  <td class="plugin-title column-primary">
459
  <div class="wpvivid-storage-form">
460
+ <input class="button-primary" type="submit" option="edit-remote" value="<?php esc_attr_e('Save Changes', 'wpvivid-backuprestore'); ?>" />
461
  </div>
462
  </td>
463
  <td class="column-description desc">
1038
  }
1039
  return array('result' => WPVIVID_SUCCESS);
1040
  }
1041
+
1042
+ public function finish_add_remote()
1043
+ {
1044
+ global $wpvivid_plugin;
1045
+ $wpvivid_plugin->ajax_check_security();
1046
+ try {
1047
+ if (empty($_POST) || !isset($_POST['remote']) || !is_string($_POST['remote'])) {
1048
+ die();
1049
+ }
1050
+
1051
+ $tmp_remote_options =get_option('wpvivid_tmp_remote_options',array());
1052
+ delete_option('wpvivid_tmp_remote_options');
1053
+ if(empty($tmp_remote_options)||$tmp_remote_options['type']!==WPVIVID_REMOTE_GOOGLEDRIVE)
1054
+ {
1055
+ die();
1056
+ }
1057
+
1058
+ $json = $_POST['remote'];
1059
+ $json = stripslashes($json);
1060
+ $remote_options = json_decode($json, true);
1061
+ if (is_null($remote_options)) {
1062
+ die();
1063
+ }
1064
+
1065
+ $remote_options['path'] = WPVIVID_GOOGLEDRIVE_DEFAULT_FOLDER;
1066
+ $remote_options=array_merge($remote_options,$tmp_remote_options);
1067
+
1068
+ $ret = $wpvivid_plugin->remote_collection->add_remote($remote_options);
1069
+
1070
+ if ($ret['result'] == 'success') {
1071
+ $html = '';
1072
+ $html = apply_filters('wpvivid_add_remote_storage_list', $html);
1073
+ $ret['html'] = $html;
1074
+ $pic = '';
1075
+ $pic = apply_filters('wpvivid_schedule_add_remote_pic', $pic);
1076
+ $ret['pic'] = $pic;
1077
+ $dir = '';
1078
+ $dir = apply_filters('wpvivid_get_remote_directory', $dir);
1079
+ $ret['dir'] = $dir;
1080
+ $schedule_local_remote = '';
1081
+ $schedule_local_remote = apply_filters('wpvivid_schedule_local_remote', $schedule_local_remote);
1082
+ $ret['local_remote'] = $schedule_local_remote;
1083
+ $remote_storage = '';
1084
+ $remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
1085
+ $ret['remote_storage'] = $remote_storage;
1086
+ $remote_select_part = '';
1087
+ $remote_select_part = apply_filters('wpvivid_remote_storage_select_part', $remote_select_part);
1088
+ $ret['remote_select_part'] = $remote_select_part;
1089
+ $default = array();
1090
+ $remote_array = apply_filters('wpvivid_archieve_remote_array', $default);
1091
+ $ret['remote_array'] = $remote_array;
1092
+ $success_msg = __('You have successfully added a remote storage.', 'wpvivid-backuprestore');
1093
+ $ret['notice'] = apply_filters('wpvivid_add_remote_notice', true, $success_msg);
1094
+ }
1095
+ else{
1096
+ $ret['notice'] = apply_filters('wpvivid_add_remote_notice', false, $ret['error']);
1097
+ }
1098
+
1099
+ }
1100
+ catch (Exception $error) {
1101
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
1102
+ error_log($message);
1103
+ echo json_encode(array('result'=>'failed','error'=>$message));
1104
+ die();
1105
+ }
1106
+ echo json_encode($ret);
1107
+ die();
1108
+ }
1109
  }
includes/customclass/class-wpvivid-one-drive.php CHANGED
@@ -35,6 +35,7 @@ class WPvivid_one_drive extends WPvivid_Remote
35
  {
36
  public $options;
37
  public $callback;
 
38
  public function __construct($options=array())
39
  {
40
  if(empty($options))
@@ -42,6 +43,9 @@ class WPvivid_one_drive extends WPvivid_Remote
42
  if(!defined('WPVIVID_INIT_STORAGE_TAB_ONE_DRIVE'))
43
  {
44
  add_action('init', array($this, 'handle_auth_actions'));
 
 
 
45
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_one_drive'), 12);
46
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_one_drive'), 12);
47
  add_action('wpvivid_edit_remote_page',array($this,'wpvivid_edit_storage_page_one_drive'), 12);
@@ -57,6 +61,7 @@ class WPvivid_one_drive extends WPvivid_Remote
57
  {
58
  $this->options=$options;
59
  }
 
60
  }
61
 
62
  public function pre_add_remote($remote,$id)
@@ -78,30 +83,15 @@ class WPvivid_one_drive extends WPvivid_Remote
78
  if($_GET['action']=='wpvivid_one_drive_auth')
79
  {
80
  try {
81
- if (!isset($_GET['name']) || empty($_GET['name'])) {
82
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore').'</p></div>';
83
- return;
84
- }
85
-
86
- $alias_name = sanitize_text_field($_GET['name']);
87
-
88
- $remoteslist = WPvivid_Setting::get_all_remote_options();
89
- foreach ($remoteslist as $key => $value) {
90
- if (isset($value['name']) && $value['name'] == $alias_name) {
91
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
92
- return;
93
- }
94
- }
95
-
96
- $default = sanitize_text_field($_GET['default']);
97
  $auth_id = uniqid('wpvivid-auth-');
98
-
 
99
  $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
100
  . '?client_id=' . urlencode('37668be9-b55f-458f-b6a3-97e6f8aa10c9')
101
  . '&scope=' . urlencode('offline_access files.readwrite')
102
  . '&response_type=code'
103
  . '&redirect_uri=' . urlencode('https://auth.wpvivid.com/onedrive_v2/')
104
- . '&state=' . urlencode(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_finish_auth&name='.$alias_name.'&default='.$default.'&auth_id='.$auth_id)
105
  . '&display=popup'
106
  . '&locale=en';
107
  header('Location: ' . esc_url_raw($url));
@@ -122,135 +112,62 @@ class WPvivid_one_drive extends WPvivid_Remote
122
  }
123
 
124
  $remoteslist = WPvivid_Setting::get_all_remote_options();
125
- foreach ($remoteslist as $key => $value) {
126
- if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id'])) {
 
 
127
  _e('<div class="notice notice-success is-dismissible"><p>You have authenticated the Microsoft OneDrive account as your remote storage.</p></div>');
128
  return;
129
  }
130
  }
131
 
132
- global $wpvivid_plugin;
133
-
134
- $remote_options['type'] = WPVIVID_REMOTE_ONEDRIVE;
135
- $remote_options['token']['access_token']=sanitize_text_field($_POST['access_token']);
136
- $remote_options['token']['refresh_token']=sanitize_text_field($_POST['refresh_token']);
137
- $remote_options['token']['expires']=time()+sanitize_text_field($_POST['expires_in']);
138
-
139
- $remote_options['name'] = sanitize_text_field($_GET['name']);
140
- $remote_options['default'] = sanitize_text_field($_GET['default']);
141
- $remote_options['path'] = WPVIVID_ONEDRIVE_DEFAULT_FOLDER;
142
- $remote_options['auth_id'] = sanitize_text_field($_GET['auth_id']);
143
- $ret = $wpvivid_plugin->remote_collection->add_remote($remote_options);
144
-
145
- if ($ret['result'] == 'success') {
146
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_one_drive&result=success');
147
- return;
148
- } else {
149
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_one_drive&result=error&resp_msg=' . $ret['error']);
150
  return;
151
  }
152
- }
153
- catch (Exception $e){
154
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
155
- }
156
- }
157
- else if($_GET['action']=='wpvivid_one_drive')
158
- {
159
- try {
160
- if (isset($_GET['result'])) {
161
- if ($_GET['result'] == 'success') {
162
- add_action('show_notice', array($this, 'wpvivid_show_notice_add_onedrive_success'));
163
- } else if ($_GET['result'] == 'error') {
164
- add_action('show_notice', array($this, 'wpvivid_show_notice_add_onedrive_error'));
 
 
 
 
 
 
 
 
 
 
165
  }
166
- }
167
- }
168
- catch (Exception $e){
169
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
170
- }
171
- }
172
- else if($_GET['action']=='wpvivid_one_drive_update_auth')
173
- {
174
- try {
175
- if (!isset($_GET['name']) || empty($_GET['name'])) {
176
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore').'</p></div>';
177
- return;
178
- }
179
-
180
- $alias_name = sanitize_text_field($_GET['name']);
181
- $id = sanitize_text_field($_GET['id']);
182
- $auth_id = uniqid('wpvivid-auth-');
183
- $remoteslist = WPvivid_Setting::get_all_remote_options();
184
- foreach ($remoteslist as $key => $value) {
185
- if (isset($value['name']) && $value['name'] == $alias_name && $key != $id) {
186
- echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
187
  return;
188
  }
189
  }
190
-
191
- $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
192
- . '?client_id=' . urlencode('37668be9-b55f-458f-b6a3-97e6f8aa10c9')
193
- . '&scope=' . urlencode('offline_access files.readwrite')
194
- . '&response_type=code'
195
- . '&redirect_uri=' . urlencode('https://auth.wpvivid.com/onedrive_v2/')
196
- . '&state=' . urlencode(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_update_finish_auth&name='.$alias_name.'&id='.$id.'&auth_id='.$auth_id)
197
- . '&display=popup'
198
- . '&locale=en';
199
- header('Location: ' . esc_url_raw($url));
200
- }
201
- catch (Exception $e){
202
- echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
203
- }
204
- }
205
- else if($_GET['action']=='wpvivid_one_drive_update_finish_auth')
206
- {
207
- try {
208
- if (isset($_GET['auth_error'])) {
209
- $error = urldecode($_GET['auth_error']);
210
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_one_drive_update&result=error&resp_msg=' . $error);
211
-
212
- return;
213
- }
214
-
215
- $remoteslist = WPvivid_Setting::get_all_remote_options();
216
- foreach ($remoteslist as $key => $value) {
217
- if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id'])) {
218
- _e('<div class="notice notice-success is-dismissible"><p>You have successfully updated the storage alias.</p></div>');
219
- return;
220
- }
221
- }
222
-
223
- global $wpvivid_plugin;
224
-
225
- $remote_options['type'] = WPVIVID_REMOTE_ONEDRIVE;
226
- $remote_options['token']['access_token']=sanitize_text_field($_POST['access_token']);
227
- $remote_options['token']['refresh_token']=sanitize_text_field($_POST['refresh_token']);
228
- $remote_options['token']['expires']=time()+sanitize_text_field($_POST['expires_in']);
229
- $remote_options['name'] = sanitize_text_field($_GET['name']);
230
- $remote_options['path'] = WPVIVID_ONEDRIVE_DEFAULT_FOLDER;
231
- $remote_options['auth_id'] = sanitize_text_field($_GET['auth_id']);
232
- $ret = $wpvivid_plugin->remote_collection->update_remote($remote_options['auth_id'], $remote_options);
233
-
234
- if ($ret['result'] == 'success') {
235
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_one_drive_update&result=success');
236
- return;
237
- } else {
238
- header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_one_drive_update&result=error&resp_msg=' . $ret['error']);
239
- return;
240
- }
241
  }
242
  catch (Exception $e){
243
  echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
244
  }
245
  }
246
- else if($_GET['action']=='wpvivid_one_drive_update')
247
  {
248
  try {
249
  if (isset($_GET['result'])) {
250
  if ($_GET['result'] == 'success') {
251
- add_action('show_notice', array($this, 'wpvivid_show_notice_edit_onedrive_success'));
252
  } else if ($_GET['result'] == 'error') {
253
- add_action('show_notice', array($this, 'wpvivid_show_notice_edit_onedrive_error'));
254
  }
255
  }
256
  }
@@ -269,14 +186,6 @@ class WPvivid_one_drive extends WPvivid_Remote
269
  $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Add OneDrive Remote');
270
  echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
271
  }
272
- public function wpvivid_show_notice_edit_onedrive_success(){
273
- echo '<div class="notice notice-success is-dismissible"><p>'.__('You have successfully updated the storage alias.', 'wpvivid-backuprestore').'</p></div>';
274
- }
275
- public function wpvivid_show_notice_edit_onedrive_error(){
276
- global $wpvivid_plugin;
277
- $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Update OneDrive Remote');
278
- echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
279
- }
280
 
281
  public function wpvivid_add_storage_tab_one_drive()
282
  {
@@ -291,133 +200,223 @@ class WPvivid_one_drive extends WPvivid_Remote
291
  {
292
  global $wpvivid_plugin;
293
  $root_path=apply_filters('wpvivid_get_root_path', WPVIVID_REMOTE_ONEDRIVE);
294
- ?>
295
- <div id="storage_account_one_drive" class="storage-account-page" style="display:none;">
296
- <div style="background-color:#f1f1f1; padding: 10px;">
297
- <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Microsoft OneDrive authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
298
- </div>
299
- <div style="padding: 10px 10px 10px 0;">
300
- <strong><?php _e('Enter Your Microsoft OneDrive Information', 'wpvivid-backuprestore'); ?></strong>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  </div>
302
- <table class="wp-list-table widefat plugins" style="width:100%;">
303
- <tbody>
304
- <tr>
305
- <td class="plugin-title column-primary">
306
- <div class="wpvivid-storage-form">
307
- <input type="text" class="regular-text" autocomplete="off" option="one_drive" name="name" placeholder="<?php esc_attr_e('Enter a unique alias: e.g. OneDrive-001', 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
308
- </div>
309
- </td>
310
- <td class="column-description desc">
311
- <div class="wpvivid-storage-form-desc">
312
- <i><?php _e('A name to help you identify the storage if you have multiple remote storage connected.', 'wpvivid-backuprestore'); ?></i>
313
- </div>
314
- </td>
315
- </tr>
316
- <tr>
317
- <td class="plugin-title column-primary">
318
- <div class="wpvivid-storage-form">
319
- <input type="text" class="regular-text" autocomplete="off" option="one_drive" name="path" value="<?php esc_attr_e($root_path.WPVIVID_ONEDRIVE_DEFAULT_FOLDER); ?>" readonly="readonly" />
320
- </div>
321
- </td>
322
- <td class="column-description desc">
323
- <div class="wpvivid-storage-form-desc">
324
- <i><?php _e('All backups will be uploaded to this directory.', 'wpvivid-backuprestore'); ?></i>
325
- </div>
326
- </td>
327
- </tr>
328
- <tr>
329
- <td class="plugin-title column-primary">
330
- <div class="wpvivid-storage-form">
331
- <input type="text" class="regular-text" autocomplete="off" value="mywebsite01" readonly="readonly" />
332
- </div>
333
- </td>
334
- <td class="column-description desc">
335
- <div class="wpvivid-storage-form-desc">
336
- <a href="https://docs.wpvivid.com/wpvivid-backup-pro-microsoft-onedrive-custom-folder-name.html"><?php _e('Pro feature: Create a directory for storing the backups of the site', 'wpvivid-backuprestore'); ?></a>
337
- </div>
338
- </td>
339
- </tr>
340
- <tr>
341
- <td class="plugin-title column-primary">
342
- <div class="wpvivid-storage-select">
343
- <label>
344
- <input type="checkbox" option="one_drive" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid-backuprestore'); ?>
345
- </label>
346
- </div>
347
- </td>
348
- <td class="column-description desc">
349
- <div class="wpvivid-storage-form-desc">
350
- <i><?php _e('Once checked, all this sites backups sent to a remote storage destination will be uploaded to this storage by default.', 'wpvivid-backuprestore'); ?></i>
351
- </div>
352
- </td>
353
- </tr>
354
- <tr>
355
- <td class="plugin-title column-primary">
356
- <div class="wpvivid-storage-form">
357
- <input onclick="wpvivid_one_drive_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Authenticate with Microsoft OneDrive', 'wpvivid-backuprestore'); ?>">
358
- </div>
359
- </td>
360
- <td class="column-description desc">
361
- <div class="wpvivid-storage-form-desc">
362
- <i><?php _e('Click the button to get Microsoft authentication and add it to the storage list below.', 'wpvivid-backuprestore'); ?></i>
363
- </div>
364
- </td>
365
- </tr>
366
- </tbody>
367
- </table>
368
- </div>
369
- <script>
370
- function wpvivid_check_onedrive_storage_alias(storage_alias){
371
- var find = 1;
372
- jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
373
- jQuery(this).children('td').each(function (j) {
374
- if (j == 3) {
375
- if (jQuery(this).text() == storage_alias) {
376
- find = -1;
377
- return false;
378
  }
379
- }
380
  });
 
 
 
 
 
 
381
  });
382
- return find;
383
- }
384
- function wpvivid_one_drive_auth()
385
- {
386
- wpvivid_settings_changed = false;
387
- var name='';
388
- var path='';
389
- jQuery('input:text[option=one_drive]').each(function()
390
  {
391
- var key = jQuery(this).prop('name');
392
- if(key==='name')
 
 
393
  {
394
- name = jQuery(this).val();
395
- }
396
- });
 
 
 
397
 
398
- var remote_default='0';
399
 
400
- jQuery('input:checkbox[option=one_drive]').each(function()
401
- {
402
- if(jQuery(this).prop('checked')) {
403
- remote_default='1';
 
 
 
 
 
 
 
 
 
 
404
  }
405
  else {
406
- remote_default='0';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  }
408
- });
409
- if(name == ''){
410
- alert(wpvividlion.remotealias);
411
  }
412
- else if(wpvivid_check_onedrive_storage_alias(name) === -1){
413
- alert(wpvividlion.remoteexist);
414
- }
415
- else {
416
- location.href = '<?php echo admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_auth&name='?>' + name + '&default=' + remote_default;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  }
418
- }
419
- </script>
420
- <?php
421
  }
422
 
423
  public function wpvivid_edit_storage_page_one_drive()
@@ -444,7 +443,7 @@ class WPvivid_one_drive extends WPvivid_Remote
444
  <tr>
445
  <td class="plugin-title column-primary">
446
  <div class="wpvivid-storage-form">
447
- <input onclick="wpvivid_one_drive_update_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Save Changes', 'wpvivid-backuprestore'); ?>">
448
  </div>
449
  </td>
450
  <td class="column-description desc">
@@ -1251,4 +1250,72 @@ class WPvivid_one_drive extends WPvivid_Remote
1251
  }
1252
  return $storage_type;
1253
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1254
  }
35
  {
36
  public $options;
37
  public $callback;
38
+ public $add_remote;
39
  public function __construct($options=array())
40
  {
41
  if(empty($options))
43
  if(!defined('WPVIVID_INIT_STORAGE_TAB_ONE_DRIVE'))
44
  {
45
  add_action('init', array($this, 'handle_auth_actions'));
46
+ //wpvivid_one_drive_add_remote
47
+ add_action('wp_ajax_wpvivid_one_drive_add_remote',array( $this,'finish_add_remote'));
48
+
49
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_one_drive'), 12);
50
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_one_drive'), 12);
51
  add_action('wpvivid_edit_remote_page',array($this,'wpvivid_edit_storage_page_one_drive'), 12);
61
  {
62
  $this->options=$options;
63
  }
64
+ $this->add_remote=false;
65
  }
66
 
67
  public function pre_add_remote($remote,$id)
83
  if($_GET['action']=='wpvivid_one_drive_auth')
84
  {
85
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  $auth_id = uniqid('wpvivid-auth-');
87
+ $remote_options['auth_id']=$auth_id;
88
+ update_option('wpvivid_tmp_remote_options',$remote_options);
89
  $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
90
  . '?client_id=' . urlencode('37668be9-b55f-458f-b6a3-97e6f8aa10c9')
91
  . '&scope=' . urlencode('offline_access files.readwrite')
92
  . '&response_type=code'
93
  . '&redirect_uri=' . urlencode('https://auth.wpvivid.com/onedrive_v2/')
94
+ . '&state=' . urlencode(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_finish_auth&main_tab=storage&sub_tab=one_drive&sub_page=storage_account_one_drive&auth_id='.$auth_id)
95
  . '&display=popup'
96
  . '&locale=en';
97
  header('Location: ' . esc_url_raw($url));
112
  }
113
 
114
  $remoteslist = WPvivid_Setting::get_all_remote_options();
115
+ foreach ($remoteslist as $key => $value)
116
+ {
117
+ if (isset($value['auth_id']) && isset($_GET['auth_id']) && $value['auth_id'] == sanitize_text_field($_GET['auth_id']))
118
+ {
119
  _e('<div class="notice notice-success is-dismissible"><p>You have authenticated the Microsoft OneDrive account as your remote storage.</p></div>');
120
  return;
121
  }
122
  }
123
 
124
+ $tmp_options=get_option('wpvivid_tmp_remote_options',false);
125
+ if($tmp_options===false)
126
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  return;
128
  }
129
+ else
130
+ {
131
+ if($tmp_options['auth_id']===$_GET['auth_id'])
132
+ {
133
+ if(empty($_POST['refresh_token']))
134
+ {
135
+ if(empty($tmp_options['token']['refresh_token']))
136
+ {
137
+ $err = 'No refresh token was received from OneDrive, which means that you entered client secret incorrectly, or that you did not re-authenticated yet after you corrected it. Please authenticate again.';
138
+ header('Location: ' . admin_url() . 'admin.php?page=' . WPVIVID_PLUGIN_SLUG . '&action=wpvivid_one_drive&result=error&resp_msg='.$err);
139
+
140
+ return;
141
+ }
142
+ }
143
+ else
144
+ {
145
+ $tmp_options['type'] = WPVIVID_REMOTE_ONEDRIVE;
146
+ $tmp_options['token']['access_token']=sanitize_text_field($_POST['access_token']);
147
+ $tmp_options['token']['refresh_token']=sanitize_text_field($_POST['refresh_token']);
148
+ $tmp_options['token']['expires']=time()+$_POST['expires_in'];
149
+ update_option('wpvivid_tmp_remote_options',$tmp_options);
150
+ }
151
+ $this->add_remote=true;
152
  }
153
+ else
154
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  return;
156
  }
157
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
159
  catch (Exception $e){
160
  echo '<div class="notice notice-error"><p>'.$e->getMessage().'</p></div>';
161
  }
162
  }
163
+ else if($_GET['action']=='wpvivid_one_drive')
164
  {
165
  try {
166
  if (isset($_GET['result'])) {
167
  if ($_GET['result'] == 'success') {
168
+ add_action('show_notice', array($this, 'wpvivid_show_notice_add_onedrive_success'));
169
  } else if ($_GET['result'] == 'error') {
170
+ add_action('show_notice', array($this, 'wpvivid_show_notice_add_onedrive_error'));
171
  }
172
  }
173
  }
186
  $wpvivid_plugin->wpvivid_handle_remote_storage_error($_GET['resp_msg'], 'Add OneDrive Remote');
187
  echo '<div class="notice notice-error"><p>'.esc_html($_GET['resp_msg']).'</p></div>';
188
  }
 
 
 
 
 
 
 
 
189
 
190
  public function wpvivid_add_storage_tab_one_drive()
191
  {
200
  {
201
  global $wpvivid_plugin;
202
  $root_path=apply_filters('wpvivid_get_root_path', WPVIVID_REMOTE_ONEDRIVE);
203
+ if($this->add_remote)
204
+ {
205
+ ?>
206
+ <div id="storage_account_one_drive" class="storage-account-page" style="display:none;">
207
+ <div style="background-color:#f1f1f1; padding: 10px;">
208
+ <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Microsoft OneDrive authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
209
+ </div>
210
+ <div style="color:#8bc34a; padding: 10px 10px 10px 0;">
211
+ <strong>Authentication is done, please continue to enter the storge information, then click 'Add Now' button to save it.</strong>
212
+ </div>
213
+ <div style="padding: 10px 10px 10px 0;">
214
+ <strong><?php _e('Enter Your Microsoft OneDrive Information', 'wpvivid-backuprestore'); ?></strong>
215
+ </div>
216
+ <table class="wp-list-table widefat plugins" style="width:100%;">
217
+ <tbody>
218
+ <tr>
219
+ <td class="plugin-title column-primary">
220
+ <div class="wpvivid-storage-form">
221
+ <input type="text" class="regular-text" autocomplete="off" option="one_drive" name="name" placeholder="<?php esc_attr_e('Enter a unique alias: e.g. OneDrive-001', 'wpvivid-backuprestore'); ?>" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
222
+ </div>
223
+ </td>
224
+ <td class="column-description desc">
225
+ <div class="wpvivid-storage-form-desc">
226
+ <i><?php _e('A name to help you identify the storage if you have multiple remote storage connected.', 'wpvivid-backuprestore'); ?></i>
227
+ </div>
228
+ </td>
229
+ </tr>
230
+ <tr>
231
+ <td class="plugin-title column-primary">
232
+ <div class="wpvivid-storage-form">
233
+ <input type="text" class="regular-text" autocomplete="off" option="one_drive" name="path" value="<?php esc_attr_e($root_path.WPVIVID_ONEDRIVE_DEFAULT_FOLDER); ?>" readonly="readonly" />
234
+ </div>
235
+ </td>
236
+ <td class="column-description desc">
237
+ <div class="wpvivid-storage-form-desc">
238
+ <i><?php _e('All backups will be uploaded to this directory.', 'wpvivid-backuprestore'); ?></i>
239
+ </div>
240
+ </td>
241
+ </tr>
242
+ <tr>
243
+ <td class="plugin-title column-primary">
244
+ <div class="wpvivid-storage-form">
245
+ <input type="text" class="regular-text" autocomplete="off" value="mywebsite01" readonly="readonly" />
246
+ </div>
247
+ </td>
248
+ <td class="column-description desc">
249
+ <div class="wpvivid-storage-form-desc">
250
+ <a href="https://docs.wpvivid.com/wpvivid-backup-pro-microsoft-onedrive-custom-folder-name.html"><?php _e('Pro feature: Create a directory for storing the backups of the site', 'wpvivid-backuprestore'); ?></a>
251
+ </div>
252
+ </td>
253
+ </tr>
254
+ <tr>
255
+ <td class="plugin-title column-primary">
256
+ <div class="wpvivid-storage-select">
257
+ <label>
258
+ <input type="checkbox" option="one_drive" name="default" checked /><?php _e('Set as the default remote storage.', 'wpvivid-backuprestore'); ?>
259
+ </label>
260
+ </div>
261
+ </td>
262
+ <td class="column-description desc">
263
+ <div class="wpvivid-storage-form-desc">
264
+ <i><?php _e('Once checked, all this sites backups sent to a remote storage destination will be uploaded to this storage by default.', 'wpvivid-backuprestore'); ?></i>
265
+ </div>
266
+ </td>
267
+ </tr>
268
+ <tr>
269
+ <td class="plugin-title column-primary">
270
+ <div class="wpvivid-storage-form">
271
+ <input id="wpvivid_one_drive_auth" class="button-primary" type="submit" value="<?php esc_attr_e('Add Now', 'wpvivid-backuprestore'); ?>">
272
+ </div>
273
+ </td>
274
+ <td class="column-description desc">
275
+ <div class="wpvivid-storage-form-desc">
276
+ <i><?php _e('Click the button to add the storage.', 'wpvivid-backuprestore'); ?></i>
277
+ </div>
278
+ </td>
279
+ </tr>
280
+ </tbody>
281
+ </table>
282
  </div>
283
+ <script>
284
+ function wpvivid_check_onedrive_storage_alias(storage_alias)
285
+ {
286
+ var find = 1;
287
+ jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
288
+ jQuery(this).children('td').each(function (j) {
289
+ if (j == 3) {
290
+ if (jQuery(this).text() == storage_alias) {
291
+ find = -1;
292
+ return false;
293
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  }
295
+ });
296
  });
297
+ return find;
298
+ }
299
+
300
+ jQuery('#wpvivid_one_drive_auth').click(function()
301
+ {
302
+ wpvivid_one_drive_auth();
303
  });
304
+
305
+ function wpvivid_one_drive_auth()
 
 
 
 
 
 
306
  {
307
+ wpvivid_settings_changed = false;
308
+ var name='';
309
+ var path='';
310
+ jQuery('input:text[option=one_drive]').each(function()
311
  {
312
+ var key = jQuery(this).prop('name');
313
+ if(key==='name')
314
+ {
315
+ name = jQuery(this).val();
316
+ }
317
+ });
318
 
319
+ var remote_default='0';
320
 
321
+ jQuery('input:checkbox[option=one_drive]').each(function()
322
+ {
323
+ if(jQuery(this).prop('checked')) {
324
+ remote_default='1';
325
+ }
326
+ else {
327
+ remote_default='0';
328
+ }
329
+ });
330
+ if(name == ''){
331
+ alert(wpvividlion.remotealias);
332
+ }
333
+ else if(wpvivid_check_onedrive_storage_alias(name) === -1){
334
+ alert(wpvividlion.remoteexist);
335
  }
336
  else {
337
+ var ajax_data;
338
+ var remote_from = wpvivid_ajax_data_transfer('one_drive');
339
+ ajax_data = {
340
+ 'action': 'wpvivid_one_drive_add_remote',
341
+ 'remote': remote_from
342
+ };
343
+ jQuery('#wpvivid_one_drive_auth').css({'pointer-events': 'none', 'opacity': '0.4'});
344
+ jQuery('#wpvivid_remote_notice').html('');
345
+ wpvivid_post_request(ajax_data, function (data)
346
+ {
347
+ try
348
+ {
349
+ var jsonarray = jQuery.parseJSON(data);
350
+ if (jsonarray.result === 'success')
351
+ {
352
+ jQuery('#wpvivid_one_drive_auth').css({'pointer-events': 'auto', 'opacity': '1'});
353
+ jQuery('input:text[option=one_drive]').each(function(){
354
+ jQuery(this).val('');
355
+ });
356
+ jQuery('input:password[option=one_drive]').each(function(){
357
+ jQuery(this).val('');
358
+ });
359
+ wpvivid_handle_remote_storage_data(data);
360
+ location.href='admin.php?page=WPvivid&action=wpvivid_one_drive&main_tab=storage&sub_tab=one_drive&sub_page=storage_account_one_drive&result=success';
361
+ }
362
+ else if (jsonarray.result === 'failed')
363
+ {
364
+ jQuery('#wpvivid_remote_notice').html(jsonarray.notice);
365
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
366
+ }
367
+ }
368
+ catch (err)
369
+ {
370
+ alert(err);
371
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
372
+ }
373
+
374
+ }, function (XMLHttpRequest, textStatus, errorThrown)
375
+ {
376
+ var error_message = wpvivid_output_ajaxerror('adding the remote storage', textStatus, errorThrown);
377
+ alert(error_message);
378
+ jQuery('#wpvivid_one_drive_auth').css({'pointer-events': 'auto', 'opacity': '1'});
379
+ });
380
  }
 
 
 
381
  }
382
+ </script>
383
+ <?php
384
+ }
385
+ else
386
+ {
387
+ ?>
388
+ <div id="storage_account_one_drive" class="storage-account-page" style="display:none;">
389
+ <div style="background-color:#f1f1f1; padding: 10px;">
390
+ <?php _e('Please read <a target="_blank" href="https://wpvivid.com/privacy-policy" style="text-decoration: none;">this privacy policy</a> for use of our Microsoft OneDrive authorization app (none of your backup data is sent to us).', 'wpvivid-backuprestore'); ?>
391
+ </div>
392
+ <div style="padding: 10px 10px 10px 0;">
393
+ <strong><?php _e('To add OneDrive, please get Microsoft authentication first. Once authenticated, you will be redirected to this page, then you can add storage information and save it', 'wpvivid-backuprestore'); ?></strong>
394
+ </div>
395
+ <table class="wp-list-table widefat plugins" style="width:100%;">
396
+ <tbody>
397
+ <tr>
398
+ <td class="plugin-title column-primary">
399
+ <div class="wpvivid-storage-form">
400
+ <input onclick="wpvivid_one_drive_auth();" class="button-primary" type="submit" value="<?php esc_attr_e('Authenticate with Microsoft OneDrive', 'wpvivid-backuprestore'); ?>">
401
+ </div>
402
+ </td>
403
+ <td class="column-description desc">
404
+ <div class="wpvivid-storage-form-desc">
405
+ <i><?php _e('Click to get Microsoft authentication.', 'wpvivid-backuprestore'); ?></i>
406
+ </div>
407
+ </td>
408
+ </tr>
409
+ </tbody>
410
+ </table>
411
+ </div>
412
+ <script>
413
+ function wpvivid_one_drive_auth()
414
+ {
415
+ location.href = '<?php echo admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_auth'?>';
416
  }
417
+ </script>
418
+ <?php
419
+ }
420
  }
421
 
422
  public function wpvivid_edit_storage_page_one_drive()
443
  <tr>
444
  <td class="plugin-title column-primary">
445
  <div class="wpvivid-storage-form">
446
+ <input class="button-primary" type="submit" option="edit-remote" value="<?php esc_attr_e('Save Changes', 'wpvivid-backuprestore'); ?>">
447
  </div>
448
  </td>
449
  <td class="column-description desc">
1250
  }
1251
  return $storage_type;
1252
  }
1253
+
1254
+ public function finish_add_remote()
1255
+ {
1256
+ global $wpvivid_plugin;
1257
+ $wpvivid_plugin->ajax_check_security();
1258
+ try {
1259
+ if (empty($_POST) || !isset($_POST['remote']) || !is_string($_POST['remote'])) {
1260
+ die();
1261
+ }
1262
+
1263
+ $tmp_remote_options =get_option('wpvivid_tmp_remote_options',array());
1264
+ delete_option('wpvivid_tmp_remote_options');
1265
+ if(empty($tmp_remote_options)||$tmp_remote_options['type']!==WPVIVID_REMOTE_ONEDRIVE)
1266
+ {
1267
+ die();
1268
+ }
1269
+
1270
+ $json = $_POST['remote'];
1271
+ $json = stripslashes($json);
1272
+ $remote_options = json_decode($json, true);
1273
+ if (is_null($remote_options)) {
1274
+ die();
1275
+ }
1276
+
1277
+ $remote_options['path'] = WPVIVID_ONEDRIVE_DEFAULT_FOLDER;
1278
+ $remote_options=array_merge($remote_options,$tmp_remote_options);
1279
+
1280
+ $ret = $wpvivid_plugin->remote_collection->add_remote($remote_options);
1281
+
1282
+ if ($ret['result'] == 'success') {
1283
+ $html = '';
1284
+ $html = apply_filters('wpvivid_add_remote_storage_list', $html);
1285
+ $ret['html'] = $html;
1286
+ $pic = '';
1287
+ $pic = apply_filters('wpvivid_schedule_add_remote_pic', $pic);
1288
+ $ret['pic'] = $pic;
1289
+ $dir = '';
1290
+ $dir = apply_filters('wpvivid_get_remote_directory', $dir);
1291
+ $ret['dir'] = $dir;
1292
+ $schedule_local_remote = '';
1293
+ $schedule_local_remote = apply_filters('wpvivid_schedule_local_remote', $schedule_local_remote);
1294
+ $ret['local_remote'] = $schedule_local_remote;
1295
+ $remote_storage = '';
1296
+ $remote_storage = apply_filters('wpvivid_remote_storage', $remote_storage);
1297
+ $ret['remote_storage'] = $remote_storage;
1298
+ $remote_select_part = '';
1299
+ $remote_select_part = apply_filters('wpvivid_remote_storage_select_part', $remote_select_part);
1300
+ $ret['remote_select_part'] = $remote_select_part;
1301
+ $default = array();
1302
+ $remote_array = apply_filters('wpvivid_archieve_remote_array', $default);
1303
+ $ret['remote_array'] = $remote_array;
1304
+ $success_msg = __('You have successfully added a remote storage.', 'wpvivid-backuprestore');
1305
+ $ret['notice'] = apply_filters('wpvivid_add_remote_notice', true, $success_msg);
1306
+ }
1307
+ else{
1308
+ $ret['notice'] = apply_filters('wpvivid_add_remote_notice', false, $ret['error']);
1309
+ }
1310
+
1311
+ }
1312
+ catch (Exception $error) {
1313
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
1314
+ error_log($message);
1315
+ echo json_encode(array('result'=>'failed','error'=>$message));
1316
+ die();
1317
+ }
1318
+ echo json_encode($ret);
1319
+ die();
1320
+ }
1321
  }
includes/customclass/class-wpvivid-s3compat.php CHANGED
@@ -751,7 +751,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
751
  }
752
  private function compare_php_version(){
753
  if(version_compare(WPVIVID_GOOGLE_NEED_PHP_VERSION,phpversion()) > 0){
754
- return array('result' => WPVIVID_FAILED,error => 'The required PHP version is higher than '.WPVIVID_S3COMPAT_NEED_PHP_VERSION.'. After updating your PHP version, please try again.');
755
  }
756
  return array('result' => WPVIVID_SUCCESS);
757
  }
751
  }
752
  private function compare_php_version(){
753
  if(version_compare(WPVIVID_GOOGLE_NEED_PHP_VERSION,phpversion()) > 0){
754
+ return array('result' => WPVIVID_FAILED,'error' => 'The required PHP version is higher than '.WPVIVID_S3COMPAT_NEED_PHP_VERSION.'. After updating your PHP version, please try again.');
755
  }
756
  return array('result' => WPVIVID_SUCCESS);
757
  }
includes/lib/google-api-php-client/src/Google/Client.php CHANGED
@@ -1062,7 +1062,8 @@ class Google_Client
1062
  }
1063
  } else {
1064
  // guzzle 6
1065
- $options['base_uri'] = $this->config['base_path'];
 
1066
  }
1067
 
1068
  return new Client($options);
1062
  }
1063
  } else {
1064
  // guzzle 6
1065
+ $options['base_uri'] = $this->config['base_path'];
1066
+ $options['verify'] = WPVIVID_PLUGIN_DIR.'/vendor/guzzle/guzzle/src/Guzzle/Http/Resources/cacert.pem';
1067
  }
1068
 
1069
  return new Client($options);
includes/staging/class-wpvivid-staging-log-page.php CHANGED
@@ -453,7 +453,7 @@ class WPvivid_Staging_Log_Page_Free
453
 
454
  public function get_staging_log_list($ret)
455
  {
456
- $html=$ret['html'];
457
  $loglist=$this->get_log_list('staging');
458
  $current_num=1;
459
  $max_log_diaplay=20;
@@ -473,7 +473,7 @@ class WPvivid_Staging_Log_Page_Free
473
  }
474
  else{
475
  $offset=get_option('gmt_offset');
476
- $localtime = strtotime($value['time']) + $offset * 60 * 60;
477
  $value['time'] = date('F-d-Y H:i:s',$localtime);
478
  }
479
  if (empty($value['des'])) {
453
 
454
  public function get_staging_log_list($ret)
455
  {
456
+ $html='';//$ret['html'];
457
  $loglist=$this->get_log_list('staging');
458
  $current_num=1;
459
  $max_log_diaplay=20;
473
  }
474
  else{
475
  $offset=get_option('gmt_offset');
476
+ $localtime = strtotime($value['time'])/* + $offset * 60 * 60*/;
477
  $value['time'] = date('F-d-Y H:i:s',$localtime);
478
  }
479
  if (empty($value['des'])) {
includes/staging/class-wpvivid-staging-log.php CHANGED
@@ -30,7 +30,8 @@ class WPvivid_Staging_Log_Free
30
  @unlink( $this->log_file);
31
  }
32
  $this->log_file_handle = fopen($this->log_file, 'a');
33
- $time =date("Y-m-d H:i:s",time());
 
34
  $text='Log created: '.$time."\n";
35
  $text.='Type: '.$describe."\n";
36
  fwrite($this->log_file_handle,$text);
@@ -61,7 +62,8 @@ class WPvivid_Staging_Log_Free
61
  {
62
  if ($this->log_file_handle)
63
  {
64
- $time =date("Y-m-d H:i:s",time());
 
65
  $text='['.$time.']'.'['.$type.']'.$log."\n";
66
  fwrite($this->log_file_handle,$text );
67
  }
@@ -157,7 +159,8 @@ class WPvivid_Staging_Log_Free
157
  $log.=' is_multisite:0';
158
  }
159
 
160
- $time =date("Y-m-d H:i:s",time());
 
161
  $text='['.$time.']'.'[notice]'.$log."\n";
162
  fwrite($this->log_file_handle,$text );
163
  }
30
  @unlink( $this->log_file);
31
  }
32
  $this->log_file_handle = fopen($this->log_file, 'a');
33
+ $offset=get_option('gmt_offset');
34
+ $time =date("Y-m-d H:i:s",time()+$offset*60*60);
35
  $text='Log created: '.$time."\n";
36
  $text.='Type: '.$describe."\n";
37
  fwrite($this->log_file_handle,$text);
62
  {
63
  if ($this->log_file_handle)
64
  {
65
+ $offset=get_option('gmt_offset');
66
+ $time =date("Y-m-d H:i:s",time()+$offset*60*60);
67
  $text='['.$time.']'.'['.$type.']'.$log."\n";
68
  fwrite($this->log_file_handle,$text );
69
  }
159
  $log.=' is_multisite:0';
160
  }
161
 
162
+ $offset=get_option('gmt_offset');
163
+ $time =date("Y-m-d H:i:s",time()+$offset*60*60);
164
  $text='['.$time.']'.'[notice]'.$log."\n";
165
  fwrite($this->log_file_handle,$text );
166
  }
includes/staging/class-wpvivid-staging-setting.php CHANGED
@@ -149,7 +149,7 @@ class WPvivid_Staging_Setting_Free
149
  <div class="wpvivid-element-space-bottom"><strong><?php _e('Delay Between Requests', 'wpvivid'); ?></strong></div>
150
  <div class="wpvivid-element-space-bottom">
151
  <input type="text" class="all-options" option="setting" name="staging_request_timeout" value="<?php esc_attr_e($staging_request_timeout); ?>"
152
- placeholder="1000" onkeyup="value=value.replace(/\D/g,'')" />ms
153
  </div>
154
  <div class="wpvivid-element-space-bottom">
155
  <?php _e( 'A lower value will help speed up the process of creating a staging site. However, if your server has a limit on the number of requests, a higher value is recommended.', 'wpvivid' ); ?>
@@ -328,7 +328,7 @@ class WPvivid_Staging_Setting_Free
328
  <div class="wpvivid-element-space-bottom"><strong><?php _e('Delay Between Requests', 'wpvivid'); ?></strong></div>
329
  <div class="wpvivid-element-space-bottom">
330
  <input type="text" class="all-options" option="setting" name="staging_request_timeout" value="<?php esc_attr_e($staging_request_timeout); ?>"
331
- placeholder="1000" onkeyup="value=value.replace(/\D/g,'')" />ms
332
  </div>
333
  <div class="wpvivid-element-space-bottom">
334
  <?php _e( 'A lower value will help speed up the process of creating a staging site. However, if your server has a limit on the number of requests, a higher value is recommended.', 'wpvivid' ); ?>
149
  <div class="wpvivid-element-space-bottom"><strong><?php _e('Delay Between Requests', 'wpvivid'); ?></strong></div>
150
  <div class="wpvivid-element-space-bottom">
151
  <input type="text" class="all-options" option="setting" name="staging_request_timeout" value="<?php esc_attr_e($staging_request_timeout); ?>"
152
+ placeholder="1500" onkeyup="value=value.replace(/\D/g,'')" />ms
153
  </div>
154
  <div class="wpvivid-element-space-bottom">
155
  <?php _e( 'A lower value will help speed up the process of creating a staging site. However, if your server has a limit on the number of requests, a higher value is recommended.', 'wpvivid' ); ?>
328
  <div class="wpvivid-element-space-bottom"><strong><?php _e('Delay Between Requests', 'wpvivid'); ?></strong></div>
329
  <div class="wpvivid-element-space-bottom">
330
  <input type="text" class="all-options" option="setting" name="staging_request_timeout" value="<?php esc_attr_e($staging_request_timeout); ?>"
331
+ placeholder="1500" onkeyup="value=value.replace(/\D/g,'')" />ms
332
  </div>
333
  <div class="wpvivid-element-space-bottom">
334
  <?php _e( 'A lower value will help speed up the process of creating a staging site. However, if your server has a limit on the number of requests, a higher value is recommended.', 'wpvivid' ); ?>
includes/staging/class-wpvivid-staging.php CHANGED
@@ -160,10 +160,10 @@ class WPvivid_Staging_Free
160
  public function load_ajax()
161
  {
162
  add_action('wp_ajax_wpvividstg_start_staging_free', array($this, 'start_staging'));
163
- add_action('wp_ajax_nopriv_wpvividstg_start_staging_free', array($this, 'start_staging'));
164
  add_action('wp_ajax_wpvividstg_set_restart_staging_id_free', array($this, 'set_restart_staging_id'));
165
  add_action('wp_ajax_wpvividstg_get_staging_progress_free', array($this, 'get_staging_progress'));
166
- add_action('wp_ajax_nopriv_wpvividstg_get_staging_progress_free', array($this, 'get_staging_progress'));
167
  add_action('wp_ajax_wpvividstg_delete_site_free', array($this, 'delete_site'));
168
  add_action('wp_ajax_wpvividstg_delete_cancel_staging_site_free', array($this, 'delete_cancel_staging_site'));
169
  add_action('wp_ajax_wpvividstg_check_staging_dir_free', array($this, 'check_staging_dir'));
160
  public function load_ajax()
161
  {
162
  add_action('wp_ajax_wpvividstg_start_staging_free', array($this, 'start_staging'));
163
+ //add_action('wp_ajax_nopriv_wpvividstg_start_staging_free', array($this, 'start_staging'));
164
  add_action('wp_ajax_wpvividstg_set_restart_staging_id_free', array($this, 'set_restart_staging_id'));
165
  add_action('wp_ajax_wpvividstg_get_staging_progress_free', array($this, 'get_staging_progress'));
166
+ //add_action('wp_ajax_nopriv_wpvividstg_get_staging_progress_free', array($this, 'get_staging_progress'));
167
  add_action('wp_ajax_wpvividstg_delete_site_free', array($this, 'delete_site'));
168
  add_action('wp_ajax_wpvividstg_delete_cancel_staging_site_free', array($this, 'delete_cancel_staging_site'));
169
  add_action('wp_ajax_wpvividstg_check_staging_dir_free', array($this, 'check_staging_dir'));
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
  Tested up to: 5.8.2
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.68
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -192,6 +192,14 @@ Thank you for translating WPvivid Backup Plugin to your languages!
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
 
 
 
 
 
 
 
 
195
  = 0.9.68 =
196
  - Fixed: Failed to upload backups to Dropbox in some cases.
197
  - Updated: Changed timezone in email report title to local time.
4
  Requires at least: 4.5
5
  Tested up to: 5.8.2
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.69
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
195
+ = 0.9.69 =
196
+ - Updated: For security reasons, adding Google Drive, Dropbox, OneDrive now needs to get authentication first.
197
+ - Updated: Changed time in a log file to local time.
198
+ - Fixed the curl 60 error that could appear when backing up to Google Drive in some cases.
199
+ - Fixed: Disabling backup splitting did not take effect on PHP 8 sites.
200
+ - Fixed: Uploading backups to Dropbox failed in some cases.
201
+ - Fixed some bugs in the plugin code.
202
+ - Optimized the plugin code.
203
  = 0.9.68 =
204
  - Fixed: Failed to upload backups to Dropbox in some cases.
205
  - Updated: Changed timezone in email report title to local time.
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.68
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.68' );
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.69
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.69' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');