PluginProbe
WPvivid Backup for MainWP / trunk
WPvivid Backup for MainWP vtrunk
0.9.42 trunk 0.9.10 0.9.11 0.9.12 0.9.13 0.9.14 0.9.15 0.9.16 0.9.17 0.9.18 0.9.19 0.9.2 0.9.20 0.9.21 0.9.22 0.9.23 0.9.24 0.9.25 0.9.26 0.9.27 0.9.28 0.9.29 0.9.3 0.9.30 All 42 releases
wpvivid-backup-mainwp / wpvivid-backup-mainwp.php
wpvivid-backup-mainwp.php
2,362 lines 110.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: WPvivid Backup MainWP
5 * Plugin URI: https://mainwp.com/
6 * Description: WPvivid Backup for MainWP enables you to create and download backups of a specific child site, set backup schedules, connect with your remote storage and set settings for all of your child sites directly from your MainWP dashboard.
7 * Version: 0.9.42
8 * Author: WPvivid Team
9 * Author URI: https://wpvivid.com
10 * License: GPL-3.0+
11 * License URI: http://www.gnu.org/copyleft/gpl.html
12 * Documentation URI: https://docs.wpvivid.com/wpvivid-backup-for-mainwp.html
13 */
14
15 define('MAINWP_WPVIVID_EXTENSION_PLUGIN_DIR',dirname(__FILE__));
16 define('MAINWP_WPVIVID_EXTENSION_PLUGIN_URL',plugins_url('',__FILE__));
17 define('MAINWP_WPVIVID_SUCCESS','success');
18 define('MAINWP_WPVIVID_FAILED','failed');
19
20 use MainWP\Dashboard;
21
22 class Mainwp_WPvivid_Extension_Activator
23 {
24 protected $plugin_handle = 'wpvivid-backup-mainwp';
25 protected $product_id = 'WPvivid Backup MainWP';
26 protected $version = '0.9.42';
27 protected $childEnabled;
28 public $childKey;
29 public $childFile;
30 protected $mainwpMainActivated;
31
32 public $remote;
33
34 public $login;
35 public $setting;
36 public $dashboard;
37 public $schedule;
38 public $incremental_schedule;
39 public $white_label;
40 public $remote_page;
41 public $capability;
42 public $backup_page;
43 public $backup_restore_page;
44 private $mainwp_wpvivid_backups_db_version = '1.0';
45
46 public function __construct()
47 {
48 $this->load_dependencies();
49
50 $this->remote=new Mainwp_WPvivid_Remote_collection();
51 $this->childFile = __FILE__;
52 add_filter( 'mainwp_getextensions', array( &$this, 'get_this_extension' ) );
53 add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_assets' ) );
54 add_filter( 'admin_body_class', array( &$this, 'add_admin_body_class' ) );
55
56 $primary_backup = get_option( 'mainwp_primaryBackup', null );
57 if ( 'wpvivid' == $primary_backup ) {
58 add_filter( 'mainwp_managesites_getbackuplink', array( $this, 'managesites_backup_link' ), 10, 2 );
59 }
60
61 $this->mainwpMainActivated = apply_filters( 'mainwp_activated_check', false );
62 if ( $this->mainwpMainActivated !== false )
63 {
64 $this->activate_this_plugin();
65 } else {
66 add_action( 'mainwp_activated', array( &$this, 'activate_this_plugin' ) );
67 }
68
69 $this->init_database();
70
71 $this->load_ajax_hook();
72 add_filter( 'mainwp_getsubpages_sites', array( &$this, 'managesites_subpage' ), 10, 1 );
73 add_filter( 'mainwp_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
74 add_action( 'mainwp_site_synced', array( $this, 'synced_site' ), 10, 2 );
75
76 //add_filter( 'mainwp-sync-extensions-options', array( &$this, 'mainwp_sync_extensions_options' ), 10, 1 );
77
78 add_action( 'mainwp_delete_site', array( &$this, 'delete_site_data' ), 10, 1 );
79 add_filter( 'mainwp_getprimarybackup_methods', array( $this, 'primary_backups_method' ), 10, 1 );
80
81 add_filter('mwp_wpvivid_set_schedule_notice', array($this, 'set_schedule_notice'), 10, 2);
82 add_filter('mwp_wpvivid_add_remote_storage_list', array( $this, 'add_remote_storage_list' ), 10);
83
84 add_filter( 'mainwp_plugins_install_checks', array( $this, 'wpvivid_mainwp_plugins_install_checks' ), 10, 1 );
85
86 if(!defined( 'DOING_CRON' ))
87 {
88 if(wp_get_schedule('mwp_wpvivid_check_version_event')===false)
89 {
90 wp_schedule_event(time()+10, 'hourly', 'mwp_wpvivid_check_version_event');
91 }
92 if(wp_get_schedule('mwp_wpvivid_refresh_latest_pro_version_event')===false)
93 {
94 wp_schedule_event(time()+10, 'daily', 'mwp_wpvivid_refresh_latest_pro_version_event');
95 }
96 }
97 }
98
99 public function wpvivid_mainwp_plugins_install_checks($plugins)
100 {
101 global $mainwp_wpvivid_extension_activator;
102
103 $select_pro=$mainwp_wpvivid_extension_activator->get_global_select_pro();
104
105 if($select_pro)
106 {
107 }
108 else
109 {
110 $plugins[] = array(
111 'page' => 'Extensions-Wpvivid-Backup-Mainwp',
112 'slug' => 'wpvivid-backuprestore/wpvivid-backuprestore.php',
113 'name' => 'WPvivid Backup Plugin',
114 );
115 }
116
117 return $plugins;
118 }
119
120 public function managesites_backup_link( $input, $site_id )
121 {
122 if ( $site_id )
123 {
124 $last_backup = 'Never';
125 $report = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'report_addon', array());
126 if(isset($report) && !empty($report)){
127 usort($report, function($a, $b){
128 if($a['backup_time'] === $b['backup_time']){
129 return 0;
130 }
131 else if($a['backup_time'] > $b['backup_time']){
132 return -1;
133 }
134 else{
135 return 1;
136 }
137 });
138
139 $time_zone=Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($site_id, 'time_zone', '');
140 if(empty($time_zone)){
141 $time_zone = 0;
142 }
143
144 foreach ($report as $task_id => $report_option) {
145 if($report_option['status'] === 'Succeeded') {
146 //$last_backup = date("H:i:s - m/d/Y", $report_option['backup_time']);
147 $last_backup = date("F d, Y H:i", $report_option['backup_time'] + $time_zone * 60 * 60);
148 break;
149 }
150 }
151 $output = $last_backup . '<br />';
152 }
153 else{
154 $last_backup = 'Never';
155 $output = '<span class="mainwp-red">Never</span><br/>';
156 }
157
158 if ( mainwp_current_user_can( 'dashboard', 'execute_backups' ) ) {
159 $output .= sprintf( '<a href="admin.php?page=ManageSitesWPvivid&id=%s">' . __( 'Backup Now', 'mainwp' ) . '</a>', $site_id );
160 }
161 return $output;
162 }
163 else {
164 return $input;
165 }
166 }
167
168 public function wpvivid_cron_schedules($schedules)
169 {
170 if(!isset($schedules["hourly"])){
171 $schedules["hourly"] = array(
172 'interval' => 3600,
173 'display' => __('Once Hourly'));
174 }
175 return $schedules;
176 }
177
178 public function load_dependencies()
179 {
180 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. 'wpvivid-backup-mainwp-setting.php';
181 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. 'wpvivid-backup-mainwp-subpage.php';
182 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. 'wpvivid-backup-mainwp-option.php';
183 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. 'wpvivid-backup-mainwp-db-option.php';
184
185 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-backupmanager.php';
186 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-backuprestorepage.php';
187
188 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/includes/class-wpvivid-mainwp-connect-server.php';
189 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/includes/class-wpvivid-crypt.php';
190 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/includes/class-wpvivid-remote-collection.php';
191
192 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-loginpage.php';
193 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-settingpage.php';
194 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-dashboardpage.php';
195 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-schedulepage.php';
196 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-incremental-backup.php';
197 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-white-label.php';
198 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-remotepage.php';
199 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-capabilitypage.php';
200 include_once dirname(__FILE__) .DIRECTORY_SEPARATOR. '/admin/wpvivid-backup-mainwp-backuppage.php';
201
202 $this->login=new Mainwp_WPvivid_Extension_LoginPage();
203 $this->setting=new Mainwp_WPvivid_Extension_SettingPage();
204 $this->dashboard=new Mainwp_WPvivid_Extension_DashboardPage();
205 $this->schedule=new Mainwp_WPvivid_Extension_SchedulePage();
206 $this->incremental_schedule=new Mainwp_WPvivid_Extension_Incremental_Backup();
207 $this->white_label=new Mainwp_WPvivid_Extension_White_Label();
208 $this->remote_page=new Mainwp_WPvivid_Extension_RemotePage();
209 $this->capability=new Mainwp_WPvivid_Extension_Capability();
210 $this->backup_page=new Mainwp_WPvivid_Extension_BackupPage();
211 $this->backup_restore_page=new Mainwp_WPvivid_Extension_BackupRestorePage();
212 }
213
214 public function load_ajax_hook()
215 {
216 add_action('wp_ajax_mwp_wpvivid_switch_pro_setting', array($this, 'switch_pro_setting'));
217 add_action('wp_ajax_mwp_wpvivid_set_individual', array( $this, 'set_individual'));
218
219 //check pro need update
220 add_action('mwp_wpvivid_check_version_event',array( $this,'mwp_wpvivid_check_version_event'));
221 add_action('mwp_wpvivid_refresh_latest_pro_version_event',array($this, 'mwp_wpvivid_refresh_latest_pro_version_event'));
222
223 add_filter('mwp_wpvivid_custom_backup_data_transfer', array($this, 'mwp_wpvivid_custom_backup_data_transfer'), 10, 3);
224 }
225
226 public function init_database()
227 {
228 Mainwp_WPvivid_Extension_DB_Option::get_instance()->import_settings();
229 Mainwp_WPvivid_Extension_DB_Option::get_instance()->import_global_settings();
230
231 $currentVersion = get_site_option( 'mainwp_wpvivid_backups_db_version' );
232
233 $query_wpvividmeta = $this->query("SHOW TABLES LIKE '" . Mainwp_WPvivid_Extension_DB_Option::get_instance()->get_table_name('wpvividmeta') . "'");
234 if ( @self::num_rows( $query_wpvividmeta ) == 0 )
235 {
236 $currentVersion = false;
237 }
238
239 $query_wpvivid_global_options = $this->query("SHOW TABLES LIKE '" . Mainwp_WPvivid_Extension_DB_Option::get_instance()->get_table_name('wpvivid_global_options') . "'");
240 if ( @self::num_rows( $query_wpvivid_global_options ) == 0 )
241 {
242 $currentVersion = false;
243 }
244
245 $query_wpvivid = $this->query("SHOW TABLES LIKE '" . Mainwp_WPvivid_Extension_Option::get_instance()->get_table_name('wpvivid') . "'");
246 if ( @self::num_rows( $query_wpvivid ) == 0 )
247 {
248 $currentVersion = false;
249 }
250
251 $query_wpvivid_global = $this->query("SHOW TABLES LIKE '" . Mainwp_WPvivid_Extension_Option::get_instance()->get_table_name('wpvivid_global') . "'");
252 if ( @self::num_rows( $query_wpvivid_global ) == 0 )
253 {
254 $currentVersion = false;
255 }
256
257 if ( $currentVersion == $this->mainwp_wpvivid_backups_db_version )
258 {
259 return;
260 }
261
262 Mainwp_WPvivid_Extension_Option::get_instance()->init_options();
263 Mainwp_WPvivid_Extension_DB_Option::get_instance()->init_db_options();
264
265 update_option('mainwp_wpvivid_backups_db_version', $this->mainwp_wpvivid_backups_db_version);
266 }
267
268 public static function use_mysqli() {
269 /** @var $wpdb wpdb */
270 if ( ! function_exists( 'mysqli_connect' ) ) {
271 return false; }
272
273 global $wpdb;
274 return ( $wpdb->dbh instanceof mysqli );
275 }
276
277 public static function num_rows( $result ) {
278 if ( $result === false ) {
279 return 0;
280 }
281 if ( self::use_mysqli() ) {
282 return mysqli_num_rows( $result );
283 } else {
284 return mysql_num_rows( $result );
285 }
286 }
287
288 public function query( $sql ) {
289 if ( null == $sql ) {
290 return false; }
291 /** @var $wpdb wpdb */
292 global $wpdb;
293 $result = @self::_query( $sql, $wpdb->dbh );
294
295 if ( ! $result || ( @self::num_rows( $result ) == 0 ) ) {
296 return false; }
297 return $result;
298 }
299
300 public static function _query( $query, $link ) {
301 if ( self::use_mysqli() ) {
302 return mysqli_query( $link, $query );
303 } else {
304 return mysql_query( $query, $link );
305 }
306 }
307
308 public function sync_others_data( $data, $pWebsite = null )
309 {
310 if ( ! is_array( $data ) )
311 {
312 $data = array();
313 }
314
315 $data['syncWPvividData'] = 1;
316
317 return $data;
318 }
319
320 public function handle_custom_tree_data($options){
321 if(isset($options['uploads_option']['exclude_uploads_list']) && !empty($options['uploads_option']['exclude_uploads_list'])){
322 foreach ($options['uploads_option']['exclude_uploads_list'] as $key => $value){
323 if($value['type'] === 'wpvivid-custom-li-folder-icon'){
324 $value['type'] = 'mwp-wpvivid-custom-li-folder-icon';
325 }
326 else if($value['type'] === 'wpvivid-custom-li-file-icon'){
327 $value['type'] = 'mwp-wpvivid-custom-li-file-icon';
328 }
329 $options['uploads_option']['exclude_uploads_list'][$key] = $value;
330 }
331 }
332 if(isset($options['content_option']['exclude_content_list']) && !empty($options['content_option']['exclude_content_list'])){
333 foreach ($options['content_option']['exclude_content_list'] as $key => $value){
334 if($value['type'] === 'wpvivid-custom-li-folder-icon'){
335 $value['type'] = 'mwp-wpvivid-custom-li-folder-icon';
336 }
337 else if($value['type'] === 'wpvivid-custom-li-file-icon'){
338 $value['type'] = 'mwp-wpvivid-custom-li-file-icon';
339 }
340 $options['content_option']['exclude_content_list'][$key] = $value;
341 }
342 }
343 if(isset($options['other_option']['include_other_list']) && !empty($options['other_option']['include_other_list'])){
344 foreach ($options['other_option']['include_other_list'] as $key => $value){
345 if($value['type'] === 'wpvivid-custom-li-folder-icon'){
346 $value['type'] = 'mwp-wpvivid-custom-li-folder-icon';
347 }
348 else if($value['type'] === 'wpvivid-custom-li-file-icon'){
349 $value['type'] = 'mwp-wpvivid-custom-li-file-icon';
350 }
351 $options['other_option']['include_other_list'][$key] = $value;
352 }
353 }
354 return $options;
355 }
356
357 public function synced_site( $pWebsite, $information = array() )
358 {
359 if ( is_array( $information ) )
360 {
361 if ( isset( $information['syncWPvividData'] ) )
362 {
363 if(isset($information['syncWPvividSetting'])){
364 $data['settings'] = isset($information['syncWPvividSetting']['setting']) ? serialize($information['syncWPvividSetting']['setting']) : '';
365 $data_meta['settings'] = isset($information['syncWPvividSetting']['setting']) ? ($information['syncWPvividSetting']['setting']) : '';//
366 $data['settings_addon'] = isset($information['syncWPvividSetting']['setting_addon']) ? serialize($information['syncWPvividSetting']['setting_addon']) : '';
367 $data_meta['settings_addon'] = isset($information['syncWPvividSetting']['setting_addon']) ? ($information['syncWPvividSetting']['setting_addon']) : '';//
368 $data['schedule'] = isset($information['syncWPvividSetting']['schedule']) ? serialize($information['syncWPvividSetting']['schedule']) : '';
369 $data_meta['schedule'] = isset($information['syncWPvividSetting']['schedule']) ? ($information['syncWPvividSetting']['schedule']) : '';//
370 $data['schedule_addon'] = isset($information['syncWPvividSetting']['schedule_addon']) ? serialize($information['syncWPvividSetting']['schedule_addon']) : '';
371 $data_meta['schedule_addon'] = isset($information['syncWPvividSetting']['schedule_addon']) ? ($information['syncWPvividSetting']['schedule_addon']) : '';//
372 $data['remote'] = isset($information['syncWPvividSetting']['remote']) ? serialize($information['syncWPvividSetting']['remote']) : '';
373 $data_meta['remote'] = isset($information['syncWPvividSetting']['remote']) ? ($information['syncWPvividSetting']['remote']) : '';//
374 if(isset($information['syncWPvividSetting']['backup_custom_setting_ex'])) {
375 $information['syncWPvividSetting']['backup_custom_setting_ex'] = $this->handle_custom_tree_data($information['syncWPvividSetting']['backup_custom_setting_ex']);
376 $data['backup_custom_setting_ex'] = serialize($information['syncWPvividSetting']['backup_custom_setting_ex']);
377 $data_meta['backup_custom_setting_ex'] = ($information['syncWPvividSetting']['backup_custom_setting_ex']);
378 }
379 else{
380 $data['backup_custom_setting_ex'] = '';
381 $data_meta['backup_custom_setting_ex'] = '';
382 }
383 $data_meta['menu_capability'] = isset($information['syncWPvividSetting']['menu_capability']) ? $information['syncWPvividSetting']['menu_capability'] : '';
384 $data_meta['white_label_setting'] = isset($information['syncWPvividSetting']['white_label_setting']) ? $information['syncWPvividSetting']['white_label_setting'] : '';
385 $data_meta['incremental_backup_setting'] = isset($information['syncWPvividSetting']['incremental_backup_setting']) ? $information['syncWPvividSetting']['incremental_backup_setting'] : array();
386
387 $data_meta['dashboard_version'] = isset($information['syncWPvividSetting']['dashboard_version']) ? $information['syncWPvividSetting']['dashboard_version'] : '';
388 $data_meta['addons_info'] = isset($information['syncWPvividSetting']['addons_info']) ? $information['syncWPvividSetting']['addons_info'] : array();
389
390 if(isset($information['syncWPvividSetting']['is_mu'])){
391 $data_meta['is_mu'] = $information['syncWPvividSetting']['is_mu'] === true ? 1 : 0;
392 }
393 else{
394 $data_meta['is_mu'] = 0;
395 }
396
397 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_sync_options($pWebsite->id, $data_meta);
398 $data['need_update'] = isset($information['syncWPvividSetting']['need_update']) ? $information['syncWPvividSetting']['need_update'] : '';
399 $data['current_version'] = isset($information['syncWPvividSetting']['current_version']) ? $information['syncWPvividSetting']['current_version'] : '';
400 if(isset($information['syncWPvividSetting']['is_pro'])) {
401 $data['is_pro'] = $information['syncWPvividSetting']['is_pro'] === true ? 1 : 0;
402 if($data['is_pro'] === 1){
403 $sync_first = $this->get_global_first_init();
404 if(!$sync_first){
405 $this->set_global_first_init('first');
406 }
407 }
408 }
409 else{
410 $data['is_pro'] = 0;
411 }
412 if(isset($information['syncWPvividSetting']['is_install'])){
413 $data['is_install'] = $information['syncWPvividSetting']['is_install'] === true ? 1 : 0;
414 }
415 else{
416 $data['is_install'] = 0;
417 }
418 if(isset($information['syncWPvividSetting']['is_login'])){
419 $data['is_login'] = $information['syncWPvividSetting']['is_login'] === true ? 1 : 0;
420 }
421 else{
422 $data['is_login'] = 0;
423 }
424 $data['latest_version'] = isset($information['syncWPvividSetting']['latest_version']) ? $information['syncWPvividSetting']['latest_version'] : '';
425 $data['time_zone'] = isset($information['syncWPvividSetting']['time_zone']) ? $information['syncWPvividSetting']['time_zone'] : 0;
426 $last_backup_report = isset($information['syncWPvividSetting']['last_backup_report']) ? $information['syncWPvividSetting']['last_backup_report'] : array();
427 $this->set_backup_report($pWebsite->id, $last_backup_report);
428 //$data['report_addon'] = isset($information['syncWPvividSetting']['report_addon']) ? base64_encode(serialize($information['syncWPvividSetting']['report_addon'])) : '';
429
430 $login_options = $this->get_global_login_addon();
431 $tmp_version = 0;
432 if(isset($login_options['wpvivid_pro_login_cache']['pro']['version'])){
433 $tmp_version = $login_options['wpvivid_pro_login_cache']['pro']['version'];
434 }
435 else if(isset($login_options['wpvivid_pro_login_cache']['dashboard']['version'])){
436 $tmp_version = $login_options['wpvivid_pro_login_cache']['dashboard']['version'];
437 }
438 if(isset($login_options['wpvivid_pro_login_cache']))
439 {
440 if (isset($data['current_version']))
441 {
442 if(version_compare($tmp_version, $data['current_version'],'>'))
443 {
444 $data['need_update']=1;
445 $data['latest_version']=$tmp_version;
446 }
447 else{
448 $data['need_update']=0;
449 }
450 }
451 else{
452 $data['need_update']=1;
453 $data['latest_version']=$tmp_version;
454 }
455 }
456
457 unset($data['backup_custom_setting_ex']);
458 Mainwp_WPvivid_Extension_Option::get_instance()->sync_options($pWebsite->id,$data);
459 unset($data['wpvivid_setting']);
460 unset($data['need_update']);
461 unset($data['current_version']);
462 unset($data['is_pro']);
463 unset($data['is_install']);
464 unset($data['is_login']);
465 unset($data['latest_version']);
466 unset($data['time_zone']);
467 //unset($data['report_addon']);
468 if(!Mainwp_WPvivid_Extension_Option::get_instance()->is_set_global_options()) {
469 Mainwp_WPvivid_Extension_Option::get_instance()->set_global_options($data);
470 }
471 unset( $information['syncWPvividSetting'] );
472 unset( $information['syncWPvividData'] );
473 }
474 else{
475 $this->set_sync_error($pWebsite->id, 2);
476 }
477 }
478 else{
479 $this->set_sync_error($pWebsite->id, 1);
480 }
481 }
482 }
483
484 public function delete_site_data($website)
485 {
486 if ( $website )
487 {
488 Mainwp_WPvivid_Extension_Option::get_instance()->delete_site($website->id );
489 }
490 }
491
492 /*public function mainwp_sync_extensions_options($values = array()) {
493 $values['wpvivid-backup-mainwp'] = array(
494 'plugin_name' => 'WPvivid Backup Plugin',
495 'plugin_slug' => 'wpvivid-backuprestore/wpvivid-backuprestore.php'
496 );
497 return $values;
498 }*/
499
500 public function primary_backups_method( $methods )
501 {
502 $methods[] = array( 'value' => 'wpvivid', 'title' => 'WPvivid Backup for MainWP' );
503 return $methods;
504 }
505
506 public function set_schedule_notice($notice_type, $message)
507 {
508 $html = '';
509 if($notice_type)
510 {
511 $html .= '<div class="notice notice-success is-dismissible inline" style="margin: 0; padding-top: 10px; margin-bottom: 10px; margin-left: 0px !important;"><p>'.esc_html($message).'</p>
512 <button type="button" class="notice-dismiss" onclick="mwp_click_dismiss_notice(this);">
513 <span class="screen-reader-text">Dismiss this notice.</span>
514 </button>
515 </div>';
516 }
517 else{
518 $html .= '<div class="notice notice-error inline" style="margin: 0; padding: 10px; margin-bottom: 10px; margin-left: 0px !important;"><p>' . esc_html($message) . '</p></div>';
519 }
520 return $html;
521 }
522
523 public function check_site_id_secure($site_id)
524 {
525 if(Mainwp_WPvivid_Extension_Option::get_instance()->is_vaild_child_site($site_id)){
526 return true;
527 }
528 else{
529 return false;
530 }
531 }
532
533 public function enqueue_admin_assets($hook = '')
534 {
535 if(!$this->is_wpvivid_mainwp_admin_page())
536 {
537 return;
538 }
539
540 wp_enqueue_style('Mainwp Wpvivid Extension', plugin_dir_url(__FILE__) . 'admin/css/wpvivid-backup-mainwp-admin.css', array(), $this->version, 'all');
541 wp_enqueue_style('Mainwp Wpvivid Extension'.'jstree', plugin_dir_url(__FILE__) . 'admin/js/jstree/dist/themes/default/style.min.css', array(), $this->version, 'all');
542
543 wp_enqueue_script('Mainwp Wpvivid Extension', plugin_dir_url(__FILE__) . 'admin/js/wpvivid-backup-mainwp-admin.js', array('jquery'), $this->version, false);
544 wp_enqueue_script('Mainwp Wpvivid Extension'.'jstree', plugin_dir_url(__FILE__) . 'admin/js/jstree/dist/jstree.min.js', array('jquery'), $this->version, false);
545 wp_localize_script('Mainwp Wpvivid Extension', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php'), 'ajax_nonce'=>wp_create_nonce('wpvivid_mainwp_ajax')));
546 if(isset($_GET['id']) && !empty($_GET['id'])) {
547 $site_id=sanitize_key($_GET['id']);
548 wp_add_inline_script( 'Mainwp Wpvivid Extension', 'site_id='.$site_id);
549 }
550 }
551
552 public function add_admin_body_class($classes)
553 {
554 if($this->is_wpvivid_mainwp_admin_page())
555 {
556 $classes .= ' wpvivid-mainwp-page';
557 }
558
559 return $classes;
560 }
561
562 private function is_wpvivid_mainwp_admin_page()
563 {
564 if(!is_admin())
565 {
566 return false;
567 }
568
569 if(!isset($_GET['page']) || empty($_GET['page']) || !is_string($_GET['page']))
570 {
571 return false;
572 }
573
574 $page = sanitize_key(wp_unslash($_GET['page']));
575 $wpvivid_pages = array(
576 'extensions-wpvivid-backup-mainwp',
577 'managesiteswpvivid',
578 );
579
580 return in_array($page, $wpvivid_pages, true);
581 }
582
583 public function managesites_subpage( $subPage )
584 {
585 $subPage[] = array(
586 'title' => __( 'WPvivid Backups', 'mainwp' ),
587 'slug' => 'WPvivid',
588 'sitetab' => true,
589 'menu_hidden' => true,
590 'callback' => array( $this, 'render' ),
591 );
592 return $subPage;
593 }
594
595 function render()
596 {
597 do_action( "mainwp_pageheader_sites", "WPvivid" );
598 Mainwp_WPvivid_Extension_Subpage::renderSubpage();
599 do_action( "mainwp_pagefooter_sites", "WPvivid" );
600 }
601
602 function get_this_extension( $pArray )
603 {
604 $extension['plugin']=__FILE__;
605 $extension['mainwp']=false;
606 $extension['callback']=array(&$this, 'settings');
607 $extension['icon']=MAINWP_WPVIVID_EXTENSION_PLUGIN_URL.'/admin/images/logo.png';
608 $pArray[] = $extension;
609 return $pArray;
610 }
611
612 function activate_this_plugin()
613 {
614 $this->mainwpMainActivated = apply_filters( 'mainwp_activated_check', $this->mainwpMainActivated );
615 $this->childEnabled = apply_filters( 'mainwp_extension_enabled_check', __FILE__ );
616 $this->childKey = $this->childEnabled['key'];
617 }
618
619 function settings()
620 {
621 do_action( 'mainwp_pageheader_extensions', $this->childFile );
622 Mainwp_WPvivid_Extension_Setting::renderSetting();
623 do_action( 'mainwp_pagefooter_extensions', $this->childFile );
624 }
625
626 public function switch_pro_setting()
627 {
628 $this->mwp_ajax_check_security();
629 try{
630 if(isset($_POST['pro_setting']) && is_string($_POST['pro_setting'])){
631 $pro_setting = sanitize_text_field($_POST['pro_setting']);
632 if($pro_setting == '1'){
633 $this->set_global_switch_pro_setting_page(1);
634 }
635 else{
636 $this->set_global_switch_pro_setting_page(0);
637 }
638 $this->set_global_select_pro($pro_setting);
639 $ret['result'] = 'success';
640 echo wp_json_encode($ret);
641 }
642 }
643 catch (Exception $error) {
644 $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
645 error_log($message);
646 echo wp_json_encode(array('result'=>'failed','error'=>$message));
647 }
648 die();
649 }
650
651 public function set_individual()
652 {
653 $this->mwp_ajax_check_security();
654 try {
655 if(isset($_POST['site_id']) && !empty($_POST['site_id']) && is_string($_POST['site_id']) &&
656 isset($_POST['individual']) && is_string($_POST['individual'])) {
657 $site_id = sanitize_key($_POST['site_id']);
658 $individual = sanitize_text_field($_POST['individual']);
659 $individual = intval($individual);
660 Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_update_single_option($site_id, 'individual', $individual);
661 $ret['result'] = 'success';
662 echo wp_json_encode($ret);
663 }
664 die();
665 }
666 catch (Exception $error) {
667 $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
668 error_log($message);
669 echo wp_json_encode(array('result'=>'failed','error'=>$message));
670 die();
671 }
672 }
673
674
675
676
677
678 public function mwp_wpvivid_get_website_plugins_list($site_id)
679 {
680 $plugins = array();
681 $dbwebsites = $this->mwp_get_child_websites();
682 foreach ($dbwebsites as $website)
683 {
684 if ($website)
685 {
686 if ($website->id === $site_id)
687 {
688 $plugins = json_decode($website->plugins, 1);
689 }
690 }
691 }
692 return $plugins;
693 }
694
695 public function get_is_login($site_id)
696 {
697 $is_login_pro = Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($site_id, 'is_login', false);
698 if(empty($is_login_pro)){
699 $is_login_pro = false;
700 }
701 return $is_login_pro;
702 }
703
704 public function set_is_login($site_id, $is_login)
705 {
706 Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_update_single_option($site_id, 'is_login', $is_login);
707 }
708
709 public function get_latest_version($site_id)
710 {
711 $latest_version = Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($site_id, 'latest_version', '');
712 if(empty($latest_version)){
713 $latest_version = '';
714 }
715 return $latest_version;
716 }
717
718 public function set_latest_version($site_id, $version)
719 {
720 Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_update_single_option($site_id, 'latest_version', $version);
721 }
722
723 public function get_current_version($site_id)
724 {
725 $current_version = Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($site_id, 'current_version', '');
726 return $current_version;
727 }
728
729 public function set_current_version($site_id, $version)
730 {
731 Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_update_single_option($site_id, 'current_version', $version);
732 }
733
734 public function get_need_update($site_id)
735 {
736 $need_update = Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($site_id, 'need_update', '');
737 return $need_update;
738 }
739
740 public function set_need_update($site_id, $need_update)
741 {
742 Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_update_single_option($site_id, 'need_update', $need_update);
743 }
744
745 public function set_sync_error($site_id, $sync_error)
746 {
747 Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_update_single_option($site_id, 'sync_error', $sync_error);
748 }
749
750 public function set_backup_report($site_id, $option)
751 {
752 $reports = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'report_addon', array());
753 if(!empty($reports)){
754 foreach ($option as $key => $value){
755 $reports[$key] = $value;
756 $reports = $this->clean_out_of_date_report($reports, 10);
757 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'report_addon', $reports);
758 }
759 }
760 else{
761 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'report_addon', $option);
762 }
763 }
764
765 public static function get_oldest_backup_id($report_list)
766 {
767 $oldest_id='not set';
768 $oldest=0;
769 foreach ($report_list as $key=>$value)
770 {
771 if ($oldest == 0) {
772 $oldest = $value['backup_time'];
773 $oldest_id = $key;
774 } else {
775 if ($oldest > $value['backup_time']) {
776 $oldest_id = $key;
777 }
778 }
779 }
780 return $oldest_id;
781 }
782
783 function clean_out_of_date_report($report_list, $max_report_count)
784 {
785 $size=sizeof($report_list);
786 while($size>$max_report_count)
787 {
788 $oldest_id=self::get_oldest_backup_id($report_list);
789
790 if($oldest_id!='not set')
791 {
792 unset($report_list[$oldest_id]);
793 }
794 $new_size=sizeof($report_list);
795 if($new_size==$size)
796 {
797 break;
798 }
799 else
800 {
801 $size=$new_size;
802 }
803 }
804 return $report_list;
805 }
806
807
808
809 public function get_global_first_init()
810 {
811 $sync_init_addon_first=Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('sync_init_addon_first', '');
812 return $sync_init_addon_first;
813 }
814
815 public function set_global_first_init($first)
816 {
817 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('sync_init_addon_first', $first);
818 }
819
820 public function get_global_switch_pro_setting_page()
821 {
822 $switch_pro_setting_page=Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('switch_pro_setting_page', '');
823 return $switch_pro_setting_page;
824 }
825
826 public function set_global_switch_pro_setting_page($pro_setting_page)
827 {
828 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('switch_pro_setting_page', $pro_setting_page);
829 }
830
831 public function get_global_select_pro()
832 {
833 $select_pro=Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('select_pro', '');
834 return $select_pro;
835 }
836
837 public function set_global_select_pro($select_pro)
838 {
839 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('select_pro', $select_pro);
840 }
841
842 public function get_global_login_addon()
843 {
844 $login_addon=Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('login_addon', array());
845 if ( !is_array($login_addon) || empty($login_addon) ) {
846 $login_addon = array();
847 }
848 return $login_addon;
849 }
850
851 public function set_global_login_addon($login_addon)
852 {
853 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('login_addon', $login_addon);
854 }
855
856 public function add_remote_storage_list($html)
857 {
858 $html = '';
859 $options=Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('remote', array());
860 $remoteslist=$options['upload'];
861 $history=$options['history'];
862 $default_remote_storage='';
863 if(isset($history['remote_selected'])) {
864 foreach ($history['remote_selected'] as $value) {
865 $default_remote_storage = $value;
866 }
867 }
868 $i=1;
869 foreach ($remoteslist as $key=>$value)
870 {
871 if($key === 'remote_selected')
872 {
873 continue;
874 }
875 if ($key === $default_remote_storage)
876 {
877 $check_status = 'checked';
878 }
879 else
880 {
881 $check_status='';
882 }
883 $storage_type = $value['type'];
884 $storage_type=apply_filters('wpvivid_storage_provider_tran', $storage_type);
885 $html .= '<tr>
886 <td>'.esc_html($i++).'</td>
887 <td><input type="checkbox" name="remote_storage" value="'.esc_attr($key).'" '.esc_attr($check_status).' /></td>
888 <td>'.esc_html($storage_type).'</td>
889 <td class="row-title"><label for="tablecell">'.esc_html($value['name']).'</label></td>
890 <td>
891 <div><img src="'.esc_url(MAINWP_WPVIVID_EXTENSION_PLUGIN_URL.'/admin/images/Delete.png').'" onclick="mwp_wpvivid_delete_remote_storage(\''.esc_js($key).'\');" style="vertical-align:middle; cursor:pointer;" title="Remove the remote storage"/></div>
892 </td>
893 </tr>';
894 }
895 return $html;
896 }
897
898 public function mwp_wpvivid_check_version_event(){
899 $websites=$this->get_websites_ex();
900 foreach ( $websites as $website ){
901 $site_id = $website['id'];
902 if($website['slug'] === 'wpvivid-backup-pro/wpvivid-backup-pro.php'){
903 $post_data['mwp_action'] = 'wpvivid_get_wpvivid_info_addon_mainwp';
904 $information = apply_filters('mainwp_fetchurlauthed', $this->childFile, $this->childKey, $site_id, 'wpvivid_backuprestore', $post_data);
905 if (isset($information['error'])) {
906 $ret['result'] = 'failed';
907 $ret['error'] = $information['error'];
908 } else {
909 $ret['result'] = 'success';
910 if(isset($information['need_update'])){
911 if($information['need_update']){
912 $need_update = 1;
913 }
914 else{
915 $need_update = 0;
916 }
917 }
918 else{
919 $need_update = 0;
920 }
921 $login_options = $this->get_global_login_addon();
922 if(isset($login_options['wpvivid_pro_login_cache'])){
923
924 $tmp_version = 0;
925 if(isset($login_options['wpvivid_pro_login_cache']['pro']['version'])){
926 $tmp_version = $login_options['wpvivid_pro_login_cache']['pro']['version'];
927 }
928 else if(isset($login_options['wpvivid_pro_login_cache']['dashboard']['version'])){
929 $tmp_version = $login_options['wpvivid_pro_login_cache']['dashboard']['version'];
930 }
931
932 if (isset($information['current_version'])) {
933 if(version_compare($tmp_version, $information['current_version'],'>')){
934 $this->set_need_update($site_id, 1);
935 $this->set_current_version($site_id, $information['current_version']);
936 $this->set_latest_version($site_id, $tmp_version);
937 }
938 else{
939 $this->set_need_update($site_id, 0);
940 $this->set_current_version($site_id, $information['current_version']);
941 }
942 }
943 else{
944 $this->set_need_update($site_id, 1);
945 $this->set_latest_version($site_id, $tmp_version);
946 }
947 }
948 else {
949 $this->set_need_update($site_id, $need_update);
950 if (isset($information['current_version'])) {
951 $current_version = $information['current_version'];
952 $this->set_current_version($site_id, $current_version);
953 }
954 }
955 if(isset($information['last_backup_report'])){
956 $last_backup_report = $information['last_backup_report'];
957 $this->set_backup_report($site_id, $last_backup_report);
958 }
959 }
960 }
961 }
962 }
963
964 public function mwp_wpvivid_refresh_latest_pro_version_event(){
965 $login_options = $this->get_global_login_addon();
966 if($login_options !== false && isset($login_options['wpvivid_pro_account'])) {
967 if(!isset($login_options['wpvivid_pro_account']['user_info']))
968 {
969 $ret['result'] = 'failed';
970 $ret['error'] = 'Failed to get previously entered login information, please login again.';
971 echo wp_json_encode($ret);
972 die();
973 }
974 $user_info=$login_options['wpvivid_pro_account']['user_info'];
975 $server=new Mainwp_WPvivid_Connect_server();
976 $ret=$server->get_mainwp_status($user_info,false);
977 if($ret['result']=='success') {
978
979 $login_options = $this->get_global_login_addon();
980 $login_options['wpvivid_pro_login_cache'] = $ret['status'];
981 $this->set_global_login_addon($login_options);
982
983 $need_update = false;
984 if($login_options === false || !isset($login_options['wpvivid_pro_account'])){
985 $login_options = array();
986 $need_update = true;
987 }
988 else{
989 if(isset($login_options['wpvivid_pro_login_cache'])){
990 $tmp_version = 0;
991 if(isset($login_options['wpvivid_pro_login_cache']['pro']['version'])){
992 $tmp_version = $login_options['wpvivid_pro_login_cache']['pro']['version'];
993 }
994 else if(isset($login_options['wpvivid_pro_login_cache']['dashboard']['version'])){
995 $tmp_version = $login_options['wpvivid_pro_login_cache']['dashboard']['version'];
996 }
997 if(version_compare($ret['status']['dashboard']['version'], $tmp_version,'>')){
998 $need_update = true;
999 }
1000 else{
1001 $need_update = false;
1002 }
1003 }
1004 else{
1005 $need_update = true;
1006 }
1007 }
1008 if($need_update) {
1009 $this->check_child_site_need_update($ret['status']['dashboard']['version']);
1010 }
1011 }
1012 }
1013 }
1014
1015 public function check_child_site_need_update($new_version)
1016 {
1017 $dbwebsites = $this->mwp_get_child_websites();
1018 foreach ($dbwebsites as $website)
1019 {
1020 if ($website)
1021 {
1022 $old_version = $this->get_latest_version($website->id);
1023 if(version_compare($new_version, $old_version,'>')){
1024 $this->set_need_update($website->id, 1);
1025 $this->set_latest_version($website->id, $new_version);
1026 }
1027 }
1028 }
1029 }
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047 public function mwp_wpvivid_update_backup_exclude_extension_rule($site_id, $type, $value){
1048 $history = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'backup_custom_setting_ex', array());
1049 if(!$history){
1050 $history = array();
1051 }
1052 if($type === 'uploads'){
1053 $history['uploads_option']['uploads_extension_list'] = array();
1054 $str_tmp = explode(',', $value);
1055 for($index=0; $index<count($str_tmp); $index++){
1056 if(!empty($str_tmp[$index])) {
1057 $history['uploads_option']['uploads_extension_list'][] = $str_tmp[$index];
1058 }
1059 }
1060 }
1061 if($type === 'content'){
1062 $history['content_option']['content_extension_list'] = array();
1063 $str_tmp = explode(',', $value);
1064 for($index=0; $index<count($str_tmp); $index++){
1065 if(!empty($str_tmp[$index])) {
1066 $history['content_option']['content_extension_list'][] = $str_tmp[$index];
1067 }
1068 }
1069 }
1070 if($type === 'additional_folder'){
1071 $history['other_option']['other_extension_list'] = array();
1072 $str_tmp = explode(',', $value);
1073 for($index=0; $index<count($str_tmp); $index++){
1074 if(!empty($str_tmp[$index])) {
1075 $history['other_option']['other_extension_list'][] = $str_tmp[$index];
1076 }
1077 }
1078 }
1079 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'backup_custom_setting_ex', $history);
1080 }
1081
1082
1083
1084 public function mwp_wpvivid_update_global_backup_exclude_extension_rule($type, $value){
1085 $history = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('backup_custom_setting', array());
1086 if(!$history){
1087 $history = array();
1088 }
1089 if($type === 'uploads'){
1090 $history['uploads_option']['uploads_extension_list'] = array();
1091 $str_tmp = explode(',', $value);
1092 for($index=0; $index<count($str_tmp); $index++){
1093 if(!empty($str_tmp[$index])) {
1094 $history['uploads_option']['uploads_extension_list'][] = $str_tmp[$index];
1095 }
1096 }
1097 }
1098 if($type === 'content'){
1099 $history['content_option']['content_extension_list'] = array();
1100 $str_tmp = explode(',', $value);
1101 for($index=0; $index<count($str_tmp); $index++){
1102 if(!empty($str_tmp[$index])) {
1103 $history['content_option']['content_extension_list'][] = $str_tmp[$index];
1104 }
1105 }
1106 }
1107 if($type === 'additional_folder'){
1108 $history['other_option']['other_extension_list'] = array();
1109 $str_tmp = explode(',', $value);
1110 for($index=0; $index<count($str_tmp); $index++){
1111 if(!empty($str_tmp[$index])) {
1112 $history['other_option']['other_extension_list'][] = $str_tmp[$index];
1113 }
1114 }
1115 }
1116 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('backup_custom_setting', $history);
1117 }
1118
1119
1120
1121
1122
1123 public function mwp_wpvivid_update_backup_custom_setting($site_id, $options){
1124 $custom_option = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'backup_custom_setting_ex', array());
1125 $custom_option['exclude_files'] = $options['exclude_files'];
1126 $custom_option['custom_dirs'] = $options['custom_dirs'];
1127 $custom_option['exclude_file_type'] = $options['exclude_file_type'];
1128
1129 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'backup_custom_setting_ex', $custom_option);
1130 }
1131
1132 public function mwp_wpvivid_update_global_backup_custom_setting($options){
1133 $history = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('backup_custom_setting', array());
1134
1135 $custom_option['database_option']['database_check'] = $options['database_check'];
1136
1137 $custom_option['themes_option']['themes_check'] = $options['themes_check'];
1138
1139 $custom_option['plugins_option']['plugins_check'] = $options['plugins_check'];
1140
1141 $custom_option['uploads_option']['uploads_check'] = $options['uploads_check'];
1142 $custom_option['uploads_option']['uploads_extension_list'] = array();
1143 if(isset($options['upload_extension'])){
1144 $str_tmp = explode(',', $options['upload_extension']);
1145 for($index=0; $index<count($str_tmp); $index++){
1146 if(!empty($str_tmp[$index])) {
1147 $custom_option['uploads_option']['uploads_extension_list'][] = $str_tmp[$index];
1148 }
1149 }
1150 }
1151
1152 $custom_option['content_option']['content_check'] = $options['content_check'];
1153 $custom_option['content_option']['content_extension_list'] = array();
1154 if(isset($options['content_extension'])){
1155 $str_tmp = explode(',', $options['content_extension']);
1156 for($index=0; $index<count($str_tmp); $index++){
1157 if(!empty($str_tmp[$index])) {
1158 $custom_option['content_option']['content_extension_list'][] = $str_tmp[$index];
1159 }
1160 }
1161 }
1162
1163 $custom_option['core_option']['core_check'] = $options['core_check'];
1164
1165 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('backup_custom_setting', $custom_option);
1166 }
1167
1168 public function set_incremental_file_settings($site_id, $options)
1169 {
1170 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'incremental_backup_setting', array());
1171 if(empty($incremental_backup_setting)){
1172 $incremental_backup_setting = array();
1173 $history = array();
1174 }
1175 else{
1176 $history = isset($incremental_backup_setting['incremental_history']) ? $incremental_backup_setting['incremental_history'] : array();
1177 if(empty($history)){
1178 $history = array();
1179 }
1180 }
1181
1182 $custom_option['database_option']['database_check'] = isset($options['database_check']) ? $options['database_check'] : 0;
1183 $custom_option['database_option']['exclude_table_list'] = isset($options['database_list']) ? $options['database_list'] : array();
1184
1185 $custom_option['themes_option']['themes_check'] = isset($options['themes_check']) ? $options['themes_check'] : 0;
1186 $custom_option['themes_option']['exclude_themes_list'] = isset($options['themes_list']) ? $options['themes_list'] : array();
1187
1188 $custom_option['plugins_option']['plugins_check'] = isset($options['plugins_check']) ? $options['plugins_check'] : 0;
1189 $custom_option['plugins_option']['exclude_plugins_list'] = isset($options['plugins_list']) ? $options['plugins_list'] : array();
1190
1191 $custom_option['uploads_option']['uploads_check'] = isset($options['uploads_check']) ? $options['uploads_check'] : 0;
1192 $custom_option['uploads_option']['exclude_uploads_list'] = isset($options['uploads_list']) ? $options['uploads_list'] : array();
1193 $custom_option['uploads_option']['uploads_extension_list'] = isset($options['upload_extension']) ? $options['upload_extension'] : array();
1194
1195 $custom_option['content_option']['content_check'] = isset($options['content_check']) ? $options['content_check'] : 0;
1196 $custom_option['content_option']['exclude_content_list'] = isset($options['content_list']) ? $options['content_list'] : array();
1197 $custom_option['content_option']['content_extension_list'] = isset($options['content_extension']) ? $options['content_extension'] : array();
1198
1199 $custom_option['core_option']['core_check'] = isset($options['core_check']) ? $options['core_check'] : 0;
1200
1201 $custom_option['other_option']['other_check'] = isset($options['other_check']) ? $options['other_check'] : 0;
1202 $custom_option['other_option']['include_other_list'] = isset($options['other_list']) ? $options['other_list'] : array();
1203 $custom_option['other_option']['other_extension_list'] = isset($options['other_extension']) ? $options['other_extension'] : array();
1204
1205 $custom_option['additional_database_option']['additional_database_check'] = isset($options['additional_database_check']) ? $options['additional_database_check'] : 0;
1206 if(isset($history['incremental_file']['additional_database_option'])) {
1207 $custom_option['additional_database_option'] = $history['incremental_file']['additional_database_option'];
1208 }
1209
1210 $incremental_backup_setting['incremental_history']['incremental_file'] = $custom_option;
1211 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'incremental_backup_setting', $incremental_backup_setting);
1212 }
1213
1214 public function set_incremental_db_setting($site_id, $options){
1215 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'incremental_backup_setting', array());
1216 if(empty($incremental_backup_setting)){
1217 $incremental_backup_setting = array();
1218 $history = array();
1219 }
1220 else{
1221 $history = isset($incremental_backup_setting['incremental_history']) ? $incremental_backup_setting['incremental_history'] : array();
1222 if(empty($history)){
1223 $history = array();
1224 }
1225 }
1226
1227 $custom_option['database_option']['database_check'] = isset($options['database_check']) ? $options['database_check'] : 0;
1228 $custom_option['database_option']['exclude_table_list'] = isset($options['database_list']) ? $options['database_list'] : array();
1229
1230 $custom_option['themes_option']['themes_check'] = isset($options['themes_check']) ? $options['themes_check'] : 0;
1231 $custom_option['themes_option']['exclude_themes_list'] = isset($options['themes_list']) ? $options['themes_list'] : array();
1232
1233 $custom_option['plugins_option']['plugins_check'] = isset($options['plugins_check']) ? $options['plugins_check'] : 0;
1234 $custom_option['plugins_option']['exclude_plugins_list'] = isset($options['plugins_list']) ? $options['plugins_list'] : array();
1235
1236 $custom_option['uploads_option']['uploads_check'] = isset($options['uploads_check']) ? $options['uploads_check'] : 0;
1237 $custom_option['uploads_option']['exclude_uploads_list'] = isset($options['uploads_list']) ? $options['uploads_list'] : array();
1238 $custom_option['uploads_option']['uploads_extension_list'] = isset($options['upload_extension']) ? $options['upload_extension'] : array();
1239
1240 $custom_option['content_option']['content_check'] = isset($options['content_check']) ? $options['content_check'] : 0;
1241 $custom_option['content_option']['exclude_content_list'] = isset($options['content_list']) ? $options['content_list'] : array();
1242 $custom_option['content_option']['content_extension_list'] = isset($options['content_extension']) ? $options['content_extension'] : array();
1243
1244 $custom_option['core_option']['core_check'] = isset($options['core_check']) ? $options['core_check'] : 0;
1245
1246 $custom_option['other_option']['other_check'] = isset($options['other_check']) ? $options['other_check'] : 0;
1247 $custom_option['other_option']['include_other_list'] = isset($options['other_list']) ? $options['other_list'] : array();
1248 $custom_option['other_option']['other_extension_list'] = isset($options['other_extension']) ? $options['other_extension'] : array();
1249
1250 if(isset($history['incremental_db']['additional_database_option'])) {
1251 $custom_option['additional_database_option'] = $history['incremental_db']['additional_database_option'];
1252 }
1253 $custom_option['additional_database_option']['additional_database_check'] = isset($options['additional_database_check']) ? $options['additional_database_check'] : 0;
1254
1255 $incremental_backup_setting['incremental_history']['incremental_db'] = $custom_option;
1256 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'incremental_backup_setting', $incremental_backup_setting);
1257 }
1258
1259 public function set_incremental_remote_retain_count($site_id, $count){
1260 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'incremental_backup_setting', array());
1261 if(empty($incremental_backup_setting)){
1262 $incremental_backup_setting = array();
1263 }
1264
1265 $incremental_backup_setting['incremental_remote_backup_count'] = $count;
1266 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'incremental_backup_setting', $incremental_backup_setting);
1267 }
1268
1269 public function set_incremental_enable($site_id, $status){
1270 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'incremental_backup_setting', array());
1271 if(empty($incremental_backup_setting)){
1272 $incremental_backup_setting = array();
1273 }
1274
1275 $incremental_backup_setting['enable_incremental_schedules'] = $status;
1276 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'incremental_backup_setting', $incremental_backup_setting);
1277 }
1278
1279 public function set_incremental_schedules($site_id, $schedules){
1280 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'incremental_backup_setting', array());
1281 if(empty($incremental_backup_setting)){
1282 $incremental_backup_setting = array();
1283 }
1284
1285 $incremental_backup_setting['incremental_schedules'] = $schedules;
1286 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'incremental_backup_setting', $incremental_backup_setting);
1287 }
1288
1289 public function set_incremental_backup_data($site_id, $data){
1290 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'incremental_backup_setting', array());
1291 if(empty($incremental_backup_setting)){
1292 $incremental_backup_setting = array();
1293 }
1294
1295 $incremental_backup_setting['incremental_backup_data'] = $data;
1296 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'incremental_backup_setting', $incremental_backup_setting);
1297 }
1298
1299 public function set_incremental_output_msg($site_id, $msg){
1300 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($site_id, 'incremental_backup_setting', array());
1301 if(empty($incremental_backup_setting)){
1302 $incremental_backup_setting = array();
1303 }
1304
1305 $incremental_backup_setting['incremental_output_msg'] = $msg;
1306 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_option($site_id, 'incremental_backup_setting', $incremental_backup_setting);
1307 }
1308
1309 public function mwp_wpvivid_custom_backup_data_transfer($options, $data, $type)
1310 {
1311 if(!isset($data['database_check'])){
1312 $data['database_check'] = 0;
1313 }
1314 $options['backup_select']['db'] = intval($data['database_check']);
1315 if(!isset($data['database_list'])){
1316 $data['database_list'] = array();
1317 }
1318 $options['exclude_tables'] = $data['database_list'];
1319
1320 if(!isset($data['themes_check'])){
1321 $data['themes_check'] = 0;
1322 }
1323 $options['backup_select']['themes'] = intval($data['themes_check']);
1324 if(!isset($data['themes_list'])){
1325 $data['themes_list'] = array();
1326 }
1327 $options['exclude_themes'] = $data['themes_list'];
1328
1329 if(!isset($data['plugins_check'])){
1330 $data['plugins_check'] = 0;
1331 }
1332 $options['backup_select']['plugin'] = intval($data['plugins_check']);
1333 if(!isset($data['plugins_list'])){
1334 $data['plugins_list'] = array();
1335 }
1336 $options['exclude_plugins'] = $data['plugins_list'];
1337
1338 if(!isset($data['uploads_check'])){
1339 $data['uploads_check'] = 0;
1340 }
1341 $options['backup_select']['uploads'] = intval($data['uploads_check']);
1342 $upload_exclude_list = array();
1343 if(isset($data['uploads_list'])) {
1344 foreach ($data['uploads_list'] as $key => $value){
1345 $upload_exclude_list[] = $key;
1346 }
1347 }
1348 else{
1349 $data['uploads_list'] = array();
1350 }
1351 $options['exclude_uploads'] = $upload_exclude_list;
1352 $upload_exclude_file_list=array();
1353 $upload_extension_tmp = array();
1354 if(isset($data['upload_extension']) && !empty($data['upload_extension'])) {
1355 $str_tmp = explode(',', $data['upload_extension']);
1356 for($index=0; $index<count($str_tmp); $index++){
1357 if(!empty($str_tmp[$index])) {
1358 $upload_exclude_file_list[] = '.*\.'.$str_tmp[$index].'$';
1359 $upload_extension_tmp[] = $str_tmp[$index];
1360 }
1361 }
1362 $data['upload_extension'] = $upload_extension_tmp;
1363 }
1364 else{
1365 $data['upload_extension'] = array();
1366 }
1367 $options['exclude_uploads_files'] = $upload_exclude_file_list;
1368
1369 if(!isset($data['content_check'])){
1370 $data['content_check'] = 0;
1371 }
1372 $options['backup_select']['content'] = intval($data['content_check']);
1373 $content_exclude_list=array();
1374 if(isset($data['content_list'])) {
1375 foreach ($data['content_list'] as $key => $value){
1376 $content_exclude_list[] = $key;
1377 }
1378 }
1379 else{
1380 $data['content_list'] = array();
1381 }
1382 $options['exclude_content'] = $content_exclude_list;
1383 $content_exclude_file_list=array();
1384 $content_extension_tmp = array();
1385 if(isset($data['content_extension']) && !empty($data['content_extension'])) {
1386 $str_tmp = explode(',', $data['content_extension']);
1387 for($index=0; $index<count($str_tmp); $index++){
1388 if(!empty($str_tmp[$index])) {
1389 $content_exclude_file_list[] = '.*\.'.$str_tmp[$index].'$';
1390 $content_extension_tmp[] = $str_tmp[$index];
1391 }
1392 }
1393 $data['content_extension'] = $content_extension_tmp;
1394 }
1395 else{
1396 $data['content_extension'] = array();
1397 }
1398 $options['exclude_content_files'] = $content_exclude_file_list;
1399
1400 if(!isset($data['core_check'])){
1401 $data['core_check'] = 0;
1402 }
1403 $options['backup_select']['core'] = intval($data['core_check']);
1404
1405 if(!isset($data['other_check'])){
1406 $data['other_check'] = 0;
1407 }
1408 $options['backup_select']['other'] = intval($data['other_check']);
1409 $other_include_list=array();
1410 if(isset($data['other_list'])) {
1411 foreach ($data['other_list'] as $key => $value){
1412 $other_include_list[] = $key;
1413 }
1414 }
1415 else{
1416 $data['other_list'] = array();
1417 }
1418 $options['custom_other_root'] = $other_include_list;
1419 $other_exclude_file_list=array();
1420 $other_extension_tmp = array();
1421 if(isset($data['other_extension']) && !empty($data['other_extension'])) {
1422 $str_tmp = explode(',', $data['other_extension']);
1423 for($index=0; $index<count($str_tmp); $index++){
1424 if(!empty($str_tmp[$index])) {
1425 $other_exclude_file_list[] = '.*\.'.$str_tmp[$index].'$';
1426 $other_extension_tmp[] = $str_tmp[$index];
1427 }
1428 }
1429 $data['other_extension'] = $other_extension_tmp;
1430 }
1431 else{
1432 $data['other_extension'] = array();
1433 }
1434 $options['exclude_custom_other_files'] = $other_exclude_file_list;
1435 $options['exclude_custom_other']=array();
1436
1437 if(!isset($data['additional_database_check'])){
1438 $data['additional_database_check'] = 0;
1439 }
1440 $options['backup_select']['additional_db'] = intval($data['additional_database_check']);
1441 if($options['backup_select']['additional_db'] === 1){
1442
1443 if(isset($history['additional_database_option']['additional_database_list']) && !empty($history['additional_database_option']['additional_database_list'])) {
1444 $options['additional_database_list'] = $history['additional_database_option']['additional_database_list'];
1445 }
1446 else{
1447 $options['additional_database_list'] = array();
1448 }
1449 }
1450
1451 return $options;
1452 }
1453
1454 public function check_incremental_schedule_option($data){
1455 //$ret['schedule']['file_start_time_zone'] = $data['file_start_time_zone'];
1456 //$ret['schedule']['db_start_time_zone'] = $data['db_start_time_zone'];
1457 $ret['schedule']['incremental_recurrence'] =$data['recurrence'];
1458 $ret['schedule']['incremental_recurrence_week'] =$data['recurrence_week'];
1459 $ret['schedule']['incremental_recurrence_day'] =$data['recurrence_day'];
1460 $ret['schedule']['incremental_files_recurrence'] =$data['incremental_files_recurrence'];
1461 $ret['schedule']['incremental_db_recurrence'] =$data['incremental_db_recurrence'];
1462 $ret['schedule']['incremental_db_recurrence_week'] = $data['incremental_db_recurrence_week'];
1463 $ret['schedule']['incremental_db_recurrence_day'] = $data['incremental_db_recurrence_day'];
1464 $ret['schedule']['incremental_backup_status'] = $data['incremental_backup_status'];
1465 $ret['schedule']['incremental_files_start_backup'] = $data['incremental_files_start_backup'];
1466
1467 /*if(isset($data['custom']['files'])){
1468 $ret['schedule']['backup_files']=array();
1469 $ret['schedule']['backup_files'] = apply_filters('mwp_wpvivid_custom_backup_data_transfer', $ret['schedule']['backup_files'], $data['custom']['files'], 'incremental_backup_file');
1470 }
1471 if(isset($data['custom']['db'])){
1472 $ret['schedule']['backup_db']=array();
1473 $ret['schedule']['backup_db'] = apply_filters('mwp_wpvivid_custom_backup_data_transfer', $ret['schedule']['backup_db'], $data['custom']['db'], 'incremental_backup_db');
1474 }*/
1475 $data['save_local_remote']=sanitize_text_field($data['save_local_remote']);
1476
1477 if(!empty($data['save_local_remote']))
1478 {
1479 if($data['save_local_remote'] == 'remote')
1480 {
1481 $ret['schedule']['backup']['remote']=1;
1482 $ret['schedule']['backup']['local']=0;
1483 }
1484 else
1485 {
1486 $ret['schedule']['backup']['remote']=0;
1487 $ret['schedule']['backup']['local']=1;
1488 }
1489 }
1490
1491 if(isset($data['backup_prefix']) && !empty($data['backup_prefix']))
1492 {
1493 $ret['schedule']['backup']['backup_prefix'] = $data['backup_prefix'];
1494 }
1495
1496 if(isset($data['db_current_day']))
1497 {
1498 $ret['schedule']['db_current_day'] = $data['db_current_day'];
1499 }
1500
1501 if(isset($data['files_current_day']))
1502 {
1503 $ret['schedule']['files_current_day'] = $data['files_current_day'];
1504 }
1505
1506 $ret['schedule']['files_current_day_hour'] = $data['files_current_day_hour'];
1507 $ret['schedule']['files_current_day_minute'] = $data['files_current_day_minute'];
1508 $ret['schedule']['db_current_day_hour'] = $data['db_current_day_hour'];
1509 $ret['schedule']['db_current_day_minute'] = $data['db_current_day_minute'];
1510
1511 $ret['schedule']['backup_db'] = $data['backup_db'];
1512 $ret['schedule']['backup_files'] = $data['backup_files'];
1513
1514 $ret['schedule']['exclude_files'] = $data['exclude_files'];
1515 $ret['schedule']['exclude_file_type'] = $data['exclude_file_type'];
1516
1517 return $ret;
1518 }
1519
1520 public function mwp_add_incremental_schedule($schedule){
1521 $schedule_data=array();
1522 $schedule_data['id']=uniqid('wpvivid_incremental_schedule');
1523 $schedule_data['files_schedule_id']=uniqid('wpvivid_incremental_files_schedule_event');
1524 $schedule_data['db_schedule_id']=uniqid('wpvivid_incremental_db_schedule_event');
1525
1526 $schedule['backup']['ismerge']=1;
1527 $schedule['backup']['lock']=0;
1528 $schedule_data= $this->mwp_set_incremental_schedule_data($schedule_data,$schedule);
1529
1530 $schedules=array();
1531 $schedules[$schedule_data['id']]=$schedule_data;
1532 return $schedules;
1533 }
1534
1535 public function mwp_set_incremental_schedule_data($schedule_data,$schedule){
1536 //$schedule_data['file_start_time_zone'] = $schedule['file_start_time_zone'];
1537 //$schedule_data['db_start_time_zone'] = $schedule['db_start_time_zone'];
1538 $schedule_data['incremental_recurrence']=$schedule['incremental_recurrence'];
1539 $schedule_data['incremental_recurrence_week']=$schedule['incremental_recurrence_week'];
1540 $schedule_data['incremental_recurrence_day']=$schedule['incremental_recurrence_day'] ;
1541 $schedule_data['incremental_files_recurrence']=$schedule['incremental_files_recurrence'];
1542 $schedule_data['incremental_db_recurrence']=$schedule['incremental_db_recurrence'];
1543 $schedule_data['incremental_db_recurrence_week']=$schedule['incremental_db_recurrence_week'];
1544 $schedule_data['incremental_db_recurrence_day']=$schedule['incremental_db_recurrence_day'];
1545 $schedule_data['db_current_day']=$schedule['db_current_day'];
1546 $schedule_data['files_current_day']=$schedule['files_current_day'];
1547 $schedule_data['incremental_backup_status'] = $schedule['incremental_backup_status'];
1548 $schedule_data['incremental_files_start_backup']=$schedule['incremental_files_start_backup'];
1549 $schedule_data['files_current_day_hour'] = $schedule['files_current_day_hour'];
1550 $schedule_data['files_current_day_minute'] = $schedule['files_current_day_minute'];
1551 $schedule_data['db_current_day_hour'] = $schedule['db_current_day_hour'];
1552 $schedule_data['db_current_day_minute'] = $schedule['db_current_day_minute'];
1553
1554 $schedule_data['backup_files'] = $schedule['backup_files'];
1555 $schedule_data['backup_db'] = $schedule['backup_db'];
1556
1557 $schedule_data['exclude_files'] = $schedule['exclude_files'];
1558 $schedule_data['exclude_file_type'] = $schedule['exclude_file_type'];
1559
1560 $schedule_data['backup']=$schedule['backup'];
1561 return $schedule_data;
1562 }
1563
1564 public function set_global_incremental_file_settings($incremental_schedule_mould_name, $options){
1565 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('incremental_backup_setting', array());
1566 if(empty($incremental_backup_setting)){
1567 $incremental_backup_setting = array();
1568 $history = array();
1569 }
1570 else{
1571 $history = isset($incremental_backup_setting['incremental_history']) ? $incremental_backup_setting['incremental_history'] : array();
1572 if(empty($history)){
1573 $history = array();
1574 }
1575 }
1576
1577 $custom_option['database_option']['database_check'] = isset($options['database_check']) ? $options['database_check'] : 0;
1578
1579 $custom_option['themes_option']['themes_check'] = isset($options['themes_check']) ? $options['themes_check'] : 0;
1580
1581 $custom_option['plugins_option']['plugins_check'] = isset($options['plugins_check']) ? $options['plugins_check'] : 0;
1582
1583 $custom_option['uploads_option']['uploads_check'] = isset($options['uploads_check']) ? $options['uploads_check'] : 0;
1584
1585 $upload_extension_tmp = array();
1586 if(isset($options['upload_extension']) && !empty($options['upload_extension'])) {
1587 $str_tmp = explode(',', $options['upload_extension']);
1588 for($index=0; $index<count($str_tmp); $index++){
1589 if(!empty($str_tmp[$index])) {
1590 $upload_extension_tmp[] = $str_tmp[$index];
1591 }
1592 }
1593 $custom_option['uploads_option']['uploads_extension_list'] = $upload_extension_tmp;
1594 }
1595 else{
1596 $custom_option['uploads_option']['uploads_extension_list'] = array();
1597 }
1598 //$custom_option['uploads_option']['uploads_extension_list'] = isset($options['upload_extension']) ? $options['upload_extension'] : array();
1599
1600 $custom_option['content_option']['content_check'] = isset($options['content_check']) ? $options['content_check'] : 0;
1601
1602 $content_extension_tmp = array();
1603 if(isset($options['content_extension']) && !empty($options['content_extension'])) {
1604 $str_tmp = explode(',', $options['content_extension']);
1605 for($index=0; $index<count($str_tmp); $index++){
1606 if(!empty($str_tmp[$index])) {
1607 $content_extension_tmp[] = $str_tmp[$index];
1608 }
1609 }
1610 $custom_option['content_option']['content_extension_list'] = $content_extension_tmp;
1611 }
1612 else{
1613 $custom_option['content_option']['content_extension_list'] = array();
1614 }
1615 //$custom_option['content_option']['content_extension_list'] = isset($options['content_extension']) ? $options['content_extension'] : array();
1616
1617 $custom_option['core_option']['core_check'] = isset($options['core_check']) ? $options['core_check'] : 0;
1618
1619 $incremental_backup_setting[$incremental_schedule_mould_name]['incremental_history']['incremental_file'] = $custom_option;
1620 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('incremental_backup_setting', $incremental_backup_setting);
1621 }
1622
1623 public function set_global_incremental_db_settings($incremental_schedule_mould_name, $options){
1624 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('incremental_backup_setting', array());
1625 if(empty($incremental_backup_setting)){
1626 $incremental_backup_setting = array();
1627 $history = array();
1628 }
1629 else{
1630 $history = isset($incremental_backup_setting['incremental_history']) ? $incremental_backup_setting['incremental_history'] : array();
1631 if(empty($history)){
1632 $history = array();
1633 }
1634 }
1635
1636 $custom_option['database_option']['database_check'] = isset($options['database_check']) ? $options['database_check'] : 0;
1637
1638 $custom_option['themes_option']['themes_check'] = isset($options['themes_check']) ? $options['themes_check'] : 0;
1639
1640 $custom_option['plugins_option']['plugins_check'] = isset($options['plugins_check']) ? $options['plugins_check'] : 0;
1641
1642 $custom_option['uploads_option']['uploads_check'] = isset($options['uploads_check']) ? $options['uploads_check'] : 0;
1643 $custom_option['uploads_option']['uploads_extension_list'] = isset($options['upload_extension']) ? $options['upload_extension'] : array();
1644
1645 $custom_option['content_option']['content_check'] = isset($options['content_check']) ? $options['content_check'] : 0;
1646 $custom_option['content_option']['content_extension_list'] = isset($options['content_extension']) ? $options['content_extension'] : array();
1647
1648 $custom_option['core_option']['core_check'] = isset($options['core_check']) ? $options['core_check'] : 0;
1649
1650 $incremental_backup_setting[$incremental_schedule_mould_name]['incremental_history']['incremental_db'] = $custom_option;
1651 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('incremental_backup_setting', $incremental_backup_setting);
1652 }
1653
1654 public function set_global_incremental_remote_retain_count($incremental_schedule_mould_name, $count){
1655 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('incremental_backup_setting', array());
1656 if(empty($incremental_backup_setting)){
1657 $incremental_backup_setting = array();
1658 }
1659
1660 $incremental_backup_setting[$incremental_schedule_mould_name]['incremental_remote_backup_count'] = $count;
1661 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('incremental_backup_setting', $incremental_backup_setting);
1662 }
1663
1664 public function set_global_incremental_schedules($incremental_schedule_mould_name, $schedule){
1665 $incremental_backup_setting = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_global_option('incremental_backup_setting', array());
1666 if(empty($incremental_backup_setting)){
1667 $incremental_backup_setting = array();
1668 }
1669
1670 $ret = $this->check_incremental_schedule_option($schedule);
1671 $schedules = $this->mwp_add_incremental_schedule($ret['schedule']);
1672
1673 $incremental_backup_setting[$incremental_schedule_mould_name]['incremental_schedules'] = $schedules;
1674 Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_update_global_option('incremental_backup_setting', $incremental_backup_setting);
1675 }
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699 public function mwp_check_white_label_option($data)
1700 {
1701 $ret['result']='failed';
1702 if(!isset($data['white_label_display']))
1703 {
1704 $ret['error']=__('The white label is required.', 'wpvivid');
1705 return $ret;
1706 }
1707 $data['white_label_display']=sanitize_text_field($data['white_label_display']);
1708 if(empty($data['white_label_display']))
1709 {
1710 $ret['error']=__('The white label is required.', 'wpvivid');
1711 return $ret;
1712 }
1713
1714 if(!isset($data['white_label_slug']))
1715 {
1716 $ret['error']=__('The slug is required.', 'wpvivid');
1717 return $ret;
1718 }
1719 $data['white_label_slug']=sanitize_text_field($data['white_label_slug']);
1720 if(empty($data['white_label_slug']))
1721 {
1722 $ret['error']=__('The slug is required.', 'wpvivid');
1723 return $ret;
1724 }
1725
1726 if(!isset($data['white_label_support_email']))
1727 {
1728 $ret['error']=__('The support email is required.', 'wpvivid');
1729 return $ret;
1730 }
1731 $data['white_label_support_email']=sanitize_text_field($data['white_label_support_email']);
1732 if(empty($data['white_label_support_email']))
1733 {
1734 $ret['error']=__('The support email is required.', 'wpvivid');
1735 return $ret;
1736 }
1737
1738 if(!isset($data['white_label_website']))
1739 {
1740 $ret['error']=__('The website is required.', 'wpvivid');
1741 return $ret;
1742 }
1743 $data['white_label_website']=sanitize_text_field($data['white_label_website']);
1744 if(empty($data['white_label_website']))
1745 {
1746 $ret['error']=__('The website is required.', 'wpvivid');
1747 return $ret;
1748 }
1749
1750 $ret['result']='success';
1751 return $ret;
1752 }
1753
1754 public function mwp_ajax_check_security($role='administrator')
1755 {
1756 check_ajax_referer( 'wpvivid_mainwp_ajax', 'nonce' );
1757 if(!is_admin()||!current_user_can($role))
1758 die();
1759 }
1760
1761 public function mwp_check_wpvivid_pro($plugins, $website_id){
1762 $check_pro = false;
1763 $is_pro=Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($website_id, 'is_pro', false);
1764 if($is_pro){
1765 $check_pro = true;
1766 }
1767 return $check_pro;
1768 }
1769
1770 public function get_websites()
1771 {
1772 $websites = apply_filters( 'mainwp_getsites', $this->childFile, $this->childKey, null );
1773 $sites_ids = array();
1774 if ( is_array( $websites ) )
1775 {
1776 foreach ( $websites as $site ) {
1777 $sites_ids[] = $site['id'];
1778 }
1779 unset( $websites );
1780 }
1781 $option = array( 'plugin_upgrades' => true, 'plugins' => true );
1782 $selected_group=array();
1783 if ( isset( $_POST['mwp_wpvivid_plugin_groups_select'] ) && $_POST['mwp_wpvivid_plugin_groups_select']!=0)
1784 {
1785 $selected_group[] = intval(sanitize_text_field($_POST['mwp_wpvivid_plugin_groups_select']));
1786 }
1787 if(!empty($selected_group))
1788 {
1789 $sites_ids=array();
1790 }
1791
1792 $dbwebsites = apply_filters( 'mainwp_getdbsites', $this->childFile, $this->childKey, $sites_ids, $selected_group, $option );
1793 $websites_with_plugin=array();
1794 foreach ( $dbwebsites as $website )
1795 {
1796 if ( $website )
1797 {
1798 $plugins = json_decode( $website->plugins, 1 );
1799 if ( is_array( $plugins ) && count( $plugins ) != 0 )
1800 {
1801 $site = array('id' => $website->id, 'name' => $website->name, 'url' => $website->url);
1802 $check_pro = $this->mwp_check_wpvivid_pro($plugins, $website->id);
1803 if(!$check_pro) {
1804 $site['pro'] = 0;
1805 $site['install'] = 0;
1806 $site['active'] = 0;
1807 $site['login'] = 0;
1808 $site['version'] = 'N/A';
1809 $site['slug'] = 'wpvivid-backuprestore'; //wpvivid-backup-pro
1810 $site['individual'] = 0;
1811 $site['status'] = 'Not Install';
1812 $site['class'] = 'need-install';
1813
1814 foreach ($plugins as $plugin) {
1815 $reg_string = 'wpvivid-backuprestore/wpvivid-backuprestore.php';
1816 if ((strcmp($plugin['slug'], $reg_string) === 0)) {
1817 $site['pro'] = 0;
1818 $site['install'] = 1;
1819 $site['slug'] = $plugin['slug'];
1820 $site['version'] = esc_html($plugin['version']).' (WPvivid Backup)';
1821
1822
1823 $individual = Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($site['id'], 'individual', false);
1824 if ($individual) {
1825 $site['individual'] = 1;
1826 } else {
1827 $site['individual'] = 0;
1828 }
1829
1830 if ($plugin['active']) {
1831 $site['active'] = 1;
1832 $plugin_upgrades = json_decode($website->plugin_upgrades, 1);
1833 if (is_array($plugin_upgrades) && count($plugin_upgrades) > 0) {
1834 if (isset($plugin_upgrades['wpvivid-backuprestore/wpvivid-backuprestore.php'])) {
1835 $upgrade = $plugin_upgrades['wpvivid-backuprestore/wpvivid-backuprestore.php'];
1836 if (isset($upgrade['update'])) {
1837 $site['upgrade'] = $upgrade['update'];
1838 $site['status'] = 'New version available';
1839 $site['class'] = 'need-update';
1840 }
1841 else{
1842 $site['status'] = 'Latest version';
1843 $site['class'] = '';
1844 }
1845 }
1846 else{
1847 $site['status'] = 'Latest version';
1848 $site['class'] = '';
1849 }
1850 }
1851 else{
1852 $site['status'] = 'Latest version';
1853 $site['class'] = '';
1854 }
1855 } else {
1856 $site['active'] = 0;
1857 $site['status'] = 'Not Actived';
1858 $site['class'] = 'need-active';
1859 }
1860 //$site['report'] = Mainwp_WPvivid_Extension_Option::get_instance()->get_report_addon($site['id']);
1861 //$site['sync_remote_setting'] = Mainwp_WPvivid_Extension_Option::get_instance()->get_sync_remote_setting($site['id']);
1862 break;
1863 }
1864 }
1865 if (isset($_GET['search']) && !empty($_GET['search'])) {
1866 $find = trim(sanitize_text_field($_GET['search']));
1867 if (stripos($site['name'], $find) !== false || stripos($site['url'], $find) !== false) {
1868 $websites_with_plugin[$site['id']] = $site;
1869 }
1870 } else {
1871 $websites_with_plugin[$site['id']] = $site;
1872 }
1873 }
1874 }
1875 }
1876 }
1877
1878 return $websites_with_plugin;
1879 }
1880
1881 public function mwp_get_child_websites(){
1882 $websites = apply_filters( 'mainwp_getsites', $this->childFile, $this->childKey, null );
1883 $sites_ids = array();
1884 if ( is_array( $websites ) ) {
1885 foreach ( $websites as $site ) {
1886 $sites_ids[] = $site['id'];
1887 }
1888 unset( $websites );
1889 }
1890 $option = array( 'plugin_upgrades' => true, 'plugins' => true );
1891 $selected_group=array();
1892 if ( isset( $_POST['mwp_wpvivid_plugin_groups_select'] ) && $_POST['mwp_wpvivid_plugin_groups_select']!=0) {
1893 $selected_group[] = intval(sanitize_text_field($_POST['mwp_wpvivid_plugin_groups_select']));
1894 }
1895 if(!empty($selected_group)) {
1896 $sites_ids=array();
1897 }
1898
1899 $dbwebsites = apply_filters( 'mainwp_getdbsites', $this->childFile, $this->childKey, $sites_ids, $selected_group, $option );
1900 return $dbwebsites;
1901 }
1902
1903 public function get_websites_ex()
1904 {
1905 $websites = apply_filters( 'mainwp_getsites', $this->childFile, $this->childKey, null );
1906 $sites_ids = array();
1907 if ( is_array( $websites ) ) {
1908 foreach ( $websites as $site ) {
1909 $sites_ids[] = $site['id'];
1910 }
1911 unset( $websites );
1912 }
1913 $option = array( 'plugin_upgrades' => true, 'plugins' => true );
1914 $selected_group=array();
1915 if ( isset( $_POST['mwp_wpvivid_plugin_groups_select'] ) && $_POST['mwp_wpvivid_plugin_groups_select']!=0) {
1916 $selected_group[] = intval(sanitize_text_field($_POST['mwp_wpvivid_plugin_groups_select']));
1917 }
1918 if(!empty($selected_group)) {
1919 $sites_ids=array();
1920 }
1921
1922 $login_options = $this->get_global_login_addon();
1923 if($login_options !== false && isset($login_options['wpvivid_pro_login_cache'])){
1924 $addons_cache = $login_options['wpvivid_pro_login_cache'];
1925 if(isset($addons_cache['pro']['version'])){
1926 $latest_version = $addons_cache['pro']['version'];
1927 }
1928 else if(isset($addons_cache['dashboard']['version'])){
1929 $latest_version = $addons_cache['dashboard']['version'];
1930 }
1931 else{
1932 $latest_version = false;
1933 }
1934 }
1935 else{
1936 $latest_version = false;
1937 }
1938
1939 $dbwebsites = apply_filters( 'mainwp_getdbsites', $this->childFile, $this->childKey, $sites_ids, $selected_group, $option );
1940 $websites_with_plugin=array();
1941 foreach ( $dbwebsites as $website ){
1942 if ( $website )
1943 {
1944 $plugins = json_decode( $website->plugins, 1 );
1945 if ( is_array( $plugins ) && count( $plugins ) != 0 )
1946 {
1947 $site = array('id' => $website->id, 'name' => $website->name, 'url' => $website->url);
1948 $check_pro = $this->mwp_check_wpvivid_pro($plugins, $website->id);
1949
1950 $site['pro'] = 1;
1951 $site['slug'] = 'wpvivid-backup-pro';
1952 $site['version'] = 'N/A';
1953 $site['individual'] = 0;
1954 $site['install-wpvivid'] = 0;
1955 $site['active-wpvivid'] = 0;
1956 $site['install-wpvivid-pro'] = 0;
1957 $site['active-wpvivid-pro'] = 0;
1958 $site['login'] = 0;
1959 $site['check-status'] = 0;
1960 $site['status'] = 'WPvivid Backup Pro not claimed';
1961 $site['class'] = 'need-install-wpvivid';
1962 $site['class-update'] = '';
1963 $wpvivid_need_update = false;
1964
1965 /*$wpvivid_status = false;
1966 foreach ($plugins as $plugin){
1967 $reg_string = 'wpvivid-backuprestore/wpvivid-backuprestore.php';
1968 if ((strcmp($plugin['slug'], $reg_string) === 0)) {
1969 $site['install-wpvivid'] = 1;
1970 if ($plugin['active']) {
1971 $site['active-wpvivid'] = 1;
1972
1973 $plugin_upgrades = json_decode($website->plugin_upgrades, 1);
1974 if (is_array($plugin_upgrades) && count($plugin_upgrades) > 0) {
1975 if (isset($plugin_upgrades['wpvivid-backuprestore/wpvivid-backuprestore.php'])) {
1976 $upgrade = $plugin_upgrades['wpvivid-backuprestore/wpvivid-backuprestore.php'];
1977 if (isset($upgrade['update'])) {
1978 $site['status'] = 'New version available';
1979 $site['class-update'] = 'need-update-wpvivid';
1980 $wpvivid_need_update = true;
1981 }
1982 }
1983 }
1984
1985 $wpvivid_status = true;
1986 } else {
1987 $site['active-wpvivid'] = 0;
1988 $site['status'] = 'WPvivid Backup Pro not claimed';
1989 $site['class'] = 'need-active-wpvivid';
1990 }
1991 break;
1992 }
1993 }*/
1994
1995 //if($wpvivid_status)
1996 //{
1997 $site['status'] = 'WPvivid Backup Pro not claimed';
1998 $site['class'] = 'need-install-wpvivid-pro';
1999 foreach ($plugins as $plugin) {
2000 $reg_string = 'wpvivid-backup-pro/wpvivid-backup-pro.php';
2001 if ((strcmp($plugin['slug'], $reg_string) === 0)) {
2002 $site['install-wpvivid-pro'] = 1;
2003 $site['slug'] = $plugin['slug'];
2004
2005 $individual = Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($site['id'], 'individual', false);
2006 if ($individual) {
2007 $site['individual'] = 1;
2008 } else {
2009 $site['individual'] = 0;
2010 }
2011
2012 if ($plugin['active']) {
2013 $site['active-wpvivid-pro'] = 1;
2014
2015 $wpvivid_pro_need_update_pro = false;
2016 if($latest_version !== false){
2017 if(version_compare($latest_version, $plugin['version'],'>')){
2018 $is_login_pro = $this->get_is_login($site['id']);
2019 if($is_login_pro !== false){
2020 if(intval($is_login_pro) !== 1){
2021 $wpvivid_pro_need_update_pro = true;
2022 $site['status'] = 'WPvivid Backup Pro not claimed';
2023 $site['class'] = 'need-install-wpvivid-pro';
2024 }
2025 }
2026 else{
2027 $wpvivid_pro_need_update_pro = true;
2028 $site['status'] = 'WPvivid Backup Pro not claimed';
2029 $site['class'] = 'need-install-wpvivid-pro';
2030 }
2031 }
2032 }
2033
2034 if(!$wpvivid_pro_need_update_pro){
2035 $is_login_pro = $this->get_is_login($site['id']);
2036 if($is_login_pro !== false){
2037 if(intval($is_login_pro) === 1){
2038 $site['login'] = 1;
2039 $need_update = $this->get_need_update($site['id']);
2040 if($need_update == '1'){
2041 $site['status'] = 'New version available';
2042 $site['class-update'] = 'need-update-wpvivid-pro';
2043 $site['class'] = '';
2044 }
2045 else{
2046 if(!$wpvivid_need_update) {
2047 $site['status'] = 'Latest version';
2048 $site['class'] = '';
2049 $site['check-status'] = 1;
2050 }
2051 else{
2052 $site['status'] = 'New version available';
2053 $site['class'] = '';
2054 $site['class-update'] = 'need-update-wpvivid';
2055 }
2056 }
2057 $site['version'] = $this->get_current_version($site['id']);
2058 $site['version'] = $site['version'].' (WPvivid Backup Pro)';
2059 }
2060 else{
2061 $site['login'] = 0;
2062 $site['status'] = 'WPvivid Backup Pro not claimed';
2063 $site['class'] = 'need-login';
2064 }
2065 }
2066 else{
2067 $site['status'] = 'WPvivid Backup Pro not claimed';
2068 $site['class'] = 'need-login';
2069 }
2070 }
2071 } else {
2072 $site['active-wpvivid-pro'] = 0;
2073 $site['status'] = 'WPvivid Backup Pro not claimed';
2074 $site['class'] = 'need-active-wpvivid-pro';
2075 }
2076
2077 break;
2078 }
2079 }
2080 //}
2081 if (isset($_GET['search']) && !empty($_GET['search'])) {
2082 $find = trim(sanitize_text_field($_GET['search']));
2083 if (stripos($site['name'], $find) !== false || stripos($site['url'], $find) !== false) {
2084 $websites_with_plugin[$site['id']] = $site;
2085 }
2086 } else {
2087 $websites_with_plugin[$site['id']] = $site;
2088 }
2089 }
2090 }
2091 }
2092 return $websites_with_plugin;
2093 }
2094
2095 public function render_sync_websites_page($submit_id, $check_addon = false, $schedule_mould_name = '')
2096 {
2097 global $mainwp_wpvivid_extension_activator;
2098
2099 if(intval($check_addon) === 1){
2100 $websites_with_plugin=$mainwp_wpvivid_extension_activator->get_websites_ex();
2101 }
2102 else{
2103 $websites_with_plugin=$mainwp_wpvivid_extension_activator->get_websites();
2104 }
2105
2106 ?>
2107
2108 <div style="padding: 10px;">
2109 <h2 style="margin-top: 10px;">Saving settings to child sites ...</h2><br>
2110 <?php
2111 if($submit_id === 'mwp_wpvivid_sync_schedule' && intval($check_addon) === 1){
2112 ?>
2113 <div class="mwp-wpvivid-block-bottom-space">
2114 <span>Schedule Name:</span><span class="mwp_wpvivid_schedule_mould_name"><?php echo esc_html($schedule_mould_name); ?></span>
2115 </div>
2116 <div class="mwp-wpvivid-block-bottom-space">
2117 <div>
2118 <label>
2119 <input type="radio" name="mwp_wpvivid_default_schedule" value="default_only" checked />
2120 <span>Set as the only active schedule (This will disable and replace existing schedules on the child sites)</span>
2121 </label>
2122 </div>
2123 <div>
2124 <label>
2125 <input type="radio" name="mwp_wpvivid_default_schedule" value="default_append" />
2126 <span>Set as an additional active schedule (This will add the new schedule to the child sites and will not disable existing schedules)</span>
2127 </label>
2128 </div>
2129 </div>
2130 <?php
2131 }
2132 else if($submit_id === 'mwp_wpvivid_sync_incremental_schedule' && intval($check_addon) === 1){
2133 ?>
2134 <div class="mwp-wpvivid-block-bottom-space">
2135 <span>Schedule Name:</span><span class="mwp_wpvivid_schedule_mould_name"><?php echo esc_html($schedule_mould_name); ?></span>
2136 </div>
2137 <div class="mwp-wpvivid-block-bottom-space">
2138 <span>This will disable all existing schedules on the child sites.</span>
2139 </div>
2140 <?php
2141 }
2142 ?>
2143 <table class="ui selectable unstackable table mainwp-with-preview-table mainwp-manage-wpsites-table">
2144 <thead>
2145 <tr>
2146 <th class="no-sort collapsing check-column"><span class="ui checkbox"><input type="checkbox" checked /></span></th>
2147 <th><?php esc_html_e( 'Site' ); ?></th>
2148 <th><?php esc_html_e( 'URL' ); ?></th>
2149 <th><?php esc_html_e( 'Status' ); ?></th>
2150 </tr>
2151 </thead>
2152 <tbody class="list:sites">
2153 <?php
2154 if ( is_array( $websites_with_plugin ) && count( $websites_with_plugin ) > 0 )
2155 {
2156 foreach ( $websites_with_plugin as $website )
2157 {
2158 $website_id = $website['id'];
2159
2160
2161 if(intval($check_addon) !== intval($website['pro']))
2162 {
2163 continue;
2164 }
2165
2166 if(intval($check_addon) === 1)
2167 {
2168 if(!$website['check-status'])
2169 {
2170 continue;
2171 }
2172 }
2173 else {
2174 if(!$website['install'])
2175 {
2176 continue;
2177 }
2178
2179 if(!$website['active'])
2180 {
2181 continue;
2182 }
2183 }
2184
2185 if($website['individual'])
2186 {
2187 continue;
2188 }
2189
2190 ?>
2191 <tr class="mwp-wpvivid-sync-row">
2192 <td class="check-column" website-id="<?php echo esc_attr($website_id); ?>"><span class="ui checkbox"><input type="checkbox" name="checked[]" checked /></span></td>
2193 <td>
2194 <a href="admin.php?page=managesites&dashboard=<?php echo esc_html($website_id); ?>"><?php echo esc_html(stripslashes($website['name'])); ?></a><br/>
2195 </td>
2196 <td>
2197 <a href="<?php echo esc_attr($website['url']); ?>" target="_blank"><?php echo esc_html($website['url']); ?></a><br/>
2198 </td>
2199 <td class="mwp-wpvivid-progress" website-id="<?php echo esc_attr($website_id); ?>">
2200 <span>Ready to update</span>
2201 </td>
2202 </tr>
2203 <?php
2204 }
2205 } else {
2206 echo '<tr><td colspan="9">No websites were found with the WPvivid Backup plugin installed.</td></tr>';
2207 }
2208 ?>
2209 </tbody>
2210 </table>
2211 <input class="ui green mini button"
2212 id="<?php echo esc_attr($submit_id) ?>" type="button"
2213 value="<?php esc_attr_e('Start Syncing Changes', 'mainwp-wpvivid-extension'); ?>"/>
2214 </div>
2215 <?php
2216 }
2217
2218 public function render_sync_websites_remote_page($submit_id, $check_addon = false){
2219 global $mainwp_wpvivid_extension_activator;
2220
2221 $websites_with_plugin=$mainwp_wpvivid_extension_activator->get_websites_ex();
2222
2223 ?>
2224 <div style="padding: 10px;">
2225 <h2 style="margin-top: 10px;">Saving settings to child sites ...</h2><br>
2226 <table class="ui single line table">
2227 <thead>
2228 <tr>
2229 <th class="no-sort collapsing check-column"><span class="ui checkbox"><input type="checkbox" checked /></span></th>
2230 <th><?php esc_html_e( 'Site' ); ?></th>
2231 <th><?php esc_html_e( 'URL' ); ?></th>
2232 <th><?php esc_html_e(' Custom Path' ); ?></th>
2233 <th><?php esc_html_e( 'Status' ); ?></th>
2234 </tr>
2235 </thead>
2236 <tbody class="list:sites" id="mwp_wpvivid_sync_remote_list">
2237 <?php
2238 if ( is_array( $websites_with_plugin ) && count( $websites_with_plugin ) > 0 )
2239 {
2240 foreach ( $websites_with_plugin as $website )
2241 {
2242 $website_id = $website['id'];
2243 if(!$website['install'])
2244 {
2245 continue;
2246 }
2247
2248 if(!$website['active'])
2249 {
2250 continue;
2251 }
2252
2253 if(intval($check_addon) !== intval($website['pro']))
2254 {
2255 continue;
2256 }
2257
2258 if(intval($check_addon) === 1)
2259 {
2260 if(!$website['login'])
2261 {
2262 continue;
2263 }
2264 }
2265
2266 if($website['individual'])
2267 {
2268 continue;
2269 }
2270
2271 ?>
2272 <tr class="mwp-wpvivid-sync-row">
2273 <td class="check-column" website-id="<?php echo esc_attr($website_id); ?>"><span class="ui checkbox"><input type="checkbox" name="checked[]" checked /></span></td>
2274 <td>
2275 <a href="admin.php?page=managesites&dashboard=<?php echo esc_url($website_id); ?>"><?php echo esc_html(stripslashes($website['name'])); ?></a><br/>
2276 </td>
2277 <td>
2278 <a href="<?php echo esc_url($website['url']); ?>" target="_blank"><?php echo esc_html($website['url']); ?></a><br/>
2279 </td>
2280 <td>
2281 <span>Domain</span>
2282 <input class="ui green mini button remote-path-edit" type="button" value="<?php esc_attr_e('Edit', 'mainwp-wpvivid-extension'); ?>" />
2283 </td>
2284 <td class="mwp-wpvivid-progress" website-id="<?php echo esc_attr($website_id); ?>">
2285 <span>Ready to update</span>
2286 </td>
2287 </tr>
2288 <?php
2289 }
2290 } else {
2291 echo '<tr><td colspan="9">No websites were found with the WPvivid Backup plugin installed.</td></tr>';
2292 }
2293 ?>
2294 </tbody>
2295 <tfoot>
2296 <tr>
2297 <th class="row-title" colspan="5"><input class="ui green mini button"
2298 id="<?php echo esc_attr($submit_id) ?>" type="button"
2299 value="<?php esc_attr_e('Start Syncing Changes', 'mainwp-wpvivid-extension'); ?>"/></th>
2300 </tr>
2301 </tfoot>
2302 </table>
2303 </div>
2304 <?php
2305 }
2306
2307 public function render_check_report_page($website_id, $pro, $website_name){
2308 $report = Mainwp_WPvivid_Extension_DB_Option::get_instance()->wpvivid_get_option($website_id, 'report_addon', array());
2309 ?>
2310 <div style="padding: 10px;">
2311 <div class="mwp-wpvivid-block-bottom-space">Note: The list below includes the last 10 backup information.</div>
2312 <div class="mwp-wpvivid-block-bottom-space"><span>Site Title: </span><span><?php echo esc_html($website_name); ?></span></div>
2313 <table class="widefat mwp-wpvivid-block-bottom-space">
2314 <thead>
2315 <th>Backup Time</th>
2316 <th>Status</th>
2317 </thead>
2318 <tbody>
2319 <?php
2320 if(isset($report) && !empty($report)) {
2321 usort($report, function($a, $b){
2322 if($a['backup_time'] === $b['backup_time']){
2323 return 0;
2324 }
2325 else if($a['backup_time'] > $b['backup_time']){
2326 return -1;
2327 }
2328 else{
2329 return 1;
2330 }
2331 });
2332
2333 $time_zone=Mainwp_WPvivid_Extension_Option::get_instance()->wpvivid_get_single_option($website_id, 'time_zone', '');
2334 if(empty($time_zone)){
2335 $time_zone = 0;
2336 }
2337
2338 foreach ($report as $task_id => $report_option) {
2339 if(isset($report_option['task_id']) && !empty($report_option['task_id']))
2340 {
2341 ?>
2342 <tr>
2343 <td><?php echo esc_html(date("H:i:s - m/d/Y", $report_option['backup_time'] + $time_zone * 60 * 60)); ?></td>
2344 <td><?php echo esc_html($report_option['status']); ?></td>
2345 </tr>
2346 <?php
2347 }
2348 }
2349 }
2350 ?>
2351 </tbody>
2352 </table>
2353 <div>
2354 <a href="admin.php?page=Extensions-Wpvivid-Backup-Mainwp&tab=dashboard" class="ui green mini button">Return to WPvivid Backup Dashboard</a>
2355 </div>
2356 </div>
2357 <?php
2358 }
2359 }
2360
2361 global $mainwp_wpvivid_extension_activator;
2362 $mainwp_wpvivid_extension_activator = new Mainwp_WPvivid_Extension_Activator();