Migration, Backup, Staging – WPvivid - Version 0.9.30

Version Description

  • Added an option to select database accessing method for a backup or restore process.
  • Optimized plugin code and set the autoload attribute to no.
  • Improved the success rate of backing up the uploads folder when the optimization mode for web hosting/shared hosting is enabled.
  • Fixed some bugs in plugin code.
Download this release

Release Info

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

Code changes from version 0.9.29 to 0.9.30

admin/class-wpvivid-admin.php CHANGED
@@ -99,6 +99,7 @@ class WPvivid_Admin {
99
  $menu['title']='Backup & Restore';
100
  $menu['tab']='admin.php?page=WPvivid&tab-backup';
101
  $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-backup';
 
102
  $menu['index']=1;
103
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
104
 
@@ -271,7 +272,7 @@ class WPvivid_Admin {
271
  function add_toolbar_items($wp_admin_bar)
272
  {
273
  global $wpvivid_plugin;
274
- if(is_admin() && current_user_can('administrator'))
275
  {
276
  $show_admin_bar = $wpvivid_plugin->get_admin_bar_setting();
277
  if ($show_admin_bar === true)
@@ -296,12 +297,14 @@ class WPvivid_Admin {
296
  return -1;
297
  });
298
  foreach ($menu['child'] as $child_menu) {
299
- $wp_admin_bar->add_menu(array(
300
- 'id' => $child_menu['id'],
301
- 'parent' => $menu['id'],
302
- 'title' => $child_menu['title'],
303
- 'href' => $child_menu['href']
304
- ));
 
 
305
  }
306
  }
307
  }
@@ -517,6 +520,8 @@ class WPvivid_Admin {
517
 
518
  public function check_extensions()
519
  {
 
 
520
  $need_php_extensions = array();
521
  $need_extensions_count = 0;
522
  $extensions=get_loaded_extensions();
@@ -533,7 +538,7 @@ class WPvivid_Admin {
533
  $need_php_extensions[$need_extensions_count] = 'zlib';
534
  $need_extensions_count++;
535
  }
536
- if(!array_search('pdo_mysql',$extensions))
537
  {
538
  $need_php_extensions[$need_extensions_count] = 'pdo_mysql';
539
  $need_extensions_count++;
99
  $menu['title']='Backup & Restore';
100
  $menu['tab']='admin.php?page=WPvivid&tab-backup';
101
  $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-backup';
102
+ $menu['capability']='administrator';
103
  $menu['index']=1;
104
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
105
 
272
  function add_toolbar_items($wp_admin_bar)
273
  {
274
  global $wpvivid_plugin;
275
+ if(is_admin())
276
  {
277
  $show_admin_bar = $wpvivid_plugin->get_admin_bar_setting();
278
  if ($show_admin_bar === true)
297
  return -1;
298
  });
299
  foreach ($menu['child'] as $child_menu) {
300
+ if(isset($child_menu['capability']) && current_user_can($child_menu['capability'])) {
301
+ $wp_admin_bar->add_menu(array(
302
+ 'id' => $child_menu['id'],
303
+ 'parent' => $menu['id'],
304
+ 'title' => $child_menu['title'],
305
+ 'href' => $child_menu['href']
306
+ ));
307
+ }
308
  }
309
  }
310
  }
520
 
521
  public function check_extensions()
522
  {
523
+ $common_setting = WPvivid_Setting::get_setting(false, 'wpvivid_common_setting');
524
+ $db_connect_method = isset($common_setting['options']['wpvivid_common_setting']['db_connect_method']) ? $common_setting['options']['wpvivid_common_setting']['db_connect_method'] : 'wpdb';
525
  $need_php_extensions = array();
526
  $need_extensions_count = 0;
527
  $extensions=get_loaded_extensions();
538
  $need_php_extensions[$need_extensions_count] = 'zlib';
539
  $need_extensions_count++;
540
  }
541
+ if(!array_search('pdo_mysql',$extensions) && $db_connect_method === 'pdo')
542
  {
543
  $need_php_extensions[$need_extensions_count] = 'pdo_mysql';
544
  $need_extensions_count++;
admin/css/wpvivid-admin.css CHANGED
@@ -9,7 +9,7 @@
9
  .quickbackup{width:calc(100% - 290px);float:left; box-sizing:border-box;margin-right:10px; padding:10px;}
10
  .quickbackup label{display:inline-block;margin-bottom:10px;}
11
  .qucikbackup-schedule{width:280px; float:left; box-sizing:border-box; min-width:280px;}
12
- .quickstart-archive-block{width:33%;padding:10px; float:left; position:relative; box-sizing:border-box; }
13
  .quickstart-storage-block{width:33%;padding:10px; float:left; position:relative; box-sizing:border-box;}
14
  .quickstart-btn{width:33%;padding:10px; float:left; position:relative; box-sizing:border-box;}
15
  .quickbackup-btn{display:block !important; margin:0 auto !important;width:150px;height:50px !important; line-height:48px !important; font-size:20px !important;}
9
  .quickbackup{width:calc(100% - 290px);float:left; box-sizing:border-box;margin-right:10px; padding:10px;}
10
  .quickbackup label{display:inline-block;margin-bottom:10px;}
11
  .qucikbackup-schedule{width:280px; float:left; box-sizing:border-box; min-width:280px;}
12
+ .quickstart-archive-block{width:33%;float:left; position:relative; box-sizing:border-box; }
13
  .quickstart-storage-block{width:33%;padding:10px; float:left; position:relative; box-sizing:border-box;}
14
  .quickstart-btn{width:33%;padding:10px; float:left; position:relative; box-sizing:border-box;}
15
  .quickbackup-btn{display:block !important; margin:0 auto !important;width:150px;height:50px !important; line-height:48px !important; font-size:20px !important;}
admin/partials/wpvivid-backup-restore-page-display.php CHANGED
@@ -1271,7 +1271,7 @@ function wpvivid_backuppage_add_page_restore(){
1271
  wpvivid_restore_unlock();
1272
  wpvivid_restoring = false;
1273
  jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
1274
- alert(jsonarray.error);
1275
  }
1276
  else {
1277
  setTimeout(function () {
1271
  wpvivid_restore_unlock();
1272
  wpvivid_restoring = false;
1273
  jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
1274
+ alert("Restore failed.");
1275
  }
1276
  else {
1277
  setTimeout(function () {
admin/partials/wpvivid-schedule-page-display.php CHANGED
@@ -98,7 +98,10 @@ function wpvivid_schedule_settings()
98
 
99
  function wpvivid_schedule_notice($html)
100
  {
101
- $html='<p>1) Scheduled job will start at web server time: </p>';
 
 
 
102
  $html.='<p>2) Being subjected to mechanisms of PHP, a scheduled backup task for your site will be triggered only when the site receives at least a visit at any page.</p>';
103
  return $html;
104
  }
98
 
99
  function wpvivid_schedule_notice($html)
100
  {
101
+ $offset=get_option('gmt_offset');
102
+ $time = '00:00:00';
103
+ $utime = strtotime($time) + $offset * 60 * 60;
104
+ $html='<p>1) Scheduled job will start at utc time: '.date('H:i:s', $utime).'</p>';
105
  $html.='<p>2) Being subjected to mechanisms of PHP, a scheduled backup task for your site will be triggered only when the site receives at least a visit at any page.</p>';
106
  return $html;
107
  }
admin/partials/wpvivid-settings-page-display.php CHANGED
@@ -206,7 +206,7 @@ function wpvivid_email_report()
206
  <input type="text" placeholder="example@yourdomain.com" option="setting" name="send_to" class="regular-text" id="wpvivid_mail" value="<?php
207
  if(!empty($general_setting['options']['wpvivid_email_setting']['send_to'])) {
208
  foreach ($general_setting['options']['wpvivid_email_setting']['send_to'] as $mail) {
209
- if(!empty($mail)) {
210
  _e($mail, 'wpvivid');
211
  break;
212
  }
@@ -512,6 +512,20 @@ function wpvivid_advanced_settings()
512
  if(!isset($general_setting['options']['wpvivid_common_setting']['migrate_size'])){
513
  $general_setting['options']['wpvivid_common_setting']['migrate_size']=WPVIVID_MIGRATE_SIZE;
514
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  ?>
516
  <div class="postbox schedule-tab-block setting-page-content">
517
  <div>
@@ -527,6 +541,23 @@ function wpvivid_advanced_settings()
527
  </div>
528
  </div>
529
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
  <div class="postbox schedule-tab-block setting-page-content">
531
  <fieldset>
532
  <label>
206
  <input type="text" placeholder="example@yourdomain.com" option="setting" name="send_to" class="regular-text" id="wpvivid_mail" value="<?php
207
  if(!empty($general_setting['options']['wpvivid_email_setting']['send_to'])) {
208
  foreach ($general_setting['options']['wpvivid_email_setting']['send_to'] as $mail) {
209
+ if(!empty($mail) && !is_array($mail)) {
210
  _e($mail, 'wpvivid');
211
  break;
212
  }
512
  if(!isset($general_setting['options']['wpvivid_common_setting']['migrate_size'])){
513
  $general_setting['options']['wpvivid_common_setting']['migrate_size']=WPVIVID_MIGRATE_SIZE;
514
  }
515
+ if(isset($general_setting['options']['wpvivid_common_setting']['db_connect_method'])){
516
+ if($general_setting['options']['wpvivid_common_setting']['db_connect_method'] === 'wpdb'){
517
+ $db_method_wpdb = 'checked';
518
+ $db_method_pdo = '';
519
+ }
520
+ else{
521
+ $db_method_wpdb = '';
522
+ $db_method_pdo = 'checked';
523
+ }
524
+ }
525
+ else{
526
+ $db_method_wpdb = 'checked';
527
+ $db_method_pdo = '';
528
+ }
529
  ?>
530
  <div class="postbox schedule-tab-block setting-page-content">
531
  <div>
541
  </div>
542
  </div>
543
  </div>
544
+ <div class="postbox schedule-tab-block wpvivid-setting-addon" style="margin-bottom: 10px; padding-bottom: 0;">
545
+ <div class="wpvivid-element-space-bottom">
546
+ <strong><?php _e('Database access method.', 'wpvivid'); ?></strong>
547
+ </div>
548
+ <div class="wpvivid-element-space-bottom">
549
+ <label>
550
+ <input type="radio" option="setting" name="db_connect_method" value="wpdb" <?php esc_attr_e($db_method_wpdb); ?> />
551
+ <span><strong>WPDB</strong></span><span><?php _e('WPDB option has a better compatibility, but the speed of backup and restore is slower.', 'wpvivid'); ?></span>
552
+ </label>
553
+ </div>
554
+ <div class="wpvivid-element-space-bottom">
555
+ <label>
556
+ <input type="radio" option="setting" name="db_connect_method" value="pdo" <?php esc_attr_e($db_method_pdo); ?> />
557
+ <span><strong>PDO</strong></span><span><?php _e('It is recommended to choose PDO option if pdo_mysql extension is installed on your server, which lets you backup and restore your site faster.', 'wpvivid'); ?></span>
558
+ </label>
559
+ </div>
560
+ </div>
561
  <div class="postbox schedule-tab-block setting-page-content">
562
  <fieldset>
563
  <label>
includes/class-wpvivid-backup-database.php CHANGED
@@ -108,7 +108,7 @@ class WPvivid_Backup_Database
108
  } else {
109
  $prefix = $wpdb->get_blog_prefix(0);
110
  }
111
- $exclude = array('/^(?!' . $prefix . ')/');
112
  return $exclude;
113
  }
114
  }
108
  } else {
109
  $prefix = $wpdb->get_blog_prefix(0);
110
  }
111
+ $exclude = array('/^(?!' . $prefix . ')/i');
112
  return $exclude;
113
  }
114
  }
includes/class-wpvivid-backup.php CHANGED
@@ -22,7 +22,7 @@ define('WPVIVID_BACKUP_ROOT_WP_ROOT','root');
22
 
23
  class WPvivid_Backup_Task
24
  {
25
- private $task;
26
 
27
  public $backup_type_collect;
28
 
@@ -228,6 +228,7 @@ class WPvivid_Backup_Task
228
  {
229
  $this->task['options']['backup_options'] = apply_filters('wpvivid_set_backup_type', $this->task['options']['backup_options'],$options);
230
  }
 
231
  $this->task['data']['doing']='backup';
232
  $this->task['data']['backup']['doing']='';
233
  $this->task['data']['backup']['finished']=0;
@@ -248,7 +249,7 @@ class WPvivid_Backup_Task
248
  return $ret;
249
  }
250
 
251
- private function parse_url_all($url)
252
  {
253
  $parse = parse_url($url);
254
  $path=str_replace('/','_',$parse['path']);
@@ -273,6 +274,7 @@ class WPvivid_Backup_Task
273
  $backup_data['dump_db']=1;
274
  $backup_data['sql_file_name']=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->task['options']['backup_options']['dir'].DIRECTORY_SEPARATOR.$this->get_prefix().'_backup_db.sql';
275
  $backup_data['json_info']['dump_db']=1;
 
276
  $backup_data['json_info']['file_type']='databases';
277
  $backup_data['prefix']=$this->get_prefix().'_backup_db';
278
  }
@@ -2232,29 +2234,31 @@ class WPvivid_Backup
2232
  {
2233
  global $wpvivid_plugin;
2234
  $wpvivid_plugin->wpvivid_log->WriteLog('Start compressing '.$data['key'],'notice');
2235
- if(isset($data['plugin_subpackage']))
2236
- {
2237
- $ret =$zip->get_plugin_packages($data);
2238
- }
2239
- else if(isset($data['uploads_subpackage']))
2240
- {
2241
- $ret =$zip->get_upload_packages($data);
2242
- }
2243
- else
2244
- {
2245
- if($data['key']==WPVIVID_BACKUP_TYPE_MERGE)
2246
- $ret =$zip->get_packages($data,true);
2247
- else
2248
- $ret =$zip->get_packages($data);
2249
- }
2250
 
2251
  $packages=$this->task->get_packages_info($data['key']);
2252
  if($packages===false)
2253
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2254
  $packages=$this->task->set_packages_info($data['key'],$ret['packages']);
2255
  }
2256
 
2257
- define(PCLZIP_TEMPORARY_DIR,$ret['temp_dir']);
 
2258
 
2259
  $result['result']=WPVIVID_SUCCESS;
2260
  $result['files']=array();
@@ -2263,9 +2267,29 @@ class WPvivid_Backup
2263
  $wpvivid_plugin->set_time_limit($this->task->get_id());
2264
  if(!empty($package['files'])&&$package['backup']==false)
2265
  {
2266
- $zip_ret=$zip->_zip($package['path'],$package['files'], $data,$package['json']);
 
 
 
 
 
 
 
 
 
 
 
 
2267
  if($zip_ret['result']==WPVIVID_SUCCESS)
2268
  {
 
 
 
 
 
 
 
 
2269
  $result['files'][] = $zip_ret['file_data'];
2270
  $package['backup']=true;
2271
  $this->task->update_packages_info($data['key'],$package,$zip_ret['file_data']);
22
 
23
  class WPvivid_Backup_Task
24
  {
25
+ protected $task;
26
 
27
  public $backup_type_collect;
28
 
228
  {
229
  $this->task['options']['backup_options'] = apply_filters('wpvivid_set_backup_type', $this->task['options']['backup_options'],$options);
230
  }
231
+
232
  $this->task['data']['doing']='backup';
233
  $this->task['data']['backup']['doing']='';
234
  $this->task['data']['backup']['finished']=0;
249
  return $ret;
250
  }
251
 
252
+ protected function parse_url_all($url)
253
  {
254
  $parse = parse_url($url);
255
  $path=str_replace('/','_',$parse['path']);
274
  $backup_data['dump_db']=1;
275
  $backup_data['sql_file_name']=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->task['options']['backup_options']['dir'].DIRECTORY_SEPARATOR.$this->get_prefix().'_backup_db.sql';
276
  $backup_data['json_info']['dump_db']=1;
277
+ $backup_data['json_info']['home_url']=home_url();
278
  $backup_data['json_info']['file_type']='databases';
279
  $backup_data['prefix']=$this->get_prefix().'_backup_db';
280
  }
2234
  {
2235
  global $wpvivid_plugin;
2236
  $wpvivid_plugin->wpvivid_log->WriteLog('Start compressing '.$data['key'],'notice');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2237
 
2238
  $packages=$this->task->get_packages_info($data['key']);
2239
  if($packages===false)
2240
  {
2241
+ if(isset($data['plugin_subpackage']))
2242
+ {
2243
+ $ret =$zip->get_plugin_packages($data);
2244
+ }
2245
+ else if(isset($data['uploads_subpackage']))
2246
+ {
2247
+ $ret =$zip->get_upload_packages($data);
2248
+ }
2249
+ else
2250
+ {
2251
+ if($data['key']==WPVIVID_BACKUP_TYPE_MERGE)
2252
+ $ret =$zip->get_packages($data,true);
2253
+ else
2254
+ $ret =$zip->get_packages($data);
2255
+ }
2256
+
2257
  $packages=$this->task->set_packages_info($data['key'],$ret['packages']);
2258
  }
2259
 
2260
+ $temp_dir = $data['path'].'temp-'.$data['prefix'].DIRECTORY_SEPARATOR;
2261
+ define(PCLZIP_TEMPORARY_DIR,$temp_dir);
2262
 
2263
  $result['result']=WPVIVID_SUCCESS;
2264
  $result['files']=array();
2267
  $wpvivid_plugin->set_time_limit($this->task->get_id());
2268
  if(!empty($package['files'])&&$package['backup']==false)
2269
  {
2270
+ if(isset($data['uploads_subpackage']))
2271
+ {
2272
+ $files=$zip->get_upload_files_from_cache($package['files']);
2273
+ }
2274
+ else
2275
+ {
2276
+ $files=$package['files'];
2277
+ }
2278
+
2279
+ if(empty($files))
2280
+ continue;
2281
+
2282
+ $zip_ret=$zip->_zip($package['path'],$files, $data,$package['json']);
2283
  if($zip_ret['result']==WPVIVID_SUCCESS)
2284
  {
2285
+ if(isset($data['uploads_subpackage']))
2286
+ {
2287
+ if(file_exists($package['files']))
2288
+ {
2289
+ @unlink($package['files']);
2290
+ }
2291
+ }
2292
+
2293
  $result['files'][] = $zip_ret['file_data'];
2294
  $package['backup']=true;
2295
  $this->task->update_packages_info($data['key'],$package,$zip_ret['file_data']);
includes/class-wpvivid-db-method.php CHANGED
@@ -1,10 +1,4 @@
1
  <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: alienware`x
5
- * Date: 2019/6/10
6
- * Time: 13:04
7
- */
8
 
9
  class WPvivid_DB_Method
10
  {
@@ -13,43 +7,42 @@ class WPvivid_DB_Method
13
 
14
  public function connect_db()
15
  {
16
- $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
17
- if($client_flags)
18
- {
19
  global $wpdb;
20
  $this->db_handle=$wpdb;
21
  $this->type='wpdb';
22
-
23
  return array('result'=>WPVIVID_SUCCESS);
24
  }
25
-
26
- if(class_exists('PDO'))
27
- {
28
- $extensions=get_loaded_extensions();
29
- if(array_search('pdo_mysql',$extensions))
30
- {
31
- $res = explode(':',DB_HOST);
32
- $db_host = $res[0];
33
- $db_port = empty($res[1])?'':$res[1];
34
-
35
- if(!empty($db_port)) {
36
- $dsn='mysql:host=' . $db_host . ';port=' . $db_port . ';dbname=' . DB_NAME;
 
 
 
 
 
 
 
37
  }
38
  else{
39
- $dsn='mysql:host=' . $db_host . ';dbname=' . DB_NAME;
40
  }
41
-
42
- $this->db_handle=new PDO($dsn, DB_USER, DB_PASSWORD);
43
-
44
- $this->type='pdo_mysql';
45
- return array('result'=>WPVIVID_SUCCESS);
46
  }
47
  }
48
- global $wpdb;
49
- $this->db_handle=$wpdb;
50
- $this->type='wpdb';
51
-
52
- return array('result'=>WPVIVID_SUCCESS);
53
  }
54
 
55
  public function check_db($fcgi)
1
  <?php
 
 
 
 
 
 
2
 
3
  class WPvivid_DB_Method
4
  {
7
 
8
  public function connect_db()
9
  {
10
+ $common_setting = WPvivid_Setting::get_setting(false, 'wpvivid_common_setting');
11
+ $db_connect_method = isset($common_setting['options']['wpvivid_common_setting']['db_connect_method']) ? $common_setting['options']['wpvivid_common_setting']['db_connect_method'] : 'wpdb';
12
+ if($db_connect_method === 'wpdb'){
13
  global $wpdb;
14
  $this->db_handle=$wpdb;
15
  $this->type='wpdb';
 
16
  return array('result'=>WPVIVID_SUCCESS);
17
  }
18
+ else{
19
+ if(class_exists('PDO')) {
20
+ $extensions=get_loaded_extensions();
21
+ if(array_search('pdo_mysql',$extensions)) {
22
+ $res = explode(':',DB_HOST);
23
+ $db_host = $res[0];
24
+ $db_port = empty($res[1])?'':$res[1];
25
+
26
+ if(!empty($db_port)) {
27
+ $dsn='mysql:host=' . $db_host . ';port=' . $db_port . ';dbname=' . DB_NAME;
28
+ }
29
+ else{
30
+ $dsn='mysql:host=' . $db_host . ';dbname=' . DB_NAME;
31
+ }
32
+
33
+ $this->db_handle=new PDO($dsn, DB_USER, DB_PASSWORD);
34
+
35
+ $this->type='pdo_mysql';
36
+ return array('result'=>WPVIVID_SUCCESS);
37
  }
38
  else{
39
+ return array('result'=>WPVIVID_FAILED, 'error'=>'The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.');
40
  }
41
+ }
42
+ else{
43
+ return array('result'=>WPVIVID_FAILED, 'error'=>'The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.');
 
 
44
  }
45
  }
 
 
 
 
 
46
  }
47
 
48
  public function check_db($fcgi)
includes/class-wpvivid-export-import.php CHANGED
@@ -65,6 +65,7 @@ class WPvivid_Export_Import
65
  $menu['title']='Export & Import';
66
  $menu['tab']= 'admin.php?page=wpvivid-export-import';
67
  $menu['href']=$admin_url . 'admin.php?page=wpvivid-export-import';
 
68
  $menu['index']=3;
69
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
70
  return $toolbar_menus;
@@ -86,21 +87,22 @@ class WPvivid_Export_Import
86
  public function init_page()
87
  {
88
  ?>
89
- <div class="wrap">
90
  <h1><?php
91
  $plugin_display_name = 'WPvivid Backup Plugin';
92
  $plugin_display_name = apply_filters('wpvivid_display_pro_name', $plugin_display_name);
93
  _e($plugin_display_name);
94
  ?></h1>
95
  <div id="wpvivid_export_notice"></div>
 
 
 
 
 
 
 
96
  </div>
97
-
98
  <?php
99
- $args['is_parent_tab']=1;
100
- $this->main_tab=new WPvivid_Tab_Page_Container();
101
- $this->main_tab->add_tab('Export','export',array($this, 'output_export'), $args);
102
- $this->main_tab->add_tab('Import','import',array($this, 'output_import'), $args);
103
- $this->main_tab->display();
104
  }
105
 
106
  //export
@@ -110,10 +112,10 @@ class WPvivid_Export_Import
110
  ?>
111
  <div class="postbox export-import-block">
112
  <div>
113
- <div class="wpvivid-element-space-bottom wpvivid-element-space-right" style="float: left;">
114
  <img src="<?php echo esc_url(WPVIVID_PLUGIN_IMAGES_URL.'export-import.png'); ?>" style="width:50px;height:50px;">
115
  </div>
116
- <div style="float: left; box-sizing: border-box;">
117
  <div class="wpvivid-text-space-bottom">Export posts or pages with images in bulk.
118
  <span class="wpvivid-feature-pro">
119
  <a href="https://wpvivid.com/export-content" target="_blank" style="text-decoration: none;">Learn more</a>
@@ -818,7 +820,7 @@ class WPvivid_Export_Import
818
  $list_cache[$id]['checked']=$checked;
819
  }
820
  }
821
- update_option('wpvivid_list_cache',$list_cache);
822
 
823
  $post_count=0;
824
 
@@ -953,7 +955,7 @@ class WPvivid_Export_Import
953
  $post_id['checked']=0;
954
  $list_cache[$id]=$post_id;
955
  }
956
- update_option('wpvivid_list_cache',$list_cache);
957
  $page=1;
958
 
959
  $arg['screen']=$post_type;
@@ -996,7 +998,7 @@ class WPvivid_Export_Import
996
 
997
  $list_cache=get_option('wpvivid_list_cache',array());
998
 
999
- update_option('wpvivid_list_cache',$list_cache);
1000
 
1001
  $page=$_POST['page'];
1002
 
@@ -1376,7 +1378,7 @@ class WPvivid_Export_Import
1376
  }
1377
  }
1378
  unset($list[$id]);
1379
- update_option('wpvivid_import_list_cache',$list);
1380
  $ret['result']='success';
1381
  }
1382
  else
@@ -1459,15 +1461,15 @@ class WPvivid_Export_Import
1459
  public function output_import()
1460
  {
1461
  $import_dir = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_IMPORT_EXPORT_DIR;
1462
- update_option('wpvivid_import_list_cache',array());
1463
- update_option('wpvivid_importer_task_list', array());
1464
  ?>
1465
  <div class="postbox export-import-block">
1466
  <div>
1467
- <div class="wpvivid-element-space-bottom wpvivid-element-space-right" style="float: left;">
1468
  <img src="<?php echo esc_url(WPVIVID_PLUGIN_IMAGES_URL.'export-import.png'); ?>" style="width:50px;height:50px;">
1469
  </div>
1470
- <div style="box-sizing: border-box;">
1471
  <div class="wpvivid-element-space-bottom wpvivid-element-space-right">Import posts or pages with images in bulk.
1472
  <span class="wpvivid-feature-pro">
1473
  <a href="https://wpvivid.com/import-content" target="_blank" style="text-decoration: none;">Learn more</a>
@@ -2368,7 +2370,7 @@ class WPvivid_Export_Import
2368
  }
2369
 
2370
  $data = array();
2371
- update_option('wpvivid_import_list_cache', $data);
2372
  $page=1;
2373
  $display_list=new WPvivid_Export_List();
2374
  $display_list->set_parent('wpvivid_import_list');
@@ -2446,7 +2448,7 @@ class WPvivid_Export_Import
2446
  $ret['result']=WPVIVID_FAILED;
2447
  $ret['error']='Failed to get local storage directory.';
2448
  }
2449
- update_option('wpvivid_import_list_cache', $data);
2450
  $page=1;
2451
  $display_list=new WPvivid_Export_List();
2452
  $display_list->set_parent('wpvivid_import_list');
65
  $menu['title']='Export & Import';
66
  $menu['tab']= 'admin.php?page=wpvivid-export-import';
67
  $menu['href']=$admin_url . 'admin.php?page=wpvivid-export-import';
68
+ $menu['capability']='administrator';
69
  $menu['index']=3;
70
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
71
  return $toolbar_menus;
87
  public function init_page()
88
  {
89
  ?>
90
+ <div class="wrap" style="max-width:1720px;">
91
  <h1><?php
92
  $plugin_display_name = 'WPvivid Backup Plugin';
93
  $plugin_display_name = apply_filters('wpvivid_display_pro_name', $plugin_display_name);
94
  _e($plugin_display_name);
95
  ?></h1>
96
  <div id="wpvivid_export_notice"></div>
97
+ <?php
98
+ $args['is_parent_tab']=1;
99
+ $this->main_tab=new WPvivid_Tab_Page_Container();
100
+ $this->main_tab->add_tab('Export','export',array($this, 'output_export'), $args);
101
+ $this->main_tab->add_tab('Import','import',array($this, 'output_import'), $args);
102
+ $this->main_tab->display();
103
+ ?>
104
  </div>
 
105
  <?php
 
 
 
 
 
106
  }
107
 
108
  //export
112
  ?>
113
  <div class="postbox export-import-block">
114
  <div>
115
+ <div class="wpvivid-element-space-bottom wpvivid-element-space-right" style="float: left; width: 50px;">
116
  <img src="<?php echo esc_url(WPVIVID_PLUGIN_IMAGES_URL.'export-import.png'); ?>" style="width:50px;height:50px;">
117
  </div>
118
+ <div style="box-sizing: border-box; margin-left: 60px;">
119
  <div class="wpvivid-text-space-bottom">Export posts or pages with images in bulk.
120
  <span class="wpvivid-feature-pro">
121
  <a href="https://wpvivid.com/export-content" target="_blank" style="text-decoration: none;">Learn more</a>
820
  $list_cache[$id]['checked']=$checked;
821
  }
822
  }
823
+ WPvivid_Setting::update_option('wpvivid_list_cache',$list_cache);
824
 
825
  $post_count=0;
826
 
955
  $post_id['checked']=0;
956
  $list_cache[$id]=$post_id;
957
  }
958
+ WPvivid_Setting::update_option('wpvivid_list_cache',$list_cache);
959
  $page=1;
960
 
961
  $arg['screen']=$post_type;
998
 
999
  $list_cache=get_option('wpvivid_list_cache',array());
1000
 
1001
+ WPvivid_Setting::update_option('wpvivid_list_cache',$list_cache);
1002
 
1003
  $page=$_POST['page'];
1004
 
1378
  }
1379
  }
1380
  unset($list[$id]);
1381
+ WPvivid_Setting::update_option('wpvivid_import_list_cache',$list);
1382
  $ret['result']='success';
1383
  }
1384
  else
1461
  public function output_import()
1462
  {
1463
  $import_dir = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_IMPORT_EXPORT_DIR;
1464
+ WPvivid_Setting::update_option('wpvivid_import_list_cache',array());
1465
+ WPvivid_Setting::update_option('wpvivid_importer_task_list', array());
1466
  ?>
1467
  <div class="postbox export-import-block">
1468
  <div>
1469
+ <div class="wpvivid-element-space-bottom wpvivid-element-space-right" style="float: left; width: 50px;">
1470
  <img src="<?php echo esc_url(WPVIVID_PLUGIN_IMAGES_URL.'export-import.png'); ?>" style="width:50px;height:50px;">
1471
  </div>
1472
+ <div style="box-sizing: border-box; margin-left: 60px;">
1473
  <div class="wpvivid-element-space-bottom wpvivid-element-space-right">Import posts or pages with images in bulk.
1474
  <span class="wpvivid-feature-pro">
1475
  <a href="https://wpvivid.com/import-content" target="_blank" style="text-decoration: none;">Learn more</a>
2370
  }
2371
 
2372
  $data = array();
2373
+ WPvivid_Setting::update_option('wpvivid_import_list_cache', $data);
2374
  $page=1;
2375
  $display_list=new WPvivid_Export_List();
2376
  $display_list->set_parent('wpvivid_import_list');
2448
  $ret['result']=WPVIVID_FAILED;
2449
  $ret['error']='Failed to get local storage directory.';
2450
  }
2451
+ WPvivid_Setting::update_option('wpvivid_import_list_cache', $data);
2452
  $page=1;
2453
  $display_list=new WPvivid_Export_List();
2454
  $display_list->set_parent('wpvivid_import_list');
includes/class-wpvivid-exporter.php CHANGED
@@ -566,8 +566,8 @@ class WPvivid_Post_List extends WP_List_Table
566
  $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
567
  } else {
568
  $html_current_page = sprintf(
569
- "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
570
- '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
571
  $current,
572
  strlen( $total_pages )
573
  );
@@ -665,7 +665,7 @@ class WPvivid_Exporter_taskmanager
665
  $default = array();
666
  $options = get_option('wpvivid_exporter_task_list', $default);
667
  $options[$task_id]=$task;
668
- update_option('wpvivid_exporter_task_list',$options);
669
  }
670
 
671
  public static function get_tasks()
@@ -692,7 +692,7 @@ class WPvivid_Exporter_taskmanager
692
  {
693
  $options = get_option('wpvivid_exporter_task_list', array());
694
  unset($options[$task_id]);
695
- update_option('wpvivid_exporter_task_list',$options);
696
  }
697
 
698
  public static function update_backup_task_status($task_id,$reset_start_time=false,$status='',$reset_timeout=false,$resume_count=false,$error='')
@@ -1261,7 +1261,7 @@ class WPvivid_Exporter_task
1261
  $backup_data['id']=$this->task['id'];
1262
  $list = get_option('wpvivid_export_list',array());
1263
  $list[$this->task['id']]=$backup_data;
1264
- update_option('wpvivid_export_list',$list);
1265
  }
1266
  }
1267
 
566
  $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
567
  } else {
568
  $html_current_page = sprintf(
569
+ "%s<input class='current-page' id='current-page-selector-export' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
570
+ '<label for="current-page-selector-export" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
571
  $current,
572
  strlen( $total_pages )
573
  );
665
  $default = array();
666
  $options = get_option('wpvivid_exporter_task_list', $default);
667
  $options[$task_id]=$task;
668
+ WPvivid_Setting::update_option('wpvivid_exporter_task_list',$options);
669
  }
670
 
671
  public static function get_tasks()
692
  {
693
  $options = get_option('wpvivid_exporter_task_list', array());
694
  unset($options[$task_id]);
695
+ WPvivid_Setting::update_option('wpvivid_exporter_task_list',$options);
696
  }
697
 
698
  public static function update_backup_task_status($task_id,$reset_start_time=false,$status='',$reset_timeout=false,$resume_count=false,$error='')
1261
  $backup_data['id']=$this->task['id'];
1262
  $list = get_option('wpvivid_export_list',array());
1263
  $list[$this->task['id']]=$backup_data;
1264
+ WPvivid_Setting::update_option('wpvivid_export_list',$list);
1265
  }
1266
  }
1267
 
includes/class-wpvivid-importer.php CHANGED
@@ -322,8 +322,8 @@ class WPvivid_Export_List extends WP_List_Table
322
  $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
323
  } else {
324
  $html_current_page = sprintf(
325
- "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
326
- '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
327
  $current,
328
  strlen( $total_pages )
329
  );
@@ -418,13 +418,13 @@ class WPvivid_Impoter_taskmanager
418
  $default = array();
419
  $options = get_option('wpvivid_importer_task_list', $default);
420
  $options[$task_id]=$task;
421
- update_option('wpvivid_importer_task_list', $options);
422
  }
423
 
424
  public static function delete_task($task_id){
425
  $options = get_option('wpvivid_importer_task_list', array());
426
  unset($options[$task_id]);
427
- update_option('wpvivid_importer_task_list', $options);
428
  }
429
 
430
  public static function get_import_task_status($task_id){
322
  $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
323
  } else {
324
  $html_current_page = sprintf(
325
+ "%s<input class='current-page' id='current-page-selector-import' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
326
+ '<label for="current-page-selector-import" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
327
  $current,
328
  strlen( $total_pages )
329
  );
418
  $default = array();
419
  $options = get_option('wpvivid_importer_task_list', $default);
420
  $options[$task_id]=$task;
421
+ WPvivid_Setting::update_option('wpvivid_importer_task_list', $options);
422
  }
423
 
424
  public static function delete_task($task_id){
425
  $options = get_option('wpvivid_importer_task_list', array());
426
  unset($options[$task_id]);
427
+ WPvivid_Setting::update_option('wpvivid_importer_task_list', $options);
428
  }
429
 
430
  public static function get_import_task_status($task_id){
includes/class-wpvivid-mail-report.php CHANGED
@@ -30,11 +30,12 @@ class WPvivid_mail_report
30
  }
31
 
32
  $headers = array('Content-Type: text/html; charset=UTF-8');
33
- $subject=self::create_subject($task);
34
- //$subject = apply_filters('wpvivid_set_mail_subject_addon', $subject, $option, $task);
35
 
36
- $body=self::create_body($task);
37
- //$body = apply_filters('wpvivid_set_mail_body_addon', $body, $option, $task);
 
 
 
38
 
39
  $task_log=$task['options']['log_file_name'];
40
 
@@ -56,6 +57,8 @@ class WPvivid_mail_report
56
  return true;
57
  }
58
 
 
 
59
  public static function create_subject($task)
60
  {
61
  $status=$task['status']['str'];
30
  }
31
 
32
  $headers = array('Content-Type: text/html; charset=UTF-8');
 
 
33
 
34
+ $subject = '';
35
+ $subject = apply_filters('wpvivid_set_mail_subject', $subject, $task);
36
+
37
+ $body = '';
38
+ $body = apply_filters('wpvivid_set_mail_body', $body, $task);
39
 
40
  $task_log=$task['options']['log_file_name'];
41
 
57
  return true;
58
  }
59
 
60
+
61
+
62
  public static function create_subject($task)
63
  {
64
  $status=$task['status']['str'];
includes/class-wpvivid-migrate.php CHANGED
@@ -342,23 +342,21 @@ class WPvivid_Migrate
342
  $migrate_part_tip = '';
343
  ?>
344
  <div id="migrate-page" class="wrap-tab-content wpvivid_tab_migrate" name="tab-migrate" style="display: none;">
345
- <?php
346
- echo apply_filters('wpvivid_migrate_descript', $migrate_descript);
347
- echo apply_filters('wpvivid_put_transfer_key', $migrate_key);
348
- ?>
349
-
350
- <div style="clear: both;"></div>
351
 
352
- <div style="padding: 0 0 10px 0;">
353
- <div class="postbox" id="wpvivid_upload_backup_percent" style="display: none;">
354
- <div class="action-progress-bar" id="wpvivid_upload_progress_bar">
355
- <div class="action-progress-bar-percent" id="wpvivid_upload_progress_bar_percent" style="height:24px;width:0"></div>
356
- </div>
357
- <div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_upload_current_doing"></p></div>
358
- <div style="clear: both;"></div>
359
- <div>
360
- <div id="wpvivid_transfer_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_transfer_cancel_btn" type="submit" value="<?php esc_attr_e( 'Cancel', 'wpvivid' ); ?>" /></div>
361
- </div>
362
  </div>
363
  </div>
364
 
@@ -516,7 +514,7 @@ class WPvivid_Migrate
516
  $options[$url]['domain']=$domain;
517
 
518
  delete_option('wpvivid_saved_api_token');
519
- update_option('wpvivid_saved_api_token',$options);
520
 
521
  $html='';
522
  $i=0;
@@ -819,7 +817,7 @@ class WPvivid_Migrate
819
  $options['expires']=$expires;
820
  $options['domain']=home_url();
821
 
822
- update_option('wpvivid_api_token',$options);
823
 
824
  $url= $options['domain'];
825
  $url=$url.'?domain='.$options['domain'].'&token='.$options['public_key'].'&expires='.$expires;
@@ -833,7 +831,7 @@ class WPvivid_Migrate
833
  if(empty($options)){
834
  $html .= '<div style="padding: 0 0 10px 0;"><strong>'.__('Please paste the key below.', 'wpvivid').'</strong><a href="#" style="margin-left: 5px; text-decoration: none;" onclick="wpvivid_click_how_to_get_key();">How to get a site key?</a></div>
835
  <div id="wpvivid_how_to_get_key"></div>
836
- <div><textarea type="text" id="wpvivid_transfer_key_text" onKeyUp="wpvivid_check_key(this.value)" style="width: 100%; height: 140px;"/></textarea></div>
837
  <div><input class="button-primary" id="wpvivid_save_url_button" type="submit" value="'.esc_attr( 'Save', 'wpvivid' ).'" onclick="wpvivid_click_save_site_url();" /></div>';
838
  }
839
  else{
@@ -852,13 +850,13 @@ class WPvivid_Migrate
852
  $key_status = 'The key will expire in: '.date("H:i:s",$time_diff).'. Once the key expires, you need to generate a new key.';
853
  }
854
  }
855
- $html .= '<div style="padding: 10px 0 10px 0;">
856
  <span>Key:</span>
857
  <input type="text" id="wpvivid_send_remote_site_url_text" value="'.$token.'" readonly="readonly" />
858
  <input class="button-primary" id="wpvivid_delete_key_button" type="submit" value="'.esc_attr( 'Delete', 'wpvivid' ).'" onclick="wpvivid_click_delete_transfer_key();" />
859
  </div>
860
- <p>'.$key_status.'</p>
861
- <p>The connection is ok. Now you can transfer the site <strong>'.$source_dir.'</strong> to the site <strong>'.$target_dir.'</strong></p>';
862
  }
863
  $html.='</div>
864
  <script>
@@ -975,7 +973,9 @@ class WPvivid_Migrate
975
  $migrate_type = '';
976
  $type_name = 'transfer_type';
977
  $html = '<div class="postbox quicktransfer">
978
- <h2><span>'.__( 'Choose the content you want to transfer', 'wpvivid').'</span></h2>
 
 
979
  <div class="quickstart-archive-block">
980
  <fieldset>
981
  <legend class="screen-reader-text"><span>input type="radio"</span></legend>
342
  $migrate_part_tip = '';
343
  ?>
344
  <div id="migrate-page" class="wrap-tab-content wpvivid_tab_migrate" name="tab-migrate" style="display: none;">
345
+ <div class="postbox wpvivid-element-space-bottom" style="padding: 10px;">
346
+ <?php
347
+ echo apply_filters('wpvivid_migrate_descript', $migrate_descript);
348
+ echo apply_filters('wpvivid_put_transfer_key', $migrate_key);
349
+ ?>
350
+ </div>
351
 
352
+ <div class="postbox wpvivid-element-space-bottom" id="wpvivid_upload_backup_percent" style="display: none;">
353
+ <div class="action-progress-bar" id="wpvivid_upload_progress_bar">
354
+ <div class="action-progress-bar-percent" id="wpvivid_upload_progress_bar_percent" style="height:24px;width:0"></div>
355
+ </div>
356
+ <div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_upload_current_doing"></p></div>
357
+ <div style="clear: both;"></div>
358
+ <div>
359
+ <div id="wpvivid_transfer_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_transfer_cancel_btn" type="submit" value="<?php esc_attr_e( 'Cancel', 'wpvivid' ); ?>" /></div>
 
 
360
  </div>
361
  </div>
362
 
514
  $options[$url]['domain']=$domain;
515
 
516
  delete_option('wpvivid_saved_api_token');
517
+ WPvivid_Setting::update_option('wpvivid_saved_api_token',$options);
518
 
519
  $html='';
520
  $i=0;
817
  $options['expires']=$expires;
818
  $options['domain']=home_url();
819
 
820
+ WPvivid_Setting::update_option('wpvivid_api_token',$options);
821
 
822
  $url= $options['domain'];
823
  $url=$url.'?domain='.$options['domain'].'&token='.$options['public_key'].'&expires='.$expires;
831
  if(empty($options)){
832
  $html .= '<div style="padding: 0 0 10px 0;"><strong>'.__('Please paste the key below.', 'wpvivid').'</strong><a href="#" style="margin-left: 5px; text-decoration: none;" onclick="wpvivid_click_how_to_get_key();">How to get a site key?</a></div>
833
  <div id="wpvivid_how_to_get_key"></div>
834
+ <div class="wpvivid-element-space-bottom"><textarea type="text" id="wpvivid_transfer_key_text" onKeyUp="wpvivid_check_key(this.value)" style="width: 100%; height: 140px;"/></textarea></div>
835
  <div><input class="button-primary" id="wpvivid_save_url_button" type="submit" value="'.esc_attr( 'Save', 'wpvivid' ).'" onclick="wpvivid_click_save_site_url();" /></div>';
836
  }
837
  else{
850
  $key_status = 'The key will expire in: '.date("H:i:s",$time_diff).'. Once the key expires, you need to generate a new key.';
851
  }
852
  }
853
+ $html .= '<div style="padding: 0 0 10px 0;">
854
  <span>Key:</span>
855
  <input type="text" id="wpvivid_send_remote_site_url_text" value="'.$token.'" readonly="readonly" />
856
  <input class="button-primary" id="wpvivid_delete_key_button" type="submit" value="'.esc_attr( 'Delete', 'wpvivid' ).'" onclick="wpvivid_click_delete_transfer_key();" />
857
  </div>
858
+ <div class="wpvivid-element-space-bottom">'.$key_status.'</div>
859
+ <div>The connection is ok. Now you can transfer the site <strong>'.$source_dir.'</strong> to the site <strong>'.$target_dir.'</strong></div>';
860
  }
861
  $html.='</div>
862
  <script>
973
  $migrate_type = '';
974
  $type_name = 'transfer_type';
975
  $html = '<div class="postbox quicktransfer">
976
+ <div class="wpvivid-element-space-bottom">
977
+ <h2 style="padding: 0;"><span>'.__( 'Choose the content you want to transfer', 'wpvivid').'</span></h2>
978
+ </div>
979
  <div class="quickstart-archive-block">
980
  <fieldset>
981
  <legend class="screen-reader-text"><span>input type="radio"</span></legend>
includes/class-wpvivid-mysqldump-method.php CHANGED
@@ -188,6 +188,9 @@ abstract class TypeAdapterFactory
188
  {
189
  $c = ucfirst(strtolower($c));
190
  if (! TypeAdapter::isValid($c)) {
 
 
 
191
  throw new Exception("Database type support for ($c) not yet available");
192
  }
193
  $method = __NAMESPACE__ . "\\" . "TypeAdapter" . $c;
@@ -1582,5 +1585,6 @@ class TypeAdapterWpdb extends TypeAdapterFactory
1582
 
1583
  public function closeCursor($resultSet)
1584
  {
 
1585
  }
1586
  }
188
  {
189
  $c = ucfirst(strtolower($c));
190
  if (! TypeAdapter::isValid($c)) {
191
+ if($c === 'Mysql'){
192
+ $c = 'PDO_MySQL';
193
+ }
194
  throw new Exception("Database type support for ($c) not yet available");
195
  }
196
  $method = __NAMESPACE__ . "\\" . "TypeAdapter" . $c;
1585
 
1586
  public function closeCursor($resultSet)
1587
  {
1588
+ $this->dbHandler->flush();
1589
  }
1590
  }
includes/class-wpvivid-mysqldump.php CHANGED
@@ -121,7 +121,7 @@ class WPvivid_Mysqldump
121
  'net_buffer_length' => self::MAXLINESIZE,
122
  'no-autocommit' => true,
123
  'no-create-info' => false,
124
- 'lock-tables' => true,
125
  'routines' => false,
126
  'single-transaction' => true,
127
  'skip-triggers' => false,
@@ -172,22 +172,14 @@ class WPvivid_Mysqldump
172
 
173
  public function get_db_type()
174
  {
175
- $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
176
- if($client_flags)
177
- {
178
  return 'wpdb';
179
  }
180
-
181
- if(class_exists('PDO'))
182
- {
183
- $extensions=get_loaded_extensions();
184
- if(array_search('pdo_mysql',$extensions))
185
- {
186
- return 'mysql';
187
- }
188
  }
189
-
190
- return 'wpdb';
191
  }
192
 
193
  /**
@@ -994,108 +986,219 @@ class WPvivid_Mysqldump
994
  global $wpdb;
995
  $prefix=$wpdb->base_prefix;
996
 
997
- if(substr($tableName, strlen($prefix))=='options')
998
  {
999
- $stmt = "SELECT " . implode(",", $colStmt) . " FROM `$tableName` WHERE option_name !='wpvivid_task_list'";
1000
- }
1001
- else
1002
- {
1003
- $stmt = "SELECT " . implode(",", $colStmt) . " FROM `$tableName`";
1004
- }
 
 
 
 
 
1005
 
 
 
 
1006
 
 
 
 
1007
 
1008
- if ($this->dumpSettings['where']) {
1009
- $stmt .= " WHERE {$this->dumpSettings['where']}";
1010
- }
1011
 
1012
- $resultSet = $this->query($stmt);
 
1013
 
1014
- if($resultSet===false)
1015
- {
1016
- global $wpvivid_plugin;
1017
- $error=$this->typeAdapter->errorInfo();
1018
- if(isset($error[2])){
1019
- $error = 'Error: '.$error[2];
1020
- }
1021
- else{
1022
- $error = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1023
  }
1024
 
1025
- $message='listValues failed. '.$error;
1026
- $wpvivid_plugin->wpvivid_log->WriteLog($message, 'warning');
 
1027
 
1028
  $this->endListValues($tableName);
1029
- return ;
1030
  }
1031
-
1032
- $i=0;
1033
- $i_check_cancel=0;
1034
- $count=0;
1035
- foreach ($resultSet as $row)
1036
  {
1037
- $i++;
1038
- $vals = $this->escape($tableName, $row);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1039
 
1040
- foreach($vals as $key => $value){
1041
- if($value === '\'0000-00-00 00:00:00\'')
1042
- $vals[$key] = '\'1999-01-01 00:00:00\'';
1043
  }
1044
 
1045
- if ($onlyOnce || !$this->dumpSettings['extended-insert'])
 
 
 
1046
  {
 
 
1047
 
1048
- if ($this->dumpSettings['complete-insert'])
 
 
 
 
 
1049
  {
1050
- $lineSize += $this->compressManager->write(
1051
- "INSERT INTO `$tableName` (" .
1052
- implode(", ", $colStmt) .
1053
- ") VALUES (" . implode(",", $vals) . ")"
1054
- );
 
 
 
 
 
 
 
 
 
1055
  } else {
1056
- $lineSize += $this->compressManager->write(
1057
- "INSERT INTO `$tableName` VALUES (" . implode(",", $vals) . ")"
1058
- );
1059
  }
1060
- $onlyOnce = false;
1061
- } else {
1062
- $lineSize += $this->compressManager->write(",(" . implode(",", $vals) . ")");
1063
- }
1064
- if (($lineSize > $this->dumpSettings['net_buffer_length']) ||
1065
  !$this->dumpSettings['extended-insert']) {
1066
- $onlyOnce = true;
1067
- $lineSize = $this->compressManager->write(";" . PHP_EOL);
1068
- }
1069
 
1070
- if($i>=200000)
1071
- {
1072
- $count+=$i;
1073
- $i=0;
1074
- if($this->task_id!=='')
1075
  {
1076
- $i_check_cancel++;
1077
- if($i_check_cancel>5)
 
1078
  {
1079
- $i_check_cancel=0;
1080
- global $wpvivid_plugin;
1081
- $wpvivid_plugin->check_cancel_backup($this->task_id);
 
 
 
 
 
 
1082
  }
1083
- $message='Dumping table '.$tableName.', rows dumped: '.$count.' rows.';
1084
- WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_DB,0,$message);
1085
  }
1086
  }
1087
- }
1088
-
1089
- $this->typeAdapter->closeCursor($resultSet);
1090
- //$resultSet->closeCursor();
1091
-
1092
- if (!$onlyOnce) {
1093
- $this->compressManager->write(";" . PHP_EOL);
1094
- }
1095
 
 
 
1096
 
 
 
 
1097
 
1098
- $this->endListValues($tableName);
 
1099
  }
1100
 
1101
  /**
@@ -1123,6 +1226,7 @@ class WPvivid_Mysqldump
1123
  if ($this->dumpSettings['lock-tables'])
1124
  {
1125
  $this->typeAdapter->lock_table($tableName);
 
1126
  //if($this -> privileges['LOCK TABLES'] == 0)
1127
  //{
1128
  //global $wpvivid_plugin;
121
  'net_buffer_length' => self::MAXLINESIZE,
122
  'no-autocommit' => true,
123
  'no-create-info' => false,
124
+ 'lock-tables' => false,
125
  'routines' => false,
126
  'single-transaction' => true,
127
  'skip-triggers' => false,
172
 
173
  public function get_db_type()
174
  {
175
+ $common_setting = WPvivid_Setting::get_setting(false, 'wpvivid_common_setting');
176
+ $db_connect_method = isset($common_setting['options']['wpvivid_common_setting']['db_connect_method']) ? $common_setting['options']['wpvivid_common_setting']['db_connect_method'] : 'wpdb';
177
+ if($db_connect_method === 'wpdb') {
178
  return 'wpdb';
179
  }
180
+ else{
181
+ return 'mysql';
 
 
 
 
 
 
182
  }
 
 
183
  }
184
 
185
  /**
986
  global $wpdb;
987
  $prefix=$wpdb->base_prefix;
988
 
989
+ if($this->dbType=='wpdb')
990
  {
991
+ $start=0;
992
+ $limit_count=5000;
993
+ $sum =$wpdb->get_var("SELECT COUNT(1) FROM `{$tableName}`");
994
+ if(substr($tableName, strlen($prefix))=='options')
995
+ {
996
+ $stmt = "SELECT " . implode(",", $colStmt) . " FROM `$tableName` WHERE option_name !='wpvivid_task_list'";
997
+ }
998
+ else
999
+ {
1000
+ $stmt = "SELECT " . implode(",", $colStmt) . " FROM `$tableName`";
1001
+ }
1002
 
1003
+ if ($this->dumpSettings['where']) {
1004
+ $stmt .= " WHERE {$this->dumpSettings['where']}";
1005
+ }
1006
 
1007
+ $i=0;
1008
+ $i_check_cancel=0;
1009
+ $count=0;
1010
 
1011
+ while($sum > $start)
1012
+ {
1013
+ $limit = " LIMIT {$limit_count} OFFSET {$start}";
1014
 
1015
+ $query=$stmt.$limit;
1016
+ $resultSet = $this->query($query);
1017
 
1018
+ if($resultSet===false)
1019
+ {
1020
+ global $wpvivid_plugin;
1021
+ $error=$this->typeAdapter->errorInfo();
1022
+ if(isset($error[2])){
1023
+ $error = 'Error: '.$error[2];
1024
+ }
1025
+ else{
1026
+ $error = '';
1027
+ }
1028
+
1029
+ $message='listValues failed. '.$error;
1030
+ $wpvivid_plugin->wpvivid_log->WriteLog($message, 'warning');
1031
+
1032
+ $this->endListValues($tableName);
1033
+ return ;
1034
+ }
1035
+
1036
+ foreach ($resultSet as $row)
1037
+ {
1038
+ $i++;
1039
+ $vals = $this->escape($tableName, $row);
1040
+
1041
+ foreach($vals as $key => $value){
1042
+ if($value === '\'0000-00-00 00:00:00\'')
1043
+ $vals[$key] = '\'1999-01-01 00:00:00\'';
1044
+ }
1045
+
1046
+ if ($onlyOnce || !$this->dumpSettings['extended-insert'])
1047
+ {
1048
+
1049
+ if ($this->dumpSettings['complete-insert'])
1050
+ {
1051
+ $lineSize += $this->compressManager->write(
1052
+ "INSERT INTO `$tableName` (" .
1053
+ implode(", ", $colStmt) .
1054
+ ") VALUES (" . implode(",", $vals) . ")"
1055
+ );
1056
+ } else {
1057
+ $lineSize += $this->compressManager->write(
1058
+ "INSERT INTO `$tableName` VALUES (" . implode(",", $vals) . ")"
1059
+ );
1060
+ }
1061
+ $onlyOnce = false;
1062
+ } else {
1063
+ $lineSize += $this->compressManager->write(",(" . implode(",", $vals) . ")");
1064
+ }
1065
+ if (($lineSize > $this->dumpSettings['net_buffer_length']) ||
1066
+ !$this->dumpSettings['extended-insert']) {
1067
+ $onlyOnce = true;
1068
+ $lineSize = $this->compressManager->write(";" . PHP_EOL);
1069
+ }
1070
+
1071
+ if($i>=200000)
1072
+ {
1073
+ $count+=$i;
1074
+ $i=0;
1075
+ if($this->task_id!=='')
1076
+ {
1077
+ $i_check_cancel++;
1078
+ if($i_check_cancel>5)
1079
+ {
1080
+ $i_check_cancel=0;
1081
+ global $wpvivid_plugin;
1082
+ $wpvivid_plugin->check_cancel_backup($this->task_id);
1083
+ }
1084
+ $message='Dumping table '.$tableName.', rows dumped: '.$count.' rows.';
1085
+ WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_DB,0,$message);
1086
+ }
1087
+ }
1088
+ }
1089
+
1090
+ $this->typeAdapter->closeCursor($resultSet);
1091
+
1092
+ $start += $limit_count;
1093
  }
1094
 
1095
+ if (!$onlyOnce) {
1096
+ $this->compressManager->write(";" . PHP_EOL);
1097
+ }
1098
 
1099
  $this->endListValues($tableName);
 
1100
  }
1101
+ else
 
 
 
 
1102
  {
1103
+ if(substr($tableName, strlen($prefix))=='options')
1104
+ {
1105
+ $stmt = "SELECT " . implode(",", $colStmt) . " FROM `$tableName` WHERE option_name !='wpvivid_task_list'";
1106
+ }
1107
+ else
1108
+ {
1109
+ $stmt = "SELECT " . implode(",", $colStmt) . " FROM `$tableName`";
1110
+ }
1111
+
1112
+ if ($this->dumpSettings['where']) {
1113
+ $stmt .= " WHERE {$this->dumpSettings['where']}";
1114
+ }
1115
+
1116
+ $resultSet = $this->query($stmt);
1117
+
1118
+ if($resultSet===false)
1119
+ {
1120
+ global $wpvivid_plugin;
1121
+ $error=$this->typeAdapter->errorInfo();
1122
+ if(isset($error[2])){
1123
+ $error = 'Error: '.$error[2];
1124
+ }
1125
+ else{
1126
+ $error = '';
1127
+ }
1128
+
1129
+ $message='listValues failed. '.$error;
1130
+ $wpvivid_plugin->wpvivid_log->WriteLog($message, 'warning');
1131
 
1132
+ $this->endListValues($tableName);
1133
+ return ;
 
1134
  }
1135
 
1136
+ $i=0;
1137
+ $i_check_cancel=0;
1138
+ $count=0;
1139
+ foreach ($resultSet as $row)
1140
  {
1141
+ $i++;
1142
+ $vals = $this->escape($tableName, $row);
1143
 
1144
+ foreach($vals as $key => $value){
1145
+ if($value === '\'0000-00-00 00:00:00\'')
1146
+ $vals[$key] = '\'1999-01-01 00:00:00\'';
1147
+ }
1148
+
1149
+ if ($onlyOnce || !$this->dumpSettings['extended-insert'])
1150
  {
1151
+
1152
+ if ($this->dumpSettings['complete-insert'])
1153
+ {
1154
+ $lineSize += $this->compressManager->write(
1155
+ "INSERT INTO `$tableName` (" .
1156
+ implode(", ", $colStmt) .
1157
+ ") VALUES (" . implode(",", $vals) . ")"
1158
+ );
1159
+ } else {
1160
+ $lineSize += $this->compressManager->write(
1161
+ "INSERT INTO `$tableName` VALUES (" . implode(",", $vals) . ")"
1162
+ );
1163
+ }
1164
+ $onlyOnce = false;
1165
  } else {
1166
+ $lineSize += $this->compressManager->write(",(" . implode(",", $vals) . ")");
 
 
1167
  }
1168
+ if (($lineSize > $this->dumpSettings['net_buffer_length']) ||
 
 
 
 
1169
  !$this->dumpSettings['extended-insert']) {
1170
+ $onlyOnce = true;
1171
+ $lineSize = $this->compressManager->write(";" . PHP_EOL);
1172
+ }
1173
 
1174
+ if($i>=200000)
 
 
 
 
1175
  {
1176
+ $count+=$i;
1177
+ $i=0;
1178
+ if($this->task_id!=='')
1179
  {
1180
+ $i_check_cancel++;
1181
+ if($i_check_cancel>5)
1182
+ {
1183
+ $i_check_cancel=0;
1184
+ global $wpvivid_plugin;
1185
+ $wpvivid_plugin->check_cancel_backup($this->task_id);
1186
+ }
1187
+ $message='Dumping table '.$tableName.', rows dumped: '.$count.' rows.';
1188
+ WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_DB,0,$message);
1189
  }
 
 
1190
  }
1191
  }
 
 
 
 
 
 
 
 
1192
 
1193
+ $this->typeAdapter->closeCursor($resultSet);
1194
+ //$resultSet->closeCursor();
1195
 
1196
+ if (!$onlyOnce) {
1197
+ $this->compressManager->write(";" . PHP_EOL);
1198
+ }
1199
 
1200
+ $this->endListValues($tableName);
1201
+ }
1202
  }
1203
 
1204
  /**
1226
  if ($this->dumpSettings['lock-tables'])
1227
  {
1228
  $this->typeAdapter->lock_table($tableName);
1229
+
1230
  //if($this -> privileges['LOCK TABLES'] == 0)
1231
  //{
1232
  //global $wpvivid_plugin;
includes/class-wpvivid-restore-database.php CHANGED
@@ -84,7 +84,7 @@ class WPvivid_RestoreDB
84
 
85
  $this->enable_plugins();
86
  unset($this->db_method);
87
- do_action('wpvivid_restore_database_finish',$options);
88
  }
89
  return $result;
90
  }
@@ -183,6 +183,8 @@ class WPvivid_RestoreDB
183
  $upload_dir = wp_upload_dir();
184
  $this->new_upload_url=untrailingslashit($upload_dir['baseurl']);
185
 
 
 
186
  $result = $wpdb->get_results("SHOW ENGINES", OBJECT_K);
187
  foreach ($result as $key=>$value)
188
  {
@@ -317,10 +319,10 @@ class WPvivid_RestoreDB
317
  }
318
 
319
  WPvivid_Setting::import_json_to_setting($this->current_setting);
 
320
  do_action('wpvivid_reset_schedule');
321
  do_action('wpvivid_do_after_restore_db');
322
 
323
-
324
  fclose($sql_handle);
325
  $ret['result']=WPVIVID_SUCCESS;
326
  return $ret;
@@ -1271,45 +1273,12 @@ class WPvivid_RestoreDB
1271
  return $skip_rows;
1272
  }
1273
 
1274
- /*
1275
- private function check_max_allow_packet()
1276
- {
1277
- //$max_allow_packet
1278
- global $wpvivid_plugin;
1279
- $max_allowed_packet = $this->db->query("SELECT @@session.max_allowed_packet;");
1280
- if($max_allowed_packet)
1281
- {
1282
- $max_allowed_packet = $max_allowed_packet -> fetchAll();
1283
- if(is_array($max_allowed_packet)&&isset($max_allowed_packet[0])&&isset($max_allowed_packet[0][0]))
1284
- {
1285
- if($max_allowed_packet[0][0]<1048576)
1286
- {
1287
- $wpvivid_plugin->restore_data->write_log('warning: max_allowed_packet less than 1M :'.size_format($max_allowed_packet[0][0],2),'notice');
1288
- }
1289
- else if($max_allowed_packet[0][0]<33554432)
1290
- {
1291
- $wpvivid_plugin->restore_data->write_log('max_allowed_packet less than 32M :'.size_format($max_allowed_packet[0][0],2),'notice');
1292
- }
1293
- $this->max_allow_packet=$max_allowed_packet[0][0];
1294
- }
1295
- else
1296
- {
1297
- $wpvivid_plugin->restore_data->write_log('get max_allowed_packet failed ','notice');
1298
- $this->max_allow_packet=1048576;
1299
- }
1300
- }
1301
- else
1302
- {
1303
- $wpvivid_plugin->restore_data->write_log('get max_allowed_packet failed ','notice');
1304
- $this->max_allow_packet=1048576;
1305
- }
1306
- }
1307
- */
1308
  public function check_max_allow_packet_ex()
1309
  {
1310
  $max_all_packet_warning=false;
1311
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore-db-method.php';
1312
  $this->db_method=new WPvivid_Restore_DB_Method();
 
1313
  $this->db_method->set_skip_query(0);
1314
 
1315
  $ret=$this->db_method->connect_db();
84
 
85
  $this->enable_plugins();
86
  unset($this->db_method);
87
+ //do_action('wpvivid_restore_database_finish',$options);
88
  }
89
  return $result;
90
  }
183
  $upload_dir = wp_upload_dir();
184
  $this->new_upload_url=untrailingslashit($upload_dir['baseurl']);
185
 
186
+ $wpdb->query('SET FOREIGN_KEY_CHECKS=0;');
187
+
188
  $result = $wpdb->get_results("SHOW ENGINES", OBJECT_K);
189
  foreach ($result as $key=>$value)
190
  {
319
  }
320
 
321
  WPvivid_Setting::import_json_to_setting($this->current_setting);
322
+
323
  do_action('wpvivid_reset_schedule');
324
  do_action('wpvivid_do_after_restore_db');
325
 
 
326
  fclose($sql_handle);
327
  $ret['result']=WPVIVID_SUCCESS;
328
  return $ret;
1273
  return $skip_rows;
1274
  }
1275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1276
  public function check_max_allow_packet_ex()
1277
  {
1278
  $max_all_packet_warning=false;
1279
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore-db-method.php';
1280
  $this->db_method=new WPvivid_Restore_DB_Method();
1281
+
1282
  $this->db_method->set_skip_query(0);
1283
 
1284
  $ret=$this->db_method->connect_db();
includes/class-wpvivid-restore-db-method.php CHANGED
@@ -11,29 +11,18 @@ class WPvivid_Restore_DB_Method
11
  public function __construct()
12
  {
13
  global $wpvivid_plugin;
14
- $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
15
- if($client_flags)
16
- {
17
  $wpvivid_plugin->restore_data->write_log('wpdb', 'Warning');
18
  $this->db =new WPvivid_Restore_DB_WPDB_Method();
19
  $this->type='wpdb';
20
- return;
21
  }
22
-
23
- if(class_exists('PDO'))
24
- {
25
- $extensions=get_loaded_extensions();
26
- if(array_search('pdo_mysql',$extensions))
27
- {
28
- $wpvivid_plugin->restore_data->write_log('pdo_mysql', 'Warning');
29
- $this->db =new WPvivid_Restore_DB_PDO_Mysql_Method();
30
- $this->type='pdo_mysql';
31
- return;
32
- }
33
  }
34
- $wpvivid_plugin->restore_data->write_log('wpdb', 'Warning');
35
- $this->db =new WPvivid_Restore_DB_WPDB_Method();
36
- $this->type='wpdb';
37
  }
38
 
39
  public function get_type()
11
  public function __construct()
12
  {
13
  global $wpvivid_plugin;
14
+ $common_setting = WPvivid_Setting::get_setting(false, 'wpvivid_common_setting');
15
+ $db_connect_method = isset($common_setting['options']['wpvivid_common_setting']['db_connect_method']) ? $common_setting['options']['wpvivid_common_setting']['db_connect_method'] : 'wpdb';
16
+ if($db_connect_method === 'wpdb'){
17
  $wpvivid_plugin->restore_data->write_log('wpdb', 'Warning');
18
  $this->db =new WPvivid_Restore_DB_WPDB_Method();
19
  $this->type='wpdb';
 
20
  }
21
+ else{
22
+ $wpvivid_plugin->restore_data->write_log('pdo_mysql', 'Warning');
23
+ $this->db =new WPvivid_Restore_DB_PDO_Mysql_Method();
24
+ $this->type='pdo_mysql';
 
 
 
 
 
 
 
25
  }
 
 
 
26
  }
27
 
28
  public function get_type()
includes/class-wpvivid-restore-db-pdo-mysql-method.php CHANGED
@@ -24,8 +24,23 @@ class WPvivid_Restore_DB_PDO_Mysql_Method
24
  $this->db->exec('SET NAMES utf8');
25
  if(empty($this->db) || !$this->db)
26
  {
27
- $ret['result']=WPVIVID_FAILED;
28
- $ret['error']='The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
  else
31
  {
@@ -36,8 +51,23 @@ class WPvivid_Restore_DB_PDO_Mysql_Method
36
  {
37
  if(empty($this->db) || !$this->db)
38
  {
39
- $ret['result']=WPVIVID_FAILED;
40
- $ret['error']='The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
  else
43
  {
24
  $this->db->exec('SET NAMES utf8');
25
  if(empty($this->db) || !$this->db)
26
  {
27
+ if(class_exists('PDO'))
28
+ {
29
+ $extensions=get_loaded_extensions();
30
+ if(array_search('pdo_mysql',$extensions))
31
+ {
32
+ $ret['result']=WPVIVID_FAILED;
33
+ $ret['error']='The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.';
34
+ }
35
+ else{
36
+ $ret['result']=WPVIVID_FAILED;
37
+ $ret['error']='The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.';
38
+ }
39
+ }
40
+ else{
41
+ $ret['result']=WPVIVID_FAILED;
42
+ $ret['error']='The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.';
43
+ }
44
  }
45
  else
46
  {
51
  {
52
  if(empty($this->db) || !$this->db)
53
  {
54
+ if(class_exists('PDO'))
55
+ {
56
+ $extensions=get_loaded_extensions();
57
+ if(array_search('pdo_mysql',$extensions))
58
+ {
59
+ $ret['result']=WPVIVID_FAILED;
60
+ $ret['error']='The error establishing a database connection. Please check wp-config.php file and make sure the information is correct.';
61
+ }
62
+ else{
63
+ $ret['result']=WPVIVID_FAILED;
64
+ $ret['error']='The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.';
65
+ }
66
+ }
67
+ else{
68
+ $ret['result']=WPVIVID_FAILED;
69
+ $ret['error']='The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.';
70
+ }
71
  }
72
  else
73
  {
includes/class-wpvivid-setting.php CHANGED
@@ -229,7 +229,7 @@ class WPvivid_Setting
229
 
230
  public static function update_option($option_name,$options)
231
  {
232
- update_option($option_name,$options);
233
  }
234
 
235
  public static function delete_option($option_name)
@@ -248,7 +248,7 @@ class WPvivid_Setting
248
  $default = array();
249
  $options = get_option('wpvivid_task_list', $default);
250
  $options[$id]=$task;
251
- update_option('wpvivid_task_list',$options);
252
  }
253
 
254
  public static function delete_task($id)
@@ -256,7 +256,7 @@ class WPvivid_Setting
256
  $default = array();
257
  $options = get_option('wpvivid_task_list', $default);
258
  unset($options[$id]);
259
- update_option('wpvivid_task_list',$options);
260
  }
261
 
262
  public static function check_compress_options()
@@ -504,10 +504,12 @@ class WPvivid_Setting
504
  $json['data']['wpvivid_task_list']=self::get_option('wpvivid_task_list');
505
  $json['data']['wpvivid_last_msg']=self::get_option('wpvivid_last_msg');
506
  $json['data']['wpvivid_user_history']=self::get_option('wpvivid_user_history');
 
507
  }
508
 
509
  if($backup_list){
510
  $json['data']['wpvivid_backup_list']=self::get_option('wpvivid_backup_list');
 
511
  }
512
 
513
  if($review)
@@ -515,16 +517,19 @@ class WPvivid_Setting
515
  $json['data']['wpvivid_need_review']=self::get_option('wpvivid_need_review');
516
  $json['data']['cron_backup_count']=self::get_option('cron_backup_count');
517
  $json['data']['wpvivid_review_msg']=self::get_option('wpvivid_review_msg');
 
518
  }
519
-
520
  return $json;
521
  }
522
 
523
  public static function import_json_to_setting($json)
524
  {
 
 
525
  foreach ($json['data'] as $option_name=>$option)
526
  {
527
- update_option($option_name,$option);
 
528
  }
529
  }
530
 
229
 
230
  public static function update_option($option_name,$options)
231
  {
232
+ update_option($option_name,$options,'no');
233
  }
234
 
235
  public static function delete_option($option_name)
248
  $default = array();
249
  $options = get_option('wpvivid_task_list', $default);
250
  $options[$id]=$task;
251
+ self::update_option('wpvivid_task_list',$options);
252
  }
253
 
254
  public static function delete_task($id)
256
  $default = array();
257
  $options = get_option('wpvivid_task_list', $default);
258
  unset($options[$id]);
259
+ self::update_option('wpvivid_task_list',$options);
260
  }
261
 
262
  public static function check_compress_options()
504
  $json['data']['wpvivid_task_list']=self::get_option('wpvivid_task_list');
505
  $json['data']['wpvivid_last_msg']=self::get_option('wpvivid_last_msg');
506
  $json['data']['wpvivid_user_history']=self::get_option('wpvivid_user_history');
507
+ $json = apply_filters('wpvivid_history_addon', $json);
508
  }
509
 
510
  if($backup_list){
511
  $json['data']['wpvivid_backup_list']=self::get_option('wpvivid_backup_list');
512
+ $json = apply_filters('wpvivid_backup_list_addon', $json);
513
  }
514
 
515
  if($review)
517
  $json['data']['wpvivid_need_review']=self::get_option('wpvivid_need_review');
518
  $json['data']['cron_backup_count']=self::get_option('cron_backup_count');
519
  $json['data']['wpvivid_review_msg']=self::get_option('wpvivid_review_msg');
520
+ $json = apply_filters('wpvivid_review_addon', $json);
521
  }
 
522
  return $json;
523
  }
524
 
525
  public static function import_json_to_setting($json)
526
  {
527
+ wp_cache_delete('notoptions', 'options');
528
+ wp_cache_delete('alloptions', 'options');
529
  foreach ($json['data'] as $option_name=>$option)
530
  {
531
+ wp_cache_delete($option_name, 'options');
532
+ self::update_option($option_name,$option);
533
  }
534
  }
535
 
includes/class-wpvivid-tab-page-container.php CHANGED
@@ -41,9 +41,10 @@ class WPvivid_Tab_Page_Container
41
 
42
  public function display()
43
  {
 
44
  ?>
45
  <div id="<?php echo $this->container_id?>">
46
- <h2 class="nav-tab-wrapper" style="padding-bottom:0!important;">
47
  <?php
48
  $this->display_tabs();
49
  ?>
@@ -51,7 +52,7 @@ class WPvivid_Tab_Page_Container
51
  <?php
52
  if($this->is_parent_tab){
53
  ?>
54
- <div class="wrap" style="max-width:1720px;">
55
  <div id="poststuff" style="padding-top: 0;">
56
  <div id="post-body" class="metabox-holder columns-2">
57
  <div id="post-body-content">
@@ -132,7 +133,8 @@ class WPvivid_Tab_Page_Container
132
  });
133
 
134
  jQuery("#wpvivid_page_"+redirect).show();
135
- jQuery(this).addClass( "nav-tab-active" );
 
136
  });
137
 
138
  jQuery(document).ready(function($)
@@ -156,6 +158,8 @@ class WPvivid_Tab_Page_Container
156
  jQuery(this).attr('redirect',redirect);
157
  });
158
  jQuery("#wpvivid_tab_"+id).addClass( "nav-tab-active" );
 
 
159
  });
160
  });
161
  </script>
@@ -175,7 +179,7 @@ class WPvivid_Tab_Page_Container
175
  $first=false;
176
  }
177
 
178
- $style='';
179
 
180
  if(isset($tab['hide']))
181
  {
@@ -186,8 +190,12 @@ class WPvivid_Tab_Page_Container
186
  {
187
  $class.=' delete';
188
  }
 
 
 
 
189
 
190
- echo '<a href="#" id="wpvivid_tab_'.$tab['slug'].'" class="'.$class.'" style="'.$style.'">';
191
 
192
  if(isset($tab['can_delete']))
193
  {
41
 
42
  public function display()
43
  {
44
+ $class = '';
45
  ?>
46
  <div id="<?php echo $this->container_id?>">
47
+ <h2 class="nav-tab-wrapper <?php esc_attr_e($class); ?>" style="padding-bottom:0!important;">
48
  <?php
49
  $this->display_tabs();
50
  ?>
52
  <?php
53
  if($this->is_parent_tab){
54
  ?>
55
+ <div style="margin: 10px 0 0 2px;">
56
  <div id="poststuff" style="padding-top: 0;">
57
  <div id="post-body" class="metabox-holder columns-2">
58
  <div id="post-body-content">
133
  });
134
 
135
  jQuery("#wpvivid_page_"+redirect).show();
136
+ jQuery("#wpvivid_tab_"+redirect).addClass( "nav-tab-active" );
137
+ //jQuery(this).addClass( "nav-tab-active" );
138
  });
139
 
140
  jQuery(document).ready(function($)
158
  jQuery(this).attr('redirect',redirect);
159
  });
160
  jQuery("#wpvivid_tab_"+id).addClass( "nav-tab-active" );
161
+ var top = jQuery("#wpvivid_tab_"+id).offset().top-jQuery("#wpvivid_tab_"+id).height();
162
+ jQuery('html, body').animate({scrollTop:top}, 'slow');
163
  });
164
  });
165
  </script>
179
  $first=false;
180
  }
181
 
182
+ $style='cursor:pointer;';
183
 
184
  if(isset($tab['hide']))
185
  {
190
  {
191
  $class.=' delete';
192
  }
193
+ if(isset($tab['transparency']))
194
+ {
195
+ $class.=' wpvivid-transparency-tab';
196
+ }
197
 
198
+ echo '<a id="wpvivid_tab_'.$tab['slug'].'" class="'.$class.'" style="'.$style.'">';
199
 
200
  if(isset($tab['can_delete']))
201
  {
includes/class-wpvivid-taskmanager.php CHANGED
@@ -440,7 +440,7 @@ class WPvivid_taskmanager
440
 
441
  $options = get_option('wpvivid_download_cache', $default);
442
  $options[$backup_id]['cache']=$cache;
443
- update_option('wpvivid_download_cache',$options);
444
  }
445
 
446
  public static function get_download_cache($backup_id)
@@ -564,7 +564,7 @@ class WPvivid_taskmanager
564
  unset($tasks[$id]);
565
  $has_marked = 1;
566
  }
567
- update_option('wpvivid_task_list',$tasks);
568
  return $has_marked;
569
  }
570
 
@@ -588,7 +588,7 @@ class WPvivid_taskmanager
588
  unset($tasks[$id]);
589
  }
590
 
591
- update_option('wpvivid_task_list',$tasks);
592
  }
593
 
594
  public static function delete_all_task()
@@ -628,7 +628,7 @@ class WPvivid_taskmanager
628
  $task['error']='';
629
  $options[$file_name]=$task;
630
 
631
- update_option('wpvivid_download_task_v2',$options);
632
  return $task;
633
  }
634
 
@@ -684,7 +684,7 @@ class WPvivid_taskmanager
684
 
685
  $options[$file_name]=$task;
686
 
687
- update_option('wpvivid_download_task_v2',$options);
688
  }
689
 
690
  public static function get_download_task_v2($file_name)
@@ -721,7 +721,7 @@ class WPvivid_taskmanager
721
  if(array_key_exists($file_name,$options))
722
  {
723
  unset($options[$file_name]);
724
- update_option('wpvivid_download_task_v2',$options);
725
  return true;
726
  }
727
  return false;
440
 
441
  $options = get_option('wpvivid_download_cache', $default);
442
  $options[$backup_id]['cache']=$cache;
443
+ WPvivid_Setting::update_option('wpvivid_download_cache',$options);
444
  }
445
 
446
  public static function get_download_cache($backup_id)
564
  unset($tasks[$id]);
565
  $has_marked = 1;
566
  }
567
+ WPvivid_Setting::update_option('wpvivid_task_list',$tasks);
568
  return $has_marked;
569
  }
570
 
588
  unset($tasks[$id]);
589
  }
590
 
591
+ WPvivid_Setting::update_option('wpvivid_task_list',$tasks);
592
  }
593
 
594
  public static function delete_all_task()
628
  $task['error']='';
629
  $options[$file_name]=$task;
630
 
631
+ WPvivid_Setting::update_option('wpvivid_download_task_v2',$options);
632
  return $task;
633
  }
634
 
684
 
685
  $options[$file_name]=$task;
686
 
687
+ WPvivid_Setting::update_option('wpvivid_download_task_v2',$options);
688
  }
689
 
690
  public static function get_download_task_v2($file_name)
721
  if(array_key_exists($file_name,$options))
722
  {
723
  unset($options[$file_name]);
724
+ WPvivid_Setting::update_option('wpvivid_download_task_v2',$options);
725
  return true;
726
  }
727
  return false;
includes/class-wpvivid-zipclass.php CHANGED
@@ -3,18 +3,15 @@
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
6
- if(!defined('WPVIVID_COMPRESS_ZIPCLASS')){
7
- define('WPVIVID_COMPRESS_ZIPCLASS','zipclass');
8
- }
9
 
10
- define('WPVIVID_ZIPCLASS_JSONFILE_NAME','wpvivid_zipclass.json');
11
  require_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-compress-default.php';
12
  class WPvivid_ZipClass extends Wpvivid_Compress_Default
13
  {
14
  public $last_error = '';
15
  public $path_filter=array();
16
 
17
- public function __construct() {
 
18
  if (!class_exists('PclZip')) include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
19
  if (!class_exists('PclZip')) {
20
  $this->last_error = array('result'=>WPVIVID_FAILED,'error'=>"Class PclZip is not detected. Please update or reinstall your WordPress.");
@@ -168,7 +165,7 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
168
  $max_size = str_replace('M', '', $max_size);
169
  $size = intval($max_size) * 1024 * 1024;
170
 
171
- $files = $this -> filesplit_plugin($size,$data['files'],0);
172
 
173
  $temp_dir = $data['path'].'temp-'.$data['prefix'].DIRECTORY_SEPARATOR;
174
  if(!file_exists($temp_dir))
@@ -177,7 +174,8 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
177
 
178
  if(sizeof($files) > 1)
179
  {
180
- for($i =0;$i <sizeof($files);$i ++)
 
181
  {
182
  $package = array();
183
  $path = $data['path'].$data['prefix'].'.part'.sprintf('%03d',($i +1)).'.zip';
@@ -192,8 +190,9 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
192
  $package['json']['root_flag'] = $data['root_flag'];
193
  $package['json']['file']=basename($path);
194
  $package['path'] = $path;
195
- $package['files'] = $files[$i];
196
  $packages[] = $package;
 
197
  }
198
  }else {
199
  $package = array();
@@ -214,7 +213,6 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
214
  }
215
 
216
  $ret['packages']=$packages;
217
- $ret['temp_dir']=$temp_dir;
218
  return $ret;
219
  }
220
 
@@ -470,133 +468,9 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
470
 
471
  public function _zip($name,$files,$options,$json_info=false)
472
  {
473
- global $wpvivid_plugin;
474
-
475
- if(file_exists($name))
476
- @unlink($name);
477
- $archive = new PclZip($name);
478
-
479
- if(isset($options['compress']['no_compress']))
480
- {
481
- $no_compress=$options['compress']['no_compress'];
482
- }
483
- else
484
- {
485
- $no_compress=1;
486
- }
487
-
488
- if(isset($options['compress']['use_temp_file']))
489
- {
490
- $use_temp_file=1;
491
- }
492
- else
493
- {
494
- $use_temp_file=0;
495
- }
496
-
497
- if(isset($options['compress']['use_temp_size']))
498
- {
499
- $use_temp_size=$options['compress']['use_temp_size'];
500
- }
501
- else
502
- {
503
- $use_temp_size=16;
504
- }
505
-
506
- if(isset($options['root_path']))
507
- {
508
- $replace_path=$options['root_path'];
509
- }
510
- else if(isset($options['root_flag']))
511
- {
512
- $replace_path=$this->get_root_flag_path($options['root_flag']);
513
- }
514
- else
515
- {
516
- $replace_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
517
- }
518
-
519
- if($json_info!==false)
520
- {
521
- $temp_path = dirname($name).DIRECTORY_SEPARATOR.'wpvivid_package_info.json';
522
- if(file_exists($temp_path))
523
- {
524
- @unlink($temp_path);
525
- }
526
- file_put_contents($temp_path,print_r(json_encode($json_info),true));
527
- $archive -> add($temp_path,PCLZIP_OPT_REMOVE_PATH,dirname($temp_path));
528
- @unlink($temp_path);
529
- }
530
-
531
- $wpvivid_plugin->wpvivid_log->WriteLog('Prepare to zip files. file: '.basename($name),'notice');
532
-
533
- if($no_compress)
534
- {
535
- if($use_temp_file==1)
536
- {
537
- if($use_temp_size!=0)
538
- {
539
- $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_NO_COMPRESSION,PCLZIP_OPT_TEMP_FILE_THRESHOLD,$use_temp_size);
540
- }
541
- else
542
- {
543
- $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_NO_COMPRESSION,PCLZIP_OPT_TEMP_FILE_ON);
544
- }
545
- }
546
- else
547
- {
548
- $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_NO_COMPRESSION,PCLZIP_OPT_TEMP_FILE_OFF);
549
- }
550
- }
551
- else
552
- {
553
- if($use_temp_file==1)
554
- {
555
- if($use_temp_size!=0)
556
- {
557
- $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_TEMP_FILE_THRESHOLD,$use_temp_size);
558
- }
559
- else
560
- {
561
- $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_TEMP_FILE_ON);
562
- }
563
- }
564
- else
565
- {
566
- $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_TEMP_FILE_OFF);
567
- }
568
- }
569
-
570
- if(!$ret)
571
- {
572
- $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: '.$archive->errorInfo(true),'notice');
573
- $size=size_format(disk_free_space(dirname($name)),2);
574
- $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
575
- return array('result'=>WPVIVID_FAILED,'error'=>$archive->errorInfo(true));
576
- }
577
-
578
- $size=filesize($name);
579
- if($size===false)
580
- {
581
- $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: file not found after backup success','error');
582
- $size=size_format(disk_free_space(dirname($name)),2);
583
- $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
584
- return array('result'=>WPVIVID_FAILED,'error'=>'The file compression failed while backing up becuase of '.$name.' file not found. Please try again. The available disk space: '.$size.'.');
585
- }
586
- else if($size==0)
587
- {
588
- $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: file size 0B after backup success','error');
589
- $size=size_format(disk_free_space(dirname($name)),2);
590
- $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
591
- return array('result'=>WPVIVID_FAILED,'error'=>'The file compression failed while backing up. The size of '.$name.' file is 0. Please make sure there is an enough disk space to backup. Then try again. The available disk space: '.$size.'.');
592
- }
593
-
594
- $wpvivid_plugin->wpvivid_log->WriteLog('Adding zip files completed.'.basename($name).', filesize: '.size_format(filesize($name),2),'notice');
595
- $file_data = array();
596
- $file_data['file_name'] = basename($name);
597
- $file_data['size'] = filesize($name);
598
-
599
- return array('result'=>WPVIVID_SUCCESS,'file_data'=>$file_data);
600
  }
601
 
602
  public function listcontent($path){
@@ -680,49 +554,83 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
680
  $folder_num_sum = 0;
681
  $package = array();
682
 
683
- foreach ($files as $file)
684
  {
685
- $folder_num=0;
686
- if(is_dir($file))
687
  {
688
- if($is_num)
 
689
  {
690
  $folder_num=$this->get_folder_file_count($file);
691
  }
692
  else
693
  {
694
- $folder_num=$this->get_folder_file_size($file);
695
  }
696
- }
697
- else
698
- {
699
- $folder_num_sum+=filesize($file);
700
- }
701
 
702
- if($folder_num > $max_file_size)
703
- {
704
- $temp_package[] = $file;
705
- $packages[] = $temp_package;
706
- $temp_package = array();
707
- continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
708
  }
709
- else
 
 
 
710
  {
711
- $folder_num_sum+=$folder_num;
712
- }
 
 
 
 
 
 
 
713
 
714
- if($folder_num_sum > $max_file_size)
715
- {
716
- $package[] = $file;
717
- $packages[] = $package;
718
- $package = array();
719
- $folder_num_sum=0;
720
- }
721
- else{
722
- $package[] = $file;
723
- }
 
724
 
 
 
 
 
 
 
 
 
 
 
 
725
  }
 
726
  if(!empty($package))
727
  $packages[] = $package;
728
  }
@@ -804,6 +712,351 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
804
  }
805
  return $path;
806
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
807
  }
808
 
809
  $wpvivid_old_time=0;
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
 
 
 
6
 
 
7
  require_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-compress-default.php';
8
  class WPvivid_ZipClass extends Wpvivid_Compress_Default
9
  {
10
  public $last_error = '';
11
  public $path_filter=array();
12
 
13
+ public function __construct()
14
+ {
15
  if (!class_exists('PclZip')) include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
16
  if (!class_exists('PclZip')) {
17
  $this->last_error = array('result'=>WPVIVID_FAILED,'error'=>"Class PclZip is not detected. Please update or reinstall your WordPress.");
165
  $max_size = str_replace('M', '', $max_size);
166
  $size = intval($max_size) * 1024 * 1024;
167
 
168
+ $files = $this -> get_files_cache($size,$data);
169
 
170
  $temp_dir = $data['path'].'temp-'.$data['prefix'].DIRECTORY_SEPARATOR;
171
  if(!file_exists($temp_dir))
174
 
175
  if(sizeof($files) > 1)
176
  {
177
+ $i=0;
178
+ foreach ($files as $file)
179
  {
180
  $package = array();
181
  $path = $data['path'].$data['prefix'].'.part'.sprintf('%03d',($i +1)).'.zip';
190
  $package['json']['root_flag'] = $data['root_flag'];
191
  $package['json']['file']=basename($path);
192
  $package['path'] = $path;
193
+ $package['files'] = $file;
194
  $packages[] = $package;
195
+ $i++;
196
  }
197
  }else {
198
  $package = array();
213
  }
214
 
215
  $ret['packages']=$packages;
 
216
  return $ret;
217
  }
218
 
468
 
469
  public function _zip($name,$files,$options,$json_info=false)
470
  {
471
+ $zip_object_class=apply_filters('wpvivid_get_zip_object_class','WPvivid_PclZip_Class');
472
+ $zip=new $zip_object_class();
473
+ return $zip->zip($name,$files,$options,$json_info);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
  }
475
 
476
  public function listcontent($path){
554
  $folder_num_sum = 0;
555
  $package = array();
556
 
557
+ if($is_num)
558
  {
559
+ foreach ($files as $file)
 
560
  {
561
+ $folder_num=0;
562
+ if(is_dir($file))
563
  {
564
  $folder_num=$this->get_folder_file_count($file);
565
  }
566
  else
567
  {
568
+ $folder_num_sum+=filesize($file);
569
  }
 
 
 
 
 
570
 
571
+ if($folder_num > $max_file_size)
572
+ {
573
+ $temp_package[] = $file;
574
+ $packages[] = $temp_package;
575
+ $temp_package = array();
576
+ continue;
577
+ }
578
+ else
579
+ {
580
+ $folder_num_sum+=$folder_num;
581
+ }
582
+
583
+ if($folder_num_sum > $max_file_size)
584
+ {
585
+ $package[] = $file;
586
+ $packages[] = $package;
587
+ $package = array();
588
+ $folder_num_sum=0;
589
+ }
590
+ else{
591
+ $package[] = $file;
592
+ }
593
  }
594
+ }
595
+ else
596
+ {
597
+ foreach ($files as $file)
598
  {
599
+ $folder_num=0;
600
+ if(is_dir($file))
601
+ {
602
+ $folder_num=$this->get_folder_file_size($file);
603
+ }
604
+ else
605
+ {
606
+ $folder_num_sum+=filesize($file);
607
+ }
608
 
609
+ if($folder_num > $max_file_size)
610
+ {
611
+ $temp_package[] = $file;
612
+ $packages[] = $temp_package;
613
+ $temp_package = array();
614
+ continue;
615
+ }
616
+ else
617
+ {
618
+ $folder_num_sum+=$folder_num;
619
+ }
620
 
621
+ if($folder_num_sum > $max_file_size)
622
+ {
623
+ $package[] = $file;
624
+ $packages[] = $package;
625
+ $package = array();
626
+ $folder_num_sum=0;
627
+ }
628
+ else{
629
+ $package[] = $file;
630
+ }
631
+ }
632
  }
633
+
634
  if(!empty($package))
635
  $packages[] = $package;
636
  }
712
  }
713
  return $path;
714
  }
715
+
716
+ public function get_files_cache($size,$data)
717
+ {
718
+ $number=1;
719
+ $cache_perfix = $data['path'].$data['prefix'].'_file_cache_';
720
+ $cache_file_handle=false;
721
+ $sumsize=0;
722
+
723
+ if(isset($data['exclude_files_regex']))
724
+ $exclude_files_regex=$data['exclude_files_regex'];
725
+ else
726
+ $exclude_files_regex=array();
727
+
728
+ if(isset($data['compress'])&&$data['compress']['exclude_file_size'])
729
+ $exclude_file_size=$data['compress']['exclude_file_size'];
730
+ else
731
+ $exclude_file_size=0;
732
+
733
+ if(isset($data['skip_files_time']))
734
+ {
735
+ $skip_files_time=$data['skip_files_time'];
736
+ }
737
+ else
738
+ {
739
+ $skip_files_time=0;
740
+ }
741
+ global $wpvivid_plugin;
742
+ $wpvivid_plugin->wpvivid_log->WriteLog('exclude_files_regex:'.json_encode($exclude_files_regex),'notice');
743
+
744
+ foreach ($data['files'] as $file)
745
+ {
746
+ $this->get_file_cache($size,$file,$cache_perfix,$cache_file_handle,$number,$sumsize,$exclude_files_regex,$exclude_file_size,$skip_files_time);
747
+ }
748
+
749
+ $file_cache=array();
750
+
751
+ for($i=1;$i<$number+1;$i++)
752
+ {
753
+ $file_cache[]=$cache_perfix.$i.'.txt';
754
+ }
755
+ return $file_cache;
756
+ }
757
+
758
+ public function get_file_cache($size,$path,$cache_perfix,&$cache_file_handle,&$number,&$sumsize,$exclude_files_regex,$exclude_file_size,$skip_files_time)
759
+ {
760
+ if(!$cache_file_handle)
761
+ {
762
+ $cache_file=$cache_perfix.$number.'.txt';
763
+ $cache_file_handle=fopen($cache_file,'a');
764
+ }
765
+ $handler = opendir($path);
766
+
767
+ while (($filename = readdir($handler)) !== false)
768
+ {
769
+ if ($filename != "." && $filename != "..")
770
+ {
771
+ if(is_dir($path . DIRECTORY_SEPARATOR . $filename))
772
+ {
773
+ $this->get_file_cache($size,$path . DIRECTORY_SEPARATOR . $filename,$cache_perfix,$cache_file_handle,$number,$sumsize,$exclude_files_regex,$exclude_file_size,$skip_files_time);
774
+ }
775
+ else
776
+ {
777
+ if($this->regex_match($exclude_files_regex, $filename, 0))
778
+ {
779
+ if ($exclude_file_size == 0||(filesize($path . DIRECTORY_SEPARATOR . $filename) < $exclude_file_size * 1024 * 1024))
780
+ {
781
+ if(is_readable($path . DIRECTORY_SEPARATOR . $filename))
782
+ {
783
+ if($skip_files_time>0)
784
+ {
785
+ $file_time=filemtime($path . DIRECTORY_SEPARATOR . $filename);
786
+ if($file_time>0&&$file_time>$skip_files_time)
787
+ {
788
+ $sumsize+=filesize($path . DIRECTORY_SEPARATOR . $filename);
789
+ if($sumsize>$size)
790
+ {
791
+ $number++;
792
+ fclose($cache_file_handle);
793
+ $cache_file=$cache_perfix.$number.'.txt';
794
+ $cache_file_handle=fopen($cache_file,'a');
795
+
796
+ $line = $path . DIRECTORY_SEPARATOR . $filename.PHP_EOL;
797
+ fwrite($cache_file_handle, $line);
798
+
799
+ $sumsize=filesize($path . DIRECTORY_SEPARATOR . $filename);
800
+ }
801
+ else
802
+ {
803
+ $line = $path . DIRECTORY_SEPARATOR . $filename.PHP_EOL;
804
+ fwrite($cache_file_handle, $line);
805
+ }
806
+ }
807
+ }
808
+ else
809
+ {
810
+ $sumsize+=filesize($path . DIRECTORY_SEPARATOR . $filename);
811
+ if($sumsize>$size)
812
+ {
813
+ $number++;
814
+ fclose($cache_file_handle);
815
+ $cache_file=$cache_perfix.$number.'.txt';
816
+ $cache_file_handle=fopen($cache_file,'a');
817
+
818
+ $line = $path . DIRECTORY_SEPARATOR . $filename.PHP_EOL;
819
+ fwrite($cache_file_handle, $line);
820
+
821
+ $sumsize=filesize($path . DIRECTORY_SEPARATOR . $filename);
822
+ }
823
+ else
824
+ {
825
+ $line = $path . DIRECTORY_SEPARATOR . $filename.PHP_EOL;
826
+ fwrite($cache_file_handle, $line);
827
+ }
828
+ $files[] = $path . DIRECTORY_SEPARATOR . $filename;
829
+ }
830
+ }
831
+ else
832
+ {
833
+ global $wpvivid_plugin;
834
+ $wpvivid_plugin->wpvivid_log->WriteLog('file not readable:' . $path . DIRECTORY_SEPARATOR . $filename, 'notice');
835
+ }
836
+ }
837
+ }
838
+ }
839
+ }
840
+ }
841
+ if($handler)
842
+ @closedir($handler);
843
+ }
844
+
845
+ private function regex_match($regex_array,$string,$mode)
846
+ {
847
+ if(empty($regex_array))
848
+ {
849
+ return true;
850
+ }
851
+
852
+ if($mode==0)
853
+ {
854
+ foreach ($regex_array as $regex)
855
+ {
856
+ if(preg_match($regex,$string))
857
+ {
858
+ return false;
859
+ }
860
+ }
861
+
862
+ return true;
863
+ }
864
+
865
+ if($mode==1)
866
+ {
867
+ foreach ($regex_array as $regex)
868
+ {
869
+ if(preg_match($regex,$string))
870
+ {
871
+ return true;
872
+ }
873
+ }
874
+
875
+ return false;
876
+ }
877
+
878
+ return true;
879
+ }
880
+
881
+ public function get_upload_files_from_cache($file)
882
+ {
883
+ $files=array();
884
+ $file = new SplFileObject($file);
885
+ $file->seek(0);
886
+
887
+ $file->setFlags( \SplFileObject::SKIP_EMPTY | \SplFileObject::READ_AHEAD );
888
+
889
+ while(!$file->eof())
890
+ {
891
+ $src = $file->fgets();
892
+
893
+ $src=trim($src,PHP_EOL);
894
+
895
+ if(empty($src))
896
+ continue;
897
+
898
+ if(!file_exists($src))
899
+ {
900
+ continue;
901
+ }
902
+
903
+ $files[]=$src;
904
+ }
905
+ return $files;
906
+ }
907
+ }
908
+
909
+ class WPvivid_PclZip_Class
910
+ {
911
+ public function zip($name,$files,$options,$json_info=false)
912
+ {
913
+ global $wpvivid_plugin;
914
+
915
+ if(file_exists($name))
916
+ @unlink($name);
917
+
918
+ $archive = new PclZip($name);
919
+
920
+ if(isset($options['compress']['no_compress']))
921
+ {
922
+ $no_compress=$options['compress']['no_compress'];
923
+ }
924
+ else
925
+ {
926
+ $no_compress=1;
927
+ }
928
+
929
+ if(isset($options['compress']['use_temp_file']))
930
+ {
931
+ $use_temp_file=1;
932
+ }
933
+ else
934
+ {
935
+ $use_temp_file=0;
936
+ }
937
+
938
+ if(isset($options['compress']['use_temp_size']))
939
+ {
940
+ $use_temp_size=$options['compress']['use_temp_size'];
941
+ }
942
+ else
943
+ {
944
+ $use_temp_size=16;
945
+ }
946
+
947
+ if(isset($options['root_path']))
948
+ {
949
+ $replace_path=$options['root_path'];
950
+ }
951
+ else if(isset($options['root_flag']))
952
+ {
953
+ $replace_path=$this->get_root_flag_path($options['root_flag']);
954
+ }
955
+ else
956
+ {
957
+ $replace_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
958
+ }
959
+
960
+ if($json_info!==false)
961
+ {
962
+ $temp_path = dirname($name).DIRECTORY_SEPARATOR.'wpvivid_package_info.json';
963
+ if(file_exists($temp_path))
964
+ {
965
+ @unlink($temp_path);
966
+ }
967
+ file_put_contents($temp_path,print_r(json_encode($json_info),true));
968
+ $archive -> add($temp_path,PCLZIP_OPT_REMOVE_PATH,dirname($temp_path));
969
+ @unlink($temp_path);
970
+ }
971
+
972
+ $wpvivid_plugin->wpvivid_log->WriteLog('Prepare to zip files. file: '.basename($name),'notice');
973
+
974
+ if($no_compress)
975
+ {
976
+ if($use_temp_file==1)
977
+ {
978
+ if($use_temp_size!=0)
979
+ {
980
+ $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_NO_COMPRESSION,PCLZIP_OPT_TEMP_FILE_THRESHOLD,$use_temp_size);
981
+ }
982
+ else
983
+ {
984
+ $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_NO_COMPRESSION,PCLZIP_OPT_TEMP_FILE_ON);
985
+ }
986
+ }
987
+ else
988
+ {
989
+ $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_NO_COMPRESSION,PCLZIP_OPT_TEMP_FILE_OFF);
990
+ }
991
+ }
992
+ else
993
+ {
994
+ if($use_temp_file==1)
995
+ {
996
+ if($use_temp_size!=0)
997
+ {
998
+ $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_TEMP_FILE_THRESHOLD,$use_temp_size);
999
+ }
1000
+ else
1001
+ {
1002
+ $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_TEMP_FILE_ON);
1003
+ }
1004
+ }
1005
+ else
1006
+ {
1007
+ $ret = $archive -> add($files,PCLZIP_OPT_REMOVE_PATH,$replace_path,PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',PCLZIP_OPT_TEMP_FILE_OFF);
1008
+ }
1009
+ }
1010
+
1011
+ if(!$ret)
1012
+ {
1013
+ $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: '.$archive->errorInfo(true),'notice');
1014
+ $size=size_format(disk_free_space(dirname($name)),2);
1015
+ $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
1016
+ return array('result'=>WPVIVID_FAILED,'error'=>$archive->errorInfo(true));
1017
+ }
1018
+
1019
+ $size=filesize($name);
1020
+ if($size===false)
1021
+ {
1022
+ $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: file not found after backup success','error');
1023
+ $size=size_format(disk_free_space(dirname($name)),2);
1024
+ $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
1025
+ return array('result'=>WPVIVID_FAILED,'error'=>'The file compression failed while backing up becuase of '.$name.' file not found. Please try again. The available disk space: '.$size.'.');
1026
+ }
1027
+ else if($size==0)
1028
+ {
1029
+ $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: file size 0B after backup success','error');
1030
+ $size=size_format(disk_free_space(dirname($name)),2);
1031
+ $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
1032
+ return array('result'=>WPVIVID_FAILED,'error'=>'The file compression failed while backing up. The size of '.$name.' file is 0. Please make sure there is an enough disk space to backup. Then try again. The available disk space: '.$size.'.');
1033
+ }
1034
+
1035
+ $wpvivid_plugin->wpvivid_log->WriteLog('Adding zip files completed.'.basename($name).', filesize: '.size_format(filesize($name),2),'notice');
1036
+ $file_data = array();
1037
+ $file_data['file_name'] = basename($name);
1038
+ $file_data['size'] = filesize($name);
1039
+
1040
+ return array('result'=>WPVIVID_SUCCESS,'file_data'=>$file_data);
1041
+ }
1042
+
1043
+ public function get_root_flag_path($flag)
1044
+ {
1045
+ $path='';
1046
+ if($flag==WPVIVID_BACKUP_ROOT_WP_CONTENT)
1047
+ {
1048
+ $path=WP_CONTENT_DIR;
1049
+ }
1050
+ else if($flag==WPVIVID_BACKUP_ROOT_CUSTOM)
1051
+ {
1052
+ $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
1053
+ }
1054
+ else if($flag==WPVIVID_BACKUP_ROOT_WP_ROOT)
1055
+ {
1056
+ $path=ABSPATH;
1057
+ }
1058
+ return $path;
1059
+ }
1060
  }
1061
 
1062
  $wpvivid_old_time=0;
includes/class-wpvivid.php CHANGED
@@ -76,13 +76,13 @@ class WPvivid {
76
  {
77
  //Initialization settings
78
  WPvivid_Setting::init_option();
79
- update_option('wpvivid_init','init');
80
  }
81
 
82
  $wpvivid_remote_init=get_option('wpvivid_remote_init', 'not init');
83
  if($wpvivid_remote_init=='not init'){
84
  $this->init_remote_option();
85
- update_option('wpvivid_remote_init','init');
86
  }
87
 
88
  //Define the locale for this plugin for internationalization.
@@ -95,7 +95,7 @@ class WPvivid {
95
  $this->load_ajax_hook_for_admin();
96
  }
97
 
98
- add_filter('pre_update_option',array( $this,'wpjam_pre_update_option_cache'),10,2);
99
 
100
  add_filter('wpvivid_add_backup_list', array( $this, 'wpvivid_add_backup_list' ), 10, 3);
101
  add_filter('wpvivid_add_remote_storage_list', array( $this, 'wpvivid_add_remote_storage_list' ), 10);
@@ -124,6 +124,9 @@ class WPvivid {
124
 
125
  add_action('wpvivid_before_setup_page',array($this,'clean_cache'));
126
  add_filter('wpvivid_check_type_database', array($this, 'wpvivid_check_type_database'), 10, 2);
 
 
 
127
  //Initialisation schedule hook
128
  $this->init_cron();
129
  //Initialisation log object
@@ -460,23 +463,6 @@ class WPvivid {
460
  echo json_encode($ret);
461
  die();
462
  }
463
- catch (Error $error)
464
- {
465
- $this->end_shutdown_function=true;
466
- $ret['result']='failed';
467
- $message = 'An exception has occurred. class:'.get_class($error).';msg:'.$error->getMessage().';code:'.$error->getCode().';line:'.$error->getLine().';in_file:'.$error->getFile().';';
468
- $ret['error'] = $message;
469
- $id=uniqid('wpvivid-');
470
- $log_file_name=$id.'_backup';
471
- $log=new WPvivid_Log();
472
- $log->CreateLogFile($log_file_name,'no_folder','backup');
473
- $log->WriteLog($message,'notice');
474
- WPvivid_error_log::create_error_log($log->log_file);
475
- $log->CloseFile();
476
- error_log($message);
477
- echo json_encode($ret);
478
- die();
479
- }
480
  }
481
 
482
  public function deal_prepare_shutdown_error()
@@ -4536,7 +4522,9 @@ class WPvivid {
4536
 
4537
  $setting_data['wpvivid_email_setting']['send_to'][] = $setting['send_to'];
4538
  $setting_data['wpvivid_email_setting']['always'] = $setting['always'];
4539
- $setting_data['wpvivid_email_setting']['email_enable'] = $setting['email_enable'];
 
 
4540
 
4541
  $setting_data['wpvivid_compress_setting']['compress_type'] = $setting['compress_type'];
4542
  $setting_data['wpvivid_compress_setting']['max_file_size'] = $setting['max_file_size'] . 'M';
@@ -4561,6 +4549,7 @@ class WPvivid {
4561
  $setting_data['wpvivid_common_setting']['restore_memory_limit'] = $setting['restore_memory_limit'].'M';
4562
  $setting_data['wpvivid_common_setting']['migrate_size'] = $setting['migrate_size'];
4563
  $setting_data['wpvivid_common_setting']['ismerge'] = $setting['ismerge'];
 
4564
  return $setting_data;
4565
  }
4566
 
@@ -4709,6 +4698,19 @@ class WPvivid {
4709
  }
4710
  }
4711
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4712
  $ret['result']=WPVIVID_SUCCESS;
4713
  return $ret;
4714
  }
@@ -4742,7 +4744,7 @@ class WPvivid {
4742
  {
4743
  $this->ajax_check_security('manage_options');
4744
  try {
4745
- if (isset($_REQUEST['setting']) && !empty($_REQUEST['setting']) && isset($_REQUEST['history']) && !empty($_REQUEST['history'])) {
4746
  $setting = sanitize_text_field($_REQUEST['setting']);
4747
  $history = sanitize_text_field($_REQUEST['history']);
4748
  $review = sanitize_text_field($_REQUEST['review']);
@@ -5746,16 +5748,26 @@ class WPvivid {
5746
  }
5747
 
5748
  public function hide_mainwp_tab_page(){
5749
- update_option('wpvivid_hide_mwp_tab_page', true);
5750
  $ret['result']=WPVIVID_SUCCESS;
5751
  echo json_encode($ret);
5752
  die();
5753
  }
5754
 
5755
  public function hide_wp_cron_notice(){
5756
- update_option('wpvivid_hide_wp_cron_notice', true);
5757
  $ret['result']=WPVIVID_SUCCESS;
5758
  echo json_encode($ret);
5759
  die();
5760
  }
 
 
 
 
 
 
 
 
 
 
5761
  }
76
  {
77
  //Initialization settings
78
  WPvivid_Setting::init_option();
79
+ WPvivid_Setting::update_option('wpvivid_init','init');
80
  }
81
 
82
  $wpvivid_remote_init=get_option('wpvivid_remote_init', 'not init');
83
  if($wpvivid_remote_init=='not init'){
84
  $this->init_remote_option();
85
+ WPvivid_Setting::update_option('wpvivid_remote_init','init');
86
  }
87
 
88
  //Define the locale for this plugin for internationalization.
95
  $this->load_ajax_hook_for_admin();
96
  }
97
 
98
+ //add_filter('pre_update_option',array( $this,'wpjam_pre_update_option_cache'),10,2);
99
 
100
  add_filter('wpvivid_add_backup_list', array( $this, 'wpvivid_add_backup_list' ), 10, 3);
101
  add_filter('wpvivid_add_remote_storage_list', array( $this, 'wpvivid_add_remote_storage_list' ), 10);
124
 
125
  add_action('wpvivid_before_setup_page',array($this,'clean_cache'));
126
  add_filter('wpvivid_check_type_database', array($this, 'wpvivid_check_type_database'), 10, 2);
127
+ add_filter('wpvivid_set_mail_subject', array($this, 'set_mail_subject'), 10, 2);
128
+ add_filter('wpvivid_set_mail_body', array($this, 'set_mail_body'), 10, 2);
129
+
130
  //Initialisation schedule hook
131
  $this->init_cron();
132
  //Initialisation log object
463
  echo json_encode($ret);
464
  die();
465
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  }
467
 
468
  public function deal_prepare_shutdown_error()
4522
 
4523
  $setting_data['wpvivid_email_setting']['send_to'][] = $setting['send_to'];
4524
  $setting_data['wpvivid_email_setting']['always'] = $setting['always'];
4525
+ if(isset($setting['email_enable'])) {
4526
+ $setting_data['wpvivid_email_setting']['email_enable'] = $setting['email_enable'];
4527
+ }
4528
 
4529
  $setting_data['wpvivid_compress_setting']['compress_type'] = $setting['compress_type'];
4530
  $setting_data['wpvivid_compress_setting']['max_file_size'] = $setting['max_file_size'] . 'M';
4549
  $setting_data['wpvivid_common_setting']['restore_memory_limit'] = $setting['restore_memory_limit'].'M';
4550
  $setting_data['wpvivid_common_setting']['migrate_size'] = $setting['migrate_size'];
4551
  $setting_data['wpvivid_common_setting']['ismerge'] = $setting['ismerge'];
4552
+ $setting_data['wpvivid_common_setting']['db_connect_method'] = $setting['db_connect_method'];
4553
  return $setting_data;
4554
  }
4555
 
4698
  }
4699
  }
4700
 
4701
+ if(isset($data['db_connect_method']) && $data['db_connect_method'] === 'pdo') {
4702
+ if (class_exists('PDO')) {
4703
+ $extensions = get_loaded_extensions();
4704
+ if (!array_search('pdo_mysql', $extensions)) {
4705
+ $ret['error'] = __('The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.', 'wpvivid');
4706
+ return $ret;
4707
+ }
4708
+ } else {
4709
+ $ret['error'] = __('The pdo_mysql extension is not detected. Please install the extension first or choose wpdb option for Database connection method.', 'wpvivid');
4710
+ return $ret;
4711
+ }
4712
+ }
4713
+
4714
  $ret['result']=WPVIVID_SUCCESS;
4715
  return $ret;
4716
  }
4744
  {
4745
  $this->ajax_check_security('manage_options');
4746
  try {
4747
+ if (isset($_REQUEST['setting']) && !empty($_REQUEST['setting']) && isset($_REQUEST['history']) && !empty($_REQUEST['history']) && isset($_REQUEST['review'])) {
4748
  $setting = sanitize_text_field($_REQUEST['setting']);
4749
  $history = sanitize_text_field($_REQUEST['history']);
4750
  $review = sanitize_text_field($_REQUEST['review']);
5748
  }
5749
 
5750
  public function hide_mainwp_tab_page(){
5751
+ WPvivid_Setting::update_option('wpvivid_hide_mwp_tab_page', true);
5752
  $ret['result']=WPVIVID_SUCCESS;
5753
  echo json_encode($ret);
5754
  die();
5755
  }
5756
 
5757
  public function hide_wp_cron_notice(){
5758
+ WPvivid_Setting::update_option('wpvivid_hide_wp_cron_notice', true);
5759
  $ret['result']=WPVIVID_SUCCESS;
5760
  echo json_encode($ret);
5761
  die();
5762
  }
5763
+
5764
+ public function set_mail_subject($subject, $task){
5765
+ $subject=WPvivid_mail_report::create_subject($task);
5766
+ return $subject;
5767
+ }
5768
+
5769
+ public function set_mail_body($body, $task){
5770
+ $body=WPvivid_mail_report::create_body($task);
5771
+ return $body;
5772
+ }
5773
  }
includes/customclass/class-wpvivid-amazons3-plus.php CHANGED
@@ -63,6 +63,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
63
  </div>
64
  <table class="wp-list-table widefat plugins" style="width:100%;">
65
  <tbody>
 
66
  <tr>
67
  <td class="plugin-title column-primary">
68
  <div class="wpvivid-storage-form">
@@ -165,6 +166,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
165
  </div>
166
  </td>
167
  </tr>
 
168
  <tr>
169
  <td class="plugin-title column-primary">
170
  <div class="wpvivid-storage-form">
@@ -199,6 +201,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
199
  </div>
200
  <table class="wp-list-table widefat plugins" style="width:100%;">
201
  <tbody>
 
202
  <tr>
203
  <td class="plugin-title column-primary">
204
  <div class="wpvivid-storage-form">
@@ -287,6 +290,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
287
  </div>
288
  </td>
289
  </tr>
 
290
  <tr>
291
  <td class="plugin-title column-primary">
292
  <div class="wpvivid-storage-form">
63
  </div>
64
  <table class="wp-list-table widefat plugins" style="width:100%;">
65
  <tbody>
66
+ <form>
67
  <tr>
68
  <td class="plugin-title column-primary">
69
  <div class="wpvivid-storage-form">
166
  </div>
167
  </td>
168
  </tr>
169
+ </form>
170
  <tr>
171
  <td class="plugin-title column-primary">
172
  <div class="wpvivid-storage-form">
201
  </div>
202
  <table class="wp-list-table widefat plugins" style="width:100%;">
203
  <tbody>
204
+ <form>
205
  <tr>
206
  <td class="plugin-title column-primary">
207
  <div class="wpvivid-storage-form">
290
  </div>
291
  </td>
292
  </tr>
293
+ </form>
294
  <tr>
295
  <td class="plugin-title column-primary">
296
  <div class="wpvivid-storage-form">
includes/customclass/class-wpvivid-ftpclass.php CHANGED
@@ -45,6 +45,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
45
  <div style="padding: 0 10px 10px 0;"><strong>Enter Your FTP Account</strong></div>
46
  <table class="wp-list-table widefat plugins" style="width:100%;">
47
  <tbody>
 
48
  <tr>
49
  <td class="plugin-title column-primary">
50
  <div class="wpvivid-storage-form">
@@ -145,6 +146,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
145
  </div>
146
  </td>
147
  </tr>
 
148
  <tr>
149
  <td class="plugin-title column-primary">
150
  <div class="wpvivid-storage-form">
@@ -170,6 +172,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
170
  <div style="padding: 0 10px 10px 0;"><strong>Enter Your FTP Account</strong></div>
171
  <table class="wp-list-table widefat plugins" style="width:100%;">
172
  <tbody>
 
173
  <tr>
174
  <td class="plugin-title column-primary">
175
  <div class="wpvivid-storage-form">
@@ -244,6 +247,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
244
  </div>
245
  </td>
246
  </tr>
 
247
  <tr>
248
  <td class="plugin-title column-primary">
249
  <div class="wpvivid-storage-form">
45
  <div style="padding: 0 10px 10px 0;"><strong>Enter Your FTP Account</strong></div>
46
  <table class="wp-list-table widefat plugins" style="width:100%;">
47
  <tbody>
48
+ <form>
49
  <tr>
50
  <td class="plugin-title column-primary">
51
  <div class="wpvivid-storage-form">
146
  </div>
147
  </td>
148
  </tr>
149
+ </form>
150
  <tr>
151
  <td class="plugin-title column-primary">
152
  <div class="wpvivid-storage-form">
172
  <div style="padding: 0 10px 10px 0;"><strong>Enter Your FTP Account</strong></div>
173
  <table class="wp-list-table widefat plugins" style="width:100%;">
174
  <tbody>
175
+ <form>
176
  <tr>
177
  <td class="plugin-title column-primary">
178
  <div class="wpvivid-storage-form">
247
  </div>
248
  </td>
249
  </tr>
250
+ </form>
251
  <tr>
252
  <td class="plugin-title column-primary">
253
  <div class="wpvivid-storage-form">
includes/customclass/class-wpvivid-s3compat.php CHANGED
@@ -411,6 +411,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
411
  </div>
412
  <table class="wp-list-table widefat plugins" style="width:100%;">
413
  <tbody>
 
414
  <tr>
415
  <td class="plugin-title column-primary">
416
  <div class="wpvivid-storage-form">
@@ -497,6 +498,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
497
  </div>
498
  </td>
499
  </tr>
 
500
  <tr>
501
  <td class="plugin-title column-primary">
502
  <div class="wpvivid-storage-form">
@@ -512,16 +514,6 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
512
  </tbody>
513
  </table>
514
  </div>
515
- <script>
516
- /*jQuery("input:text[option=s3compat][name=s3directory]").keyup(function(){
517
- var value = jQuery(this).val();
518
- if(value == ''){
519
- value = '*';
520
- }
521
- value = value + '/wpvivid_backup';
522
- jQuery('#wpvivid_dos_root_path').html(value);
523
- });*/
524
- </script>
525
  <?php
526
  }
527
 
@@ -534,6 +526,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
534
  </div>
535
  <table class="wp-list-table widefat plugins" style="width:100%;">
536
  <tbody>
 
537
  <tr>
538
  <td class="plugin-title column-primary">
539
  <div class="wpvivid-storage-form">
@@ -606,6 +599,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
606
  </div>
607
  </td>
608
  </tr>
 
609
  <tr>
610
  <td class="plugin-title column-primary">
611
  <div class="wpvivid-storage-form">
411
  </div>
412
  <table class="wp-list-table widefat plugins" style="width:100%;">
413
  <tbody>
414
+ <form>
415
  <tr>
416
  <td class="plugin-title column-primary">
417
  <div class="wpvivid-storage-form">
498
  </div>
499
  </td>
500
  </tr>
501
+ </form>
502
  <tr>
503
  <td class="plugin-title column-primary">
504
  <div class="wpvivid-storage-form">
514
  </tbody>
515
  </table>
516
  </div>
 
 
 
 
 
 
 
 
 
 
517
  <?php
518
  }
519
 
526
  </div>
527
  <table class="wp-list-table widefat plugins" style="width:100%;">
528
  <tbody>
529
+ <form>
530
  <tr>
531
  <td class="plugin-title column-primary">
532
  <div class="wpvivid-storage-form">
599
  </div>
600
  </td>
601
  </tr>
602
+ </form>
603
  <tr>
604
  <td class="plugin-title column-primary">
605
  <div class="wpvivid-storage-form">
includes/customclass/class-wpvivid-sftpclass.php CHANGED
@@ -49,6 +49,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
49
  </div>
50
  <table class="wp-list-table widefat plugins" style="width:100%;">
51
  <tbody>
 
52
  <tr>
53
  <td class="plugin-title column-primary">
54
  <div class="wpvivid-storage-form">
@@ -135,6 +136,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
135
  </div>
136
  </td>
137
  </tr>
 
138
  <tr>
139
  <td class="plugin-title column-primary">
140
  <div class="wpvivid-storage-form">
@@ -162,6 +164,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
162
  </div>
163
  <table class="wp-list-table widefat plugins" style="width:100%;">
164
  <tbody>
 
165
  <tr>
166
  <td class="plugin-title column-primary">
167
  <div class="wpvivid-storage-form">
@@ -234,6 +237,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
234
  </div>
235
  </td>
236
  </tr>
 
237
  <tr>
238
  <td class="plugin-title column-primary">
239
  <div class="wpvivid-storage-form">
49
  </div>
50
  <table class="wp-list-table widefat plugins" style="width:100%;">
51
  <tbody>
52
+ <form>
53
  <tr>
54
  <td class="plugin-title column-primary">
55
  <div class="wpvivid-storage-form">
136
  </div>
137
  </td>
138
  </tr>
139
+ </form>
140
  <tr>
141
  <td class="plugin-title column-primary">
142
  <div class="wpvivid-storage-form">
164
  </div>
165
  <table class="wp-list-table widefat plugins" style="width:100%;">
166
  <tbody>
167
+ <form>
168
  <tr>
169
  <td class="plugin-title column-primary">
170
  <div class="wpvivid-storage-form">
237
  </div>
238
  </td>
239
  </tr>
240
+ </form>
241
  <tr>
242
  <td class="plugin-title column-primary">
243
  <div class="wpvivid-storage-form">
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: move, clone, migrate, copy, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
  Tested up to: 5.3
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.29
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -166,6 +166,11 @@ Thank you for translating WPvivid Backup Plugin to your languages!
166
  * [Andrew Galas](https://profiles.wordpress.org/andrewgalas) (Polish)
167
 
168
  == Changelog ==
 
 
 
 
 
169
  = 0.9.29 =
170
  - Successfully tested with WordPress 5.3.
171
  - Fixed: Locked backups were deleted automatically.
4
  Requires at least: 4.5
5
  Tested up to: 5.3
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.30
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
166
  * [Andrew Galas](https://profiles.wordpress.org/andrewgalas) (Polish)
167
 
168
  == Changelog ==
169
+ = 0.9.30 =
170
+ - Added an option to select database accessing method for a backup or restore process.
171
+ - Optimized plugin code and set the autoload attribute to no.
172
+ - Improved the success rate of backing up the uploads folder when the optimization mode for web hosting/shared hosting is enabled.
173
+ - Fixed some bugs in plugin code.
174
  = 0.9.29 =
175
  - Successfully tested with WordPress 5.3.
176
  - Fixed: Locked backups were deleted automatically.
uninstall.php CHANGED
@@ -20,6 +20,26 @@ delete_option('wpvivid_download_cache');
20
  delete_option('wpvivid_download_task');
21
  delete_option('wpvivid_user_history');
22
  delete_option('wpvivid_saved_api_token');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  define('WPVIVID_MAIN_SCHEDULE_EVENT','wpvivid_main_schedule_event');
24
 
25
  if(wp_get_schedule(WPVIVID_MAIN_SCHEDULE_EVENT))
20
  delete_option('wpvivid_download_task');
21
  delete_option('wpvivid_user_history');
22
  delete_option('wpvivid_saved_api_token');
23
+ delete_option('wpvivid_import_list_cache');
24
+ delete_option('wpvivid_importer_task_list');
25
+ delete_option('wpvivid_list_cache');
26
+ delete_option('wpvivid_exporter_task_list');
27
+ delete_option('wpvivid_need_review');
28
+ delete_option('wpvivid_review_msg');
29
+ delete_option('wpvivid_migrate_status');
30
+ delete_option('clean_task');
31
+ delete_option('cron_backup_count');
32
+ delete_option('wpvivid_backup_success_count');
33
+ delete_option('wpvivid_backup_error_array');
34
+ delete_option('wpvivid_amazons3_notice');
35
+ delete_option('wpvivid_hide_mwp_tab_page');
36
+ delete_option('wpvivid_hide_wp_cron_notice');
37
+ delete_option('wpvivid_transfer_error_array');
38
+ delete_option('wpvivid_transfer_success_count');
39
+ delete_option('wpvivid_api_token');
40
+ delete_option('wpvivid_download_task_v2');
41
+ delete_option('wpvivid_export_list');
42
+
43
  define('WPVIVID_MAIN_SCHEDULE_EVENT','wpvivid_main_schedule_event');
44
 
45
  if(wp_get_schedule(WPVIVID_MAIN_SCHEDULE_EVENT))
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.29
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.29' );
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.30
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.30' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');