@@ -233,84 +233,84 @@ discard block |
||
233 | 233 | * The class responsible for orchestrating the actions and filters of the |
234 | 234 | * core plugin. |
235 | 235 | */ |
236 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-loader.php'; |
|
236 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-loader.php'; |
|
237 | 237 | |
238 | 238 | /** |
239 | 239 | * The class responsible for defining internationalization functionality |
240 | 240 | * of the plugin. |
241 | 241 | */ |
242 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-i18n.php'; |
|
242 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-i18n.php'; |
|
243 | 243 | |
244 | 244 | /** |
245 | 245 | * The class responsible for defining all actions that occur in the admin area. |
246 | 246 | */ |
247 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-xcloner-admin.php'; |
|
247 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-xcloner-admin.php'; |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * The class responsible for debugging XCloner. |
251 | 251 | */ |
252 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-logger.php'; |
|
252 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-logger.php'; |
|
253 | 253 | |
254 | 254 | /** |
255 | 255 | * The class responsible for defining the admin settings area. |
256 | 256 | */ |
257 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-settings.php'; |
|
257 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-settings.php'; |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * The class responsible for defining the Remote Storage settings area. |
261 | 261 | */ |
262 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-remote-storage.php'; |
|
262 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-remote-storage.php'; |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * The class responsible for implementing the database backup methods. |
266 | 266 | */ |
267 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-database.php'; |
|
267 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-database.php'; |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * The class responsible for sanitization of users input. |
271 | 271 | */ |
272 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-sanitization.php'; |
|
272 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-sanitization.php'; |
|
273 | 273 | |
274 | 274 | /** |
275 | 275 | * The class responsible for XCloner system requirements validation. |
276 | 276 | */ |
277 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-requirements.php'; |
|
277 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-requirements.php'; |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * The class responsible for XCloner backup archive creation. |
281 | 281 | */ |
282 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-archive.php'; |
|
282 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-archive.php'; |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * The class responsible for XCloner API requests. |
286 | 286 | */ |
287 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-api.php'; |
|
287 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-api.php'; |
|
288 | 288 | |
289 | 289 | /** |
290 | 290 | * The class responsible for the XCloner File System methods. |
291 | 291 | */ |
292 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-system.php'; |
|
292 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-system.php'; |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * The class responsible for the XCloner File Transfer methods. |
296 | 296 | */ |
297 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-transfer.php'; |
|
297 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-transfer.php'; |
|
298 | 298 | |
299 | 299 | /** |
300 | 300 | * The class responsible for the XCloner Scheduler methods. |
301 | 301 | */ |
302 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-scheduler.php'; |
|
302 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-scheduler.php'; |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * The class responsible for the XCloner Encryption methods. |
306 | 306 | */ |
307 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-encryption.php'; |
|
307 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-encryption.php'; |
|
308 | 308 | |
309 | 309 | /** |
310 | 310 | * The class responsible for defining all actions that occur in the public-facing |
311 | 311 | * side of the site. |
312 | 312 | */ |
313 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-xcloner-public.php'; |
|
313 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-xcloner-public.php'; |
|
314 | 314 | |
315 | 315 | $this->loader = new Xcloner_Loader($this); |
316 | 316 | |
@@ -360,31 +360,31 @@ discard block |
||
360 | 360 | * @access private |
361 | 361 | * |
362 | 362 | */ |
363 | - private function define_admin_menu(){ |
|
363 | + private function define_admin_menu() { |
|
364 | 364 | |
365 | 365 | add_action('admin_menu', array($this->loader, 'xcloner_backup_add_admin_menu')); |
366 | 366 | |
367 | 367 | } |
368 | 368 | |
369 | - private function define_plugin_settings(){ |
|
369 | + private function define_plugin_settings() { |
|
370 | 370 | /** |
371 | 371 | * register wporg_settings_init to the admin_init action hook |
372 | 372 | */ |
373 | 373 | |
374 | 374 | $this->xcloner_settings = new XCloner_Settings($this); |
375 | 375 | |
376 | - if(defined('DOING_CRON') || isset($_POST['hash'])){ |
|
376 | + if (defined('DOING_CRON') || isset($_POST['hash'])) { |
|
377 | 377 | |
378 | - if(defined('DOING_CRON') || $_POST['hash'] == "generate_hash"){ |
|
378 | + if (defined('DOING_CRON') || $_POST['hash'] == "generate_hash") { |
|
379 | 379 | $this->xcloner_settings->generate_new_hash(); |
380 | - }else{ |
|
380 | + } else { |
|
381 | 381 | $this->xcloner_settings->set_hash($_POST['hash']); |
382 | 382 | } |
383 | 383 | } |
384 | 384 | |
385 | - if(defined('DOING_CRON') || !isset($_POST['hash'])) |
|
385 | + if (defined('DOING_CRON') || !isset($_POST['hash'])) |
|
386 | 386 | { |
387 | - add_action( 'shutdown', function(){ |
|
387 | + add_action('shutdown', function() { |
|
388 | 388 | $this->xcloner_filesystem = new Xcloner_File_System($this); |
389 | 389 | $this->xcloner_filesystem->remove_tmp_filesystem(); |
390 | 390 | }); |
@@ -516,20 +516,20 @@ discard block |
||
516 | 516 | $logger = new XCloner_Logger($this, "php_system"); |
517 | 517 | $error = error_get_last(); |
518 | 518 | |
519 | - if($error['type'] and $logger) |
|
519 | + if ($error['type'] and $logger) |
|
520 | 520 | { |
521 | - $logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true)); |
|
521 | + $logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true)); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
525 | 525 | |
526 | 526 | function friendly_error_type($type) { |
527 | - static $levels=null; |
|
528 | - if ($levels===null) { |
|
529 | - $levels=[]; |
|
527 | + static $levels = null; |
|
528 | + if ($levels === null) { |
|
529 | + $levels = []; |
|
530 | 530 | foreach (get_defined_constants() as $key=>$value) { |
531 | - if (strpos($key,'E_')!==0) {continue;} |
|
532 | - $levels[$value]= $key; //substr($key,2); |
|
531 | + if (strpos($key, 'E_') !== 0) {continue; } |
|
532 | + $levels[$value] = $key; //substr($key,2); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
@@ -539,56 +539,56 @@ discard block |
||
539 | 539 | { |
540 | 540 | //adding the pre-update hook |
541 | 541 | |
542 | - if(is_admin() || defined('DOING_CRON')) |
|
542 | + if (is_admin() || defined('DOING_CRON')) |
|
543 | 543 | { |
544 | - $this->xcloner_logger = new XCloner_Logger($this, "xcloner_api"); |
|
545 | - $this->xcloner_filesystem = new Xcloner_File_System($this); |
|
544 | + $this->xcloner_logger = new XCloner_Logger($this, "xcloner_api"); |
|
545 | + $this->xcloner_filesystem = new Xcloner_File_System($this); |
|
546 | 546 | |
547 | 547 | //$this->xcloner_filesystem->set_diff_timestamp_start (strtotime("-15 days")); |
548 | 548 | |
549 | - $this->archive_system = new Xcloner_Archive($this); |
|
550 | - $this->xcloner_database = new Xcloner_Database($this); |
|
551 | - $this->xcloner_scheduler = new Xcloner_Scheduler($this); |
|
552 | - $this->xcloner_remote_storage = new Xcloner_Remote_Storage($this); |
|
549 | + $this->archive_system = new Xcloner_Archive($this); |
|
550 | + $this->xcloner_database = new Xcloner_Database($this); |
|
551 | + $this->xcloner_scheduler = new Xcloner_Scheduler($this); |
|
552 | + $this->xcloner_remote_storage = new Xcloner_Remote_Storage($this); |
|
553 | 553 | $this->xcloner_file_transfer = new Xcloner_File_Transfer($this); |
554 | 554 | $this->xcloner_encryption = new Xcloner_Encryption($this); |
555 | 555 | |
556 | - $xcloner_api = new Xcloner_Api($this); |
|
557 | - |
|
558 | - add_action( 'wp_ajax_get_database_tables_action', array($xcloner_api,'get_database_tables_action') ); |
|
559 | - add_action( 'wp_ajax_get_file_system_action', array($xcloner_api,'get_file_system_action') ); |
|
560 | - add_action( 'wp_ajax_scan_filesystem', array($xcloner_api,'scan_filesystem') ); |
|
561 | - add_action( 'wp_ajax_backup_database', array($xcloner_api,'backup_database') ); |
|
562 | - add_action( 'wp_ajax_backup_files' , array($xcloner_api,'backup_files') ); |
|
563 | - add_action( 'wp_ajax_save_schedule' , array($xcloner_api,'save_schedule') ); |
|
564 | - add_action( 'wp_ajax_get_schedule_by_id', array($xcloner_api,'get_schedule_by_id') ); |
|
565 | - add_action( 'wp_ajax_get_scheduler_list', array($xcloner_api,'get_scheduler_list') ); |
|
566 | - add_action( 'wp_ajax_delete_schedule_by_id' , array($xcloner_api,'delete_schedule_by_id') ); |
|
567 | - add_action( 'wp_ajax_delete_backup_by_name' , array($xcloner_api,'delete_backup_by_name') ); |
|
568 | - add_action( 'wp_ajax_download_backup_by_name', array($xcloner_api,'download_backup_by_name') ); |
|
569 | - add_action( 'wp_ajax_remote_storage_save_status', array($xcloner_api,'remote_storage_save_status') ); |
|
570 | - add_action( 'wp_ajax_upload_backup_to_remote', array($xcloner_api,'upload_backup_to_remote') ); |
|
571 | - add_action( 'wp_ajax_list_backup_files' , array($xcloner_api,'list_backup_files') ); |
|
572 | - add_action( 'wp_ajax_restore_upload_backup' , array($xcloner_api,'restore_upload_backup') ); |
|
573 | - add_action( 'wp_ajax_download_restore_script', array($xcloner_api,'download_restore_script') ); |
|
574 | - add_action( 'wp_ajax_copy_backup_remote_to_local', array($xcloner_api,'copy_backup_remote_to_local') ); |
|
575 | - add_action( 'wp_ajax_restore_backup', array($xcloner_api,'restore_backup') ); |
|
576 | - add_action( 'wp_ajax_backup_encryption', array($xcloner_api,'backup_encryption') ); |
|
577 | - add_action( 'wp_ajax_backup_decryption', array($xcloner_api,'backup_decryption') ); |
|
578 | - add_action( 'wp_ajax_get_manage_backups_list', array($xcloner_api,'get_manage_backups_list') ); |
|
579 | - add_action( 'admin_notices', array($this, 'xcloner_error_admin_notices' )); |
|
556 | + $xcloner_api = new Xcloner_Api($this); |
|
557 | + |
|
558 | + add_action('wp_ajax_get_database_tables_action', array($xcloner_api, 'get_database_tables_action')); |
|
559 | + add_action('wp_ajax_get_file_system_action', array($xcloner_api, 'get_file_system_action')); |
|
560 | + add_action('wp_ajax_scan_filesystem', array($xcloner_api, 'scan_filesystem')); |
|
561 | + add_action('wp_ajax_backup_database', array($xcloner_api, 'backup_database')); |
|
562 | + add_action('wp_ajax_backup_files', array($xcloner_api, 'backup_files')); |
|
563 | + add_action('wp_ajax_save_schedule', array($xcloner_api, 'save_schedule')); |
|
564 | + add_action('wp_ajax_get_schedule_by_id', array($xcloner_api, 'get_schedule_by_id')); |
|
565 | + add_action('wp_ajax_get_scheduler_list', array($xcloner_api, 'get_scheduler_list')); |
|
566 | + add_action('wp_ajax_delete_schedule_by_id', array($xcloner_api, 'delete_schedule_by_id')); |
|
567 | + add_action('wp_ajax_delete_backup_by_name', array($xcloner_api, 'delete_backup_by_name')); |
|
568 | + add_action('wp_ajax_download_backup_by_name', array($xcloner_api, 'download_backup_by_name')); |
|
569 | + add_action('wp_ajax_remote_storage_save_status', array($xcloner_api, 'remote_storage_save_status')); |
|
570 | + add_action('wp_ajax_upload_backup_to_remote', array($xcloner_api, 'upload_backup_to_remote')); |
|
571 | + add_action('wp_ajax_list_backup_files', array($xcloner_api, 'list_backup_files')); |
|
572 | + add_action('wp_ajax_restore_upload_backup', array($xcloner_api, 'restore_upload_backup')); |
|
573 | + add_action('wp_ajax_download_restore_script', array($xcloner_api, 'download_restore_script')); |
|
574 | + add_action('wp_ajax_copy_backup_remote_to_local', array($xcloner_api, 'copy_backup_remote_to_local')); |
|
575 | + add_action('wp_ajax_restore_backup', array($xcloner_api, 'restore_backup')); |
|
576 | + add_action('wp_ajax_backup_encryption', array($xcloner_api, 'backup_encryption')); |
|
577 | + add_action('wp_ajax_backup_decryption', array($xcloner_api, 'backup_decryption')); |
|
578 | + add_action('wp_ajax_get_manage_backups_list', array($xcloner_api, 'get_manage_backups_list')); |
|
579 | + add_action('admin_notices', array($this, 'xcloner_error_admin_notices')); |
|
580 | 580 | |
581 | 581 | } |
582 | 582 | |
583 | 583 | //Do a pre-update backup of targeted files |
584 | - if($this->get_xcloner_settings()->get_xcloner_option('xcloner_enable_pre_update_backup')) |
|
584 | + if ($this->get_xcloner_settings()->get_xcloner_option('xcloner_enable_pre_update_backup')) |
|
585 | 585 | { |
586 | 586 | add_action("pre_auto_update", array($this, "pre_auto_update"), 1, 3); |
587 | 587 | } |
588 | 588 | } |
589 | 589 | |
590 | 590 | function add_plugin_action_links($links, $file) { |
591 | - if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php')) |
|
591 | + if ($file == plugin_basename(dirname(dirname(__FILE__)).'/xcloner.php')) |
|
592 | 592 | { |
593 | 593 | $links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>'; |
594 | 594 | $links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>'; |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | global $wpdb; |
63 | 63 | |
64 | - if ( version_compare( phpversion(), Xcloner_Activator::xcloner_minimum_version, '<' ) ) { |
|
65 | - wp_die( '<p>' . sprintf( __( "XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s" ), Xcloner_Activator::xcloner_minimum_version, phpversion() ) . '</p>', __( "XCloner Activation Error" ), array( 'response' => 500, |
|
64 | + if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) { |
|
65 | + wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array('response' => 500, |
|
66 | 66 | 'back_link' => true |
67 | - ) ); |
|
67 | + )); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $charset_collate = $wpdb->get_charset_collate(); |
71 | 71 | |
72 | - $installed_ver = get_option( "xcloner_db_version" ); |
|
72 | + $installed_ver = get_option("xcloner_db_version"); |
|
73 | 73 | |
74 | 74 | $xcloner_db_version = Xcloner_Activator::xcloner_db_version; |
75 | 75 | |
76 | - $xcloner_scheduler_table = $wpdb->prefix . "xcloner_scheduler"; |
|
76 | + $xcloner_scheduler_table = $wpdb->prefix."xcloner_scheduler"; |
|
77 | 77 | |
78 | - if ( $installed_ver != $xcloner_db_version ) { |
|
79 | - $xcloner_schedule_sql = "CREATE TABLE `" . $xcloner_scheduler_table . "` ( |
|
78 | + if ($installed_ver != $xcloner_db_version) { |
|
79 | + $xcloner_schedule_sql = "CREATE TABLE `".$xcloner_scheduler_table."` ( |
|
80 | 80 | `id` int(11) NOT NULL AUTO_INCREMENT, |
81 | 81 | `name` varchar(255) NOT NULL, |
82 | 82 | `recurrence` varchar(25) NOT NULL, |
@@ -87,73 +87,73 @@ discard block |
||
87 | 87 | `status` int(1) NOT NULL, |
88 | 88 | `last_backup` varchar(100) DEFAULT NULL, |
89 | 89 | PRIMARY KEY (`id`) |
90 | - ) " . $charset_collate . "; |
|
90 | + ) " . $charset_collate."; |
|
91 | 91 | "; |
92 | 92 | |
93 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
94 | - dbDelta( $xcloner_schedule_sql ); |
|
93 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
94 | + dbDelta($xcloner_schedule_sql); |
|
95 | 95 | |
96 | - update_option( "xcloner_db_version", $xcloner_db_version ); |
|
96 | + update_option("xcloner_db_version", $xcloner_db_version); |
|
97 | 97 | } |
98 | 98 | |
99 | - if ( get_option( 'xcloner_backup_compression_level' ) === false ) { |
|
100 | - update_option( 'xcloner_backup_compression_level', 0 ); |
|
99 | + if (get_option('xcloner_backup_compression_level') === false) { |
|
100 | + update_option('xcloner_backup_compression_level', 0); |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( get_option( 'xcloner_enable_log' ) === false ) { |
|
104 | - update_option( 'xcloner_enable_log', 1 ); |
|
103 | + if (get_option('xcloner_enable_log') === false) { |
|
104 | + update_option('xcloner_enable_log', 1); |
|
105 | 105 | } |
106 | 106 | |
107 | - if ( get_option( 'xcloner_enable_mysql_backup' ) === false ) { |
|
108 | - update_option( 'xcloner_enable_mysql_backup', 1 ); |
|
107 | + if (get_option('xcloner_enable_mysql_backup') === false) { |
|
108 | + update_option('xcloner_enable_mysql_backup', 1); |
|
109 | 109 | } |
110 | 110 | |
111 | - if ( get_option( 'xcloner_system_settings_page' ) === false ) { |
|
112 | - update_option( 'xcloner_system_settings_page', 100 ); |
|
111 | + if (get_option('xcloner_system_settings_page') === false) { |
|
112 | + update_option('xcloner_system_settings_page', 100); |
|
113 | 113 | } |
114 | 114 | |
115 | - if ( get_option( 'xcloner_files_to_process_per_request' ) === false ) { |
|
116 | - update_option( 'xcloner_files_to_process_per_request', 250 ); |
|
115 | + if (get_option('xcloner_files_to_process_per_request') === false) { |
|
116 | + update_option('xcloner_files_to_process_per_request', 250); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( get_option( 'xcloner_database_records_per_request' ) === false ) { |
|
120 | - update_option( 'xcloner_database_records_per_request', 10000 ); |
|
119 | + if (get_option('xcloner_database_records_per_request') === false) { |
|
120 | + update_option('xcloner_database_records_per_request', 10000); |
|
121 | 121 | } |
122 | 122 | |
123 | - if ( get_option( 'xcloner_exclude_files_larger_than_mb' ) === false ) { |
|
124 | - update_option( 'xcloner_exclude_files_larger_than_mb', 0 ); |
|
123 | + if (get_option('xcloner_exclude_files_larger_than_mb') === false) { |
|
124 | + update_option('xcloner_exclude_files_larger_than_mb', 0); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( get_option( 'xcloner_split_backup_limit' ) === false ) { |
|
128 | - update_option( 'xcloner_split_backup_limit', 2048 ); |
|
127 | + if (get_option('xcloner_split_backup_limit') === false) { |
|
128 | + update_option('xcloner_split_backup_limit', 2048); |
|
129 | 129 | } |
130 | 130 | |
131 | - if ( get_option( 'xcloner_size_limit_per_request' ) === false ) { |
|
132 | - update_option( 'xcloner_size_limit_per_request', 50 ); |
|
131 | + if (get_option('xcloner_size_limit_per_request') === false) { |
|
132 | + update_option('xcloner_size_limit_per_request', 50); |
|
133 | 133 | } |
134 | 134 | |
135 | - if ( get_option( 'xcloner_cleanup_retention_limit_days' ) === false ) { |
|
136 | - update_option( 'xcloner_cleanup_retention_limit_days', 60 ); |
|
135 | + if (get_option('xcloner_cleanup_retention_limit_days') === false) { |
|
136 | + update_option('xcloner_cleanup_retention_limit_days', 60); |
|
137 | 137 | } |
138 | 138 | |
139 | - if ( get_option( 'xcloner_cleanup_retention_limit_archives' ) === false ) { |
|
140 | - update_option( 'xcloner_cleanup_retention_limit_archives', 100 ); |
|
139 | + if (get_option('xcloner_cleanup_retention_limit_archives') === false) { |
|
140 | + update_option('xcloner_cleanup_retention_limit_archives', 100); |
|
141 | 141 | } |
142 | 142 | |
143 | - if ( get_option( 'xcloner_directories_to_scan_per_request' ) === false ) { |
|
144 | - update_option( 'xcloner_directories_to_scan_per_request', 25 ); |
|
143 | + if (get_option('xcloner_directories_to_scan_per_request') === false) { |
|
144 | + update_option('xcloner_directories_to_scan_per_request', 25); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /*if(!get_option('xcloner_diff_backup_recreate_period')) |
148 | 148 | update_option('xcloner_diff_backup_recreate_period', 10); |
149 | 149 | * */ |
150 | 150 | |
151 | - if ( ! get_option( 'xcloner_regex_exclude' ) ) { |
|
152 | - update_option( 'xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$" . PHP_EOL . "(.*)\.(svn|git)(.*)$" . PHP_EOL . "wp-content\/cache(.*)$" . PHP_EOL . "(.*)error_log$" ); |
|
151 | + if (!get_option('xcloner_regex_exclude')) { |
|
152 | + update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$"); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( ! get_option( 'xcloner_regex_exclude' ) ) { |
|
156 | - update_option( 'xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$" . PHP_EOL . "(.*)\.(svn|git)(.*)$" . PHP_EOL . "wp-content\/cache(.*)$" . PHP_EOL . "(.*)error_log$" ); |
|
155 | + if (!get_option('xcloner_regex_exclude')) { |
|
156 | + update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$"); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | load_plugin_textdomain( |
53 | 53 | 'xcloner-backup-and-restore', |
54 | 54 | false, |
55 | - dirname(dirname(plugin_basename(__FILE__))) . '/languages/' |
|
55 | + dirname(dirname(plugin_basename(__FILE__))).'/languages/' |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | } |
@@ -337,7 +337,7 @@ |
||
337 | 337 | |
338 | 338 | $result = $this->get_var("SELECT count(*) FROM $table;"); |
339 | 339 | |
340 | - return intval($result) ;// not max limit on 32 bit systems 2147483647; on 64 bit 999999999999 |
|
340 | + return intval($result); // not max limit on 32 bit systems 2147483647; on 64 bit 999999999999 |
|
341 | 341 | |
342 | 342 | } |
343 | 343 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->xcloner_remote_storage = $xcloner_container->get_xcloner_remote_storage(); |
90 | 90 | |
91 | 91 | if (isset($_POST['API_ID'])) { |
92 | - $this->logger->info("Processing ajax request ID " . substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), |
|
92 | + $this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), |
|
93 | 93 | 0, 15)); |
94 | 94 | } |
95 | 95 | |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | |
132 | 132 | |
133 | 133 | $data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
134 | - $data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . ".database"; |
|
135 | - $data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "database-sql.sql"; |
|
134 | + $data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS.".database"; |
|
135 | + $data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql"; |
|
136 | 136 | |
137 | 137 | try { |
138 | 138 | $this->xcloner_database->init($data); |
139 | 139 | |
140 | - } catch (Exception $e) { |
|
140 | + }catch (Exception $e) { |
|
141 | 141 | |
142 | 142 | $this->send_response($e->getMessage()); |
143 | 143 | $this->logger->error($e->getMessage()); |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | } else { |
224 | 224 | |
225 | 225 | $schedule['status'] = 1; |
226 | - $schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] . |
|
227 | - " " . $this->form_params['backup_params']['schedule_start_time']); |
|
226 | + $schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date']. |
|
227 | + " ".$this->form_params['backup_params']['schedule_start_time']); |
|
228 | 228 | |
229 | 229 | if ($schedule['start_at'] <= time()) { |
230 | 230 | $schedule['start_at'] = ""; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | if (!isset($_POST['id'])) { |
251 | 251 | $wpdb->insert( |
252 | - $wpdb->prefix . 'xcloner_scheduler', |
|
252 | + $wpdb->prefix.'xcloner_scheduler', |
|
253 | 253 | $schedule, |
254 | 254 | array( |
255 | 255 | '%s', |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | ); |
259 | 259 | } else { |
260 | 260 | $wpdb->update( |
261 | - $wpdb->prefix . 'xcloner_scheduler', |
|
261 | + $wpdb->prefix.'xcloner_scheduler', |
|
262 | 262 | $schedule, |
263 | 263 | array('id' => $_POST['id']), |
264 | 264 | array( |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | try { |
310 | 310 | $return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], |
311 | 311 | $this->form_params['extra'], $init); |
312 | - } catch (Exception $e) { |
|
312 | + }catch (Exception $e) { |
|
313 | 313 | $return = array(); |
314 | 314 | $return['error'] = true; |
315 | 315 | $return['status'] = 500; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $additional['lines_total'] = $return['extra']['lines_total']; |
337 | 337 | $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], |
338 | 338 | $this->form_params, "", $additional); |
339 | - } catch (Exception $e) { |
|
339 | + }catch (Exception $e) { |
|
340 | 340 | $this->logger->error($e->getMessage()); |
341 | 341 | } |
342 | 342 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | if (isset($params->backup_params)) { |
431 | 431 | foreach ($params->backup_params as $param) { |
432 | 432 | $this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value); |
433 | - $this->logger->debug("Adding form parameter " . $param->name . "." . $param->value . "\n", array( |
|
433 | + $this->logger->debug("Adding form parameter ".$param->name.".".$param->value."\n", array( |
|
434 | 434 | 'POST', |
435 | 435 | 'fields filter' |
436 | 436 | )); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | if (isset($params->table_params)) { |
443 | 443 | foreach ($params->table_params as $param) { |
444 | 444 | $this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id); |
445 | - $this->logger->debug("Adding database filter " . $param->parent . "." . $param->id . "\n", array( |
|
445 | + $this->logger->debug("Adding database filter ".$param->parent.".".$param->id."\n", array( |
|
446 | 446 | 'POST', |
447 | 447 | 'database filter' |
448 | 448 | )); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | if (!in_array($param->parent, $this->form_params['excluded_files'])) { |
462 | 462 | //$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id); |
463 | 463 | $unique_exclude_files[] = $param->id; |
464 | - $this->logger->debug("Adding file filter " . $param->id . "\n", array( |
|
464 | + $this->logger->debug("Adding file filter ".$param->id."\n", array( |
|
465 | 465 | 'POST', |
466 | 466 | 'exclude files filter' |
467 | 467 | )); |
@@ -509,13 +509,13 @@ discard block |
||
509 | 509 | 'text' => $this->xcloner_settings->get_xcloner_start_path(), |
510 | 510 | //'children' => true, |
511 | 511 | 'state' => array('selected' => false, 'opened' => true), |
512 | - 'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-root.png" |
|
512 | + 'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/file-icon-root.png" |
|
513 | 513 | ); |
514 | 514 | } |
515 | 515 | |
516 | 516 | try { |
517 | 517 | $files = $this->xcloner_file_system->list_directory($folder); |
518 | - } catch (Exception $e) { |
|
518 | + }catch (Exception $e) { |
|
519 | 519 | |
520 | 520 | print $e->getMessage(); |
521 | 521 | $this->logger->error($e->getMessage()); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | if ($file['type'] == "dir") { |
537 | 537 | $children = true; |
538 | 538 | } else { |
539 | - $text .= " (" . $this->xcloner_requirements->file_format_size($file['size']) . ")"; |
|
539 | + $text .= " (".$this->xcloner_requirements->file_format_size($file['size']).")"; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | if ($this->xcloner_file_system->is_excluded($file)) { |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | //'title' => "test", |
553 | 553 | 'children' => $children, |
554 | 554 | 'state' => array('selected' => $selected, 'opened' => false, "checkbox_disabled" => $selected), |
555 | - 'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-" . strtolower(substr($file['type'], |
|
556 | - 0, 1)) . ".png" |
|
555 | + 'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/file-icon-".strtolower(substr($file['type'], |
|
556 | + 0, 1)).".png" |
|
557 | 557 | ); |
558 | 558 | } |
559 | 559 | |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | if ($database == "#") { |
580 | 580 | try { |
581 | 581 | $return = $this->xcloner_database->get_all_databases(); |
582 | - } catch (Exception $e) { |
|
582 | + }catch (Exception $e) { |
|
583 | 583 | $this->logger->error($e->getMessage()); |
584 | 584 | } |
585 | 585 | |
@@ -600,10 +600,10 @@ discard block |
||
600 | 600 | $data[] = array( |
601 | 601 | 'id' => $database['name'], |
602 | 602 | 'parent' => '#', |
603 | - 'text' => $database['name'] . " (" . (int)$database['num_tables'] . ")", |
|
603 | + 'text' => $database['name']." (".(int)$database['num_tables'].")", |
|
604 | 604 | 'children' => true, |
605 | 605 | 'state' => $state, |
606 | - 'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/database-icon.png" |
|
606 | + 'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/database-icon.png" |
|
607 | 607 | ); |
608 | 608 | } |
609 | 609 | |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | |
612 | 612 | try { |
613 | 613 | $return = $this->xcloner_database->list_tables($database, "", 1); |
614 | - } catch (Exception $e) { |
|
614 | + }catch (Exception $e) { |
|
615 | 615 | $this->logger->error($e->getMessage()); |
616 | 616 | } |
617 | 617 | |
@@ -628,12 +628,12 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | $data[] = array( |
631 | - 'id' => $database . "." . $table['name'], |
|
631 | + 'id' => $database.".".$table['name'], |
|
632 | 632 | 'parent' => $database, |
633 | - 'text' => $table['name'] . " (" . (int)$table['records'] . ")", |
|
633 | + 'text' => $table['name']." (".(int)$table['records'].")", |
|
634 | 634 | 'children' => false, |
635 | 635 | 'state' => $state, |
636 | - 'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/table-icon.png" |
|
636 | + 'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/table-icon.png" |
|
637 | 637 | ); |
638 | 638 | } |
639 | 639 | } |
@@ -677,17 +677,17 @@ discard block |
||
677 | 677 | $return['data'] = array(); |
678 | 678 | |
679 | 679 | foreach ($data as $res) { |
680 | - $action = "<a href=\"#" . $res->id . "\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> |
|
681 | - <a href=\"#" . $res->id . "\" class=\"delete\" title='Delete'><i class=\"material-icons \">delete</i></a>"; |
|
680 | + $action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> |
|
681 | + <a href=\"#" . $res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons \">delete</i></a>"; |
|
682 | 682 | if ($res->status) { |
683 | 683 | $status = '<i class="material-icons active status">timer</i>'; |
684 | 684 | } else { |
685 | 685 | $status = '<i class="material-icons status inactive">timer_off</i>'; |
686 | 686 | } |
687 | 687 | |
688 | - $next_run_time = wp_next_scheduled('xcloner_scheduler_' . $res->id, array($res->id)); |
|
688 | + $next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id)); |
|
689 | 689 | |
690 | - $next_run = date(get_option('date_format') . " " . get_option('time_format'), $next_run_time); |
|
690 | + $next_run = date(get_option('date_format')." ".get_option('time_format'), $next_run_time); |
|
691 | 691 | |
692 | 692 | $remote_storage = $res->remote_storage; |
693 | 693 | |
@@ -696,16 +696,16 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | if (trim($next_run)) { |
699 | - $date_text = date(get_option('date_format') . " " . get_option('time_format'), |
|
699 | + $date_text = date(get_option('date_format')." ".get_option('time_format'), |
|
700 | 700 | $next_run_time + (get_option('gmt_offset') * HOUR_IN_SECONDS)); |
701 | 701 | |
702 | 702 | if ($next_run_time >= time()) { |
703 | - $next_run = "in " . human_time_diff($next_run_time, time()); |
|
703 | + $next_run = "in ".human_time_diff($next_run_time, time()); |
|
704 | 704 | } else { |
705 | 705 | $next_run = __("executed", 'xcloner-backup-and-restore'); |
706 | 706 | } |
707 | 707 | |
708 | - $next_run = "<a href='#' title='" . $date_text . "'>" . $next_run . "</a>"; |
|
708 | + $next_run = "<a href='#' title='".$date_text."'>".$next_run."</a>"; |
|
709 | 709 | //$next_run .=" ($date_text)"; |
710 | 710 | } |
711 | 711 | |
@@ -717,11 +717,11 @@ discard block |
||
717 | 717 | if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup)) { |
718 | 718 | $metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup); |
719 | 719 | $backup_size = size_format($this->xcloner_file_system->get_backup_size($res->last_backup)); |
720 | - $backup_time = date(get_option('date_format') . " " . get_option('time_format'), |
|
720 | + $backup_time = date(get_option('date_format')." ".get_option('time_format'), |
|
721 | 721 | $metadata['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS)); |
722 | 722 | } |
723 | 723 | |
724 | - $backup_text = "<span title='" . $backup_time . "' class='shorten_string'>" . $res->last_backup . " (" . $backup_size . ")</span>"; |
|
724 | + $backup_text = "<span title='".$backup_time."' class='shorten_string'>".$res->last_backup." (".$backup_size.")</span>"; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | $schedules = wp_get_schedules(); |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | $return['data'][] = array( |
734 | 734 | $res->id, |
735 | 735 | $res->name, |
736 | - $res->recurrence,/*$res->start_at,*/ |
|
736 | + $res->recurrence, /*$res->start_at,*/ |
|
737 | 737 | $next_run, |
738 | 738 | $remote_storage, |
739 | 739 | $backup_text, |
@@ -795,25 +795,25 @@ discard block |
||
795 | 795 | $this->process_params($params); |
796 | 796 | $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($this->form_params['extra']['backup_parent']); |
797 | 797 | |
798 | - if(isset($this->form_params['extra']['start'])) { |
|
798 | + if (isset($this->form_params['extra']['start'])) { |
|
799 | 799 | $start = $this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['start']); |
800 | - }else{ |
|
800 | + } else { |
|
801 | 801 | $start = 0; |
802 | 802 | } |
803 | 803 | |
804 | - if(isset($this->form_params['extra']['iv'])) { |
|
804 | + if (isset($this->form_params['extra']['iv'])) { |
|
805 | 805 | $iv = $this->xcloner_sanitization->sanitize_input_as_raw($this->form_params['extra']['iv']); |
806 | - }else{ |
|
806 | + } else { |
|
807 | 807 | $iv = ""; |
808 | 808 | } |
809 | 809 | |
810 | - if(isset($this->form_params['extra']['part'])) { |
|
810 | + if (isset($this->form_params['extra']['part'])) { |
|
811 | 811 | $return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['part']); |
812 | - }else{ |
|
812 | + } else { |
|
813 | 813 | $return['part'] = 0; |
814 | 814 | } |
815 | 815 | |
816 | - }else{ |
|
816 | + } else { |
|
817 | 817 | $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']); |
818 | 818 | $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']); |
819 | 819 | $iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']); |
@@ -828,14 +828,14 @@ discard block |
||
828 | 828 | } |
829 | 829 | |
830 | 830 | $return['processing_file'] = $backup_file; |
831 | - $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file); |
|
831 | + $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file); |
|
832 | 832 | |
833 | 833 | try { |
834 | 834 | $this->logger->info(json_encode($_POST)); |
835 | 835 | $this->logger->info($iv); |
836 | 836 | $return = array_merge($return, |
837 | 837 | $this->xcloner_encryption->encrypt_file($backup_file, "", "", $start, base64_decode($iv))); |
838 | - }catch(\Exception $e){ |
|
838 | + }catch (\Exception $e) { |
|
839 | 839 | $return['error'] = true; |
840 | 840 | $return['message'] = $e->getMessage(); |
841 | 841 | $return['error_message'] = $e->getMessage(); |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | |
844 | 844 | //echo strlen($return['iv']);exit; |
845 | 845 | |
846 | - if($return['finished']) { |
|
846 | + if ($return['finished']) { |
|
847 | 847 | if ($this->xcloner_file_system->is_multipart($source_backup_file)) { |
848 | 848 | $return['start'] = 0; |
849 | 849 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | } |
858 | 858 | |
859 | 859 | if (isset($_POST['data'])) { |
860 | - $return['extra'] = array_merge($this->form_params['extra'], $return); |
|
860 | + $return['extra'] = array_merge($this->form_params['extra'], $return); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | $this->send_response($return, 0); |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']); |
877 | 877 | $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']); |
878 | 878 | $iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']); |
879 | - $decryption_key = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['decryption_key']);; |
|
879 | + $decryption_key = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['decryption_key']); ; |
|
880 | 880 | $return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']); |
881 | 881 | |
882 | 882 | $backup_file = $source_backup_file; |
@@ -887,17 +887,17 @@ discard block |
||
887 | 887 | } |
888 | 888 | |
889 | 889 | $return['processing_file'] = $backup_file; |
890 | - $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file); |
|
890 | + $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file); |
|
891 | 891 | |
892 | 892 | try { |
893 | 893 | $return = array_merge($return, |
894 | 894 | $this->xcloner_encryption->decrypt_file($backup_file, "", $decryption_key, $start, base64_decode($iv))); |
895 | - }catch(\Exception $e){ |
|
895 | + }catch (\Exception $e) { |
|
896 | 896 | $return['error'] = true; |
897 | 897 | $return['message'] = $e->getMessage(); |
898 | 898 | } |
899 | 899 | |
900 | - if($return['finished']) { |
|
900 | + if ($return['finished']) { |
|
901 | 901 | if ($this->xcloner_file_system->is_multipart($source_backup_file)) { |
902 | 902 | $return['start'] = 0; |
903 | 903 | |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | foreach ($backup_list as $file_info):?> |
930 | 930 | <?php |
931 | 931 | if ($storage_selection == "gdrive") { |
932 | - $file_info['path'] = $file_info['filename'] . "." . $file_info['extension']; |
|
932 | + $file_info['path'] = $file_info['filename'].".".$file_info['extension']; |
|
933 | 933 | } |
934 | 934 | $file_exists_on_local_storage = true; |
935 | 935 | |
@@ -1050,10 +1050,10 @@ discard block |
||
1050 | 1050 | <?php endif ?> |
1051 | 1051 | <?php |
1052 | 1052 | $basename = $file_info['basename']; |
1053 | - if(isset($file_info['childs']) and sizeof($file_info['childs'])) |
|
1053 | + if (isset($file_info['childs']) and sizeof($file_info['childs'])) |
|
1054 | 1054 | $basename = $file_info['childs'][0][0]; |
1055 | 1055 | ?> |
1056 | - <?php if($this->xcloner_encryption->is_encrypted_file($basename)) :?> |
|
1056 | + <?php if ($this->xcloner_encryption->is_encrypted_file($basename)) :?> |
|
1057 | 1057 | <a href="#<?php echo $file_info['basename'] ?>" class="backup-decryption" |
1058 | 1058 | title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>"> |
1059 | 1059 | <i class="material-icons">enhanced_encryption</i> |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | $backup_file = $backup_parts[$return['part']]; |
1111 | 1111 | } |
1112 | 1112 | |
1113 | - if($this->xcloner_encryption->is_encrypted_file($backup_file)) { |
|
1113 | + if ($this->xcloner_encryption->is_encrypted_file($backup_file)) { |
|
1114 | 1114 | $return['error'] = true; |
1115 | 1115 | $return['message'] = __("Backup archive is encrypted, please decrypt it first before you can list it's content.", "xcloner-backup-and-restore"); |
1116 | 1116 | $this->send_response($return, 0); |
@@ -1118,10 +1118,10 @@ discard block |
||
1118 | 1118 | |
1119 | 1119 | try { |
1120 | 1120 | $tar = new Tar(); |
1121 | - $tar->open($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file, $start); |
|
1121 | + $tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start); |
|
1122 | 1122 | |
1123 | 1123 | $data = $tar->contents(get_option('xcloner_files_to_process_per_request')); |
1124 | - } catch (Exception $e) { |
|
1124 | + }catch (Exception $e) { |
|
1125 | 1125 | $return['error'] = true; |
1126 | 1126 | $return['message'] = $e->getMessage(); |
1127 | 1127 | $this->send_response($return, 0); |
@@ -1129,14 +1129,14 @@ discard block |
||
1129 | 1129 | |
1130 | 1130 | $return['files'] = array(); |
1131 | 1131 | $return['finished'] = 1; |
1132 | - $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file); |
|
1132 | + $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file); |
|
1133 | 1133 | $i = 0; |
1134 | 1134 | |
1135 | 1135 | if (isset($data['extracted_files']) and is_array($data['extracted_files'])) { |
1136 | 1136 | foreach ($data['extracted_files'] as $file) { |
1137 | 1137 | $return['files'][$i]['path'] = $file->getPath(); |
1138 | 1138 | $return['files'][$i]['size'] = $file->getSize(); |
1139 | - $return['files'][$i]['mtime'] = date(get_option('date_format') . " " . get_option('time_format'), |
|
1139 | + $return['files'][$i]['mtime'] = date(get_option('date_format')." ".get_option('time_format'), |
|
1140 | 1140 | $file->getMtime()); |
1141 | 1141 | |
1142 | 1142 | $i++; |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | "copy_backup_remote_to_local" |
1185 | 1185 | ), array($backup_file, $storage_type)); |
1186 | 1186 | } |
1187 | - } catch (Exception $e) { |
|
1187 | + }catch (Exception $e) { |
|
1188 | 1188 | |
1189 | 1189 | $return['error'] = 1; |
1190 | 1190 | $return['message'] = $e->getMessage(); |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | "upload_backup_to_storage" |
1224 | 1224 | ), array($backup_file, $storage_type)); |
1225 | 1225 | } |
1226 | - } catch (Exception $e) { |
|
1226 | + }catch (Exception $e) { |
|
1227 | 1227 | |
1228 | 1228 | $return['error'] = 1; |
1229 | 1229 | $return['message'] = $e->getMessage(); |
@@ -1283,21 +1283,21 @@ discard block |
||
1283 | 1283 | $phar2->setStub($phar2->createDefaultStub('vendor/autoload.php', 'vendor/autoload.php')); |
1284 | 1284 | * */ |
1285 | 1285 | |
1286 | - $tmp_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "xcloner-restore.tgz"; |
|
1286 | + $tmp_file = $this->xcloner_settings->get_xcloner_tmp_path().DS."xcloner-restore.tgz"; |
|
1287 | 1287 | |
1288 | 1288 | $tar = new Tar(); |
1289 | 1289 | $tar->create($tmp_file); |
1290 | 1290 | |
1291 | - $tar->addFile(dirname(__DIR__) . "/restore/vendor.build.txt", "vendor.phar"); |
|
1291 | + $tar->addFile(dirname(__DIR__)."/restore/vendor.build.txt", "vendor.phar"); |
|
1292 | 1292 | //$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz"); |
1293 | 1293 | |
1294 | 1294 | $files = $xcloner_plugin_filesystem->listContents("vendor/", true); |
1295 | 1295 | foreach ($files as $file) { |
1296 | - $tar->addFile(dirname(__DIR__) . DS . $file['path'], $file['path']); |
|
1296 | + $tar->addFile(dirname(__DIR__).DS.$file['path'], $file['path']); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $content = file_get_contents(dirname(__DIR__) . "/restore/xcloner_restore.php"); |
|
1300 | - $content = str_replace("define('AUTH_KEY', '');", "define('AUTH_KEY', '" . md5(AUTH_KEY) . "');", $content); |
|
1299 | + $content = file_get_contents(dirname(__DIR__)."/restore/xcloner_restore.php"); |
|
1300 | + $content = str_replace("define('AUTH_KEY', '');", "define('AUTH_KEY', '".md5(AUTH_KEY)."');", $content); |
|
1301 | 1301 | |
1302 | 1302 | $tar->addData("xcloner_restore.php", $content); |
1303 | 1303 | |
@@ -1306,11 +1306,11 @@ discard block |
||
1306 | 1306 | if (file_exists($tmp_file)) { |
1307 | 1307 | header('Content-Description: File Transfer'); |
1308 | 1308 | header('Content-Type: application/octet-stream'); |
1309 | - header('Content-Disposition: attachment; filename="' . basename($tmp_file) . '"'); |
|
1309 | + header('Content-Disposition: attachment; filename="'.basename($tmp_file).'"'); |
|
1310 | 1310 | header('Expires: 0'); |
1311 | 1311 | header('Cache-Control: must-revalidate'); |
1312 | 1312 | header('Pragma: public'); |
1313 | - header('Content-Length: ' . filesize($tmp_file)); |
|
1313 | + header('Content-Length: '.filesize($tmp_file)); |
|
1314 | 1314 | readfile($tmp_file); |
1315 | 1315 | |
1316 | 1316 | } |
@@ -1342,9 +1342,9 @@ discard block |
||
1342 | 1342 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1343 | 1343 | header('Cache-Control: private', false); |
1344 | 1344 | header('Content-Transfer-Encoding: binary'); |
1345 | - header('Content-Disposition: attachment; filename="' . $metadata['path'] . '";'); |
|
1345 | + header('Content-Disposition: attachment; filename="'.$metadata['path'].'";'); |
|
1346 | 1346 | header('Content-Type: application/octet-stream'); |
1347 | - header('Content-Length: ' . $metadata['size']); |
|
1347 | + header('Content-Length: '.$metadata['size']); |
|
1348 | 1348 | |
1349 | 1349 | @ob_end_clean(); |
1350 | 1350 | |
@@ -1404,12 +1404,12 @@ discard block |
||
1404 | 1404 | $xcloner_file_transfer->set_target($target_url); |
1405 | 1405 | $return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash); |
1406 | 1406 | |
1407 | - } catch (Exception $e) { |
|
1407 | + }catch (Exception $e) { |
|
1408 | 1408 | |
1409 | 1409 | $return = array(); |
1410 | 1410 | $return['error'] = true; |
1411 | 1411 | $return['status'] = 500; |
1412 | - $return['message'] = "CURL communication error with the restore host. " . $e->getMessage(); |
|
1412 | + $return['message'] = "CURL communication error with the restore host. ".$e->getMessage(); |
|
1413 | 1413 | $this->send_response($return, 0); |
1414 | 1414 | |
1415 | 1415 | } |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | $this->check_access(); |
1434 | 1434 | |
1435 | 1435 | define("XCLONER_PLUGIN_ACCESS", 1); |
1436 | - include_once(dirname(__DIR__) . DS . "restore" . DS . "xcloner_restore.php"); |
|
1436 | + include_once(dirname(__DIR__).DS."restore".DS."xcloner_restore.php"); |
|
1437 | 1437 | |
1438 | 1438 | return; |
1439 | 1439 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | return $update; |
171 | 171 | } |
172 | 172 | |
173 | - public function update_hash( $schedule_id, $hash ) { |
|
173 | + public function update_hash($schedule_id, $hash) { |
|
174 | 174 | $schedule = array(); |
175 | 175 | |
176 | 176 | $schedule['hash'] = $hash; |
@@ -207,91 +207,91 @@ discard block |
||
207 | 207 | return $update; |
208 | 208 | } |
209 | 209 | |
210 | - private function _xcloner_scheduler_callback( $id, $schedule ) { |
|
211 | - set_time_limit( 0 ); |
|
210 | + private function _xcloner_scheduler_callback($id, $schedule) { |
|
211 | + set_time_limit(0); |
|
212 | 212 | |
213 | 213 | $xcloner = new XCloner(); |
214 | 214 | $xcloner->init(); |
215 | - $this->set_xcloner_container( $xcloner ); |
|
215 | + $this->set_xcloner_container($xcloner); |
|
216 | 216 | |
217 | 217 | #$hash = $this->xcloner_settings->get_hash(); |
218 | 218 | #$this->get_xcloner_container()->get_xcloner_settings()->set_hash($hash); |
219 | 219 | |
220 | 220 | //$this->xcloner_settings = $this->get_xcloner_container()->get_xcloner_settings(); |
221 | 221 | $this->xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
222 | - $this->xcloner_encryption = $this->get_xcloner_container()->get_xcloner_encryption(); |
|
222 | + $this->xcloner_encryption = $this->get_xcloner_container()->get_xcloner_encryption(); |
|
223 | 223 | $this->xcloner_database = $this->get_xcloner_container()->get_xcloner_database(); |
224 | 224 | $this->archive_system = $this->get_xcloner_container()->get_archive_system(); |
225 | - $this->logger = $this->get_xcloner_container()->get_xcloner_logger()->withName( "xcloner_scheduler" ); |
|
225 | + $this->logger = $this->get_xcloner_container()->get_xcloner_logger()->withName("xcloner_scheduler"); |
|
226 | 226 | $this->xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
227 | 227 | |
228 | - $this->logger->info( sprintf( "New schedule hash is %s", $this->xcloner_settings->get_hash() ) ); |
|
228 | + $this->logger->info(sprintf("New schedule hash is %s", $this->xcloner_settings->get_hash())); |
|
229 | 229 | |
230 | - if ( isset( $schedule['backup_params']->diff_start_date ) && $schedule['backup_params']->diff_start_date ) { |
|
231 | - $this->xcloner_file_system->set_diff_timestamp_start( $schedule['backup_params']->diff_start_date ); |
|
230 | + if (isset($schedule['backup_params']->diff_start_date) && $schedule['backup_params']->diff_start_date) { |
|
231 | + $this->xcloner_file_system->set_diff_timestamp_start($schedule['backup_params']->diff_start_date); |
|
232 | 232 | } |
233 | 233 | |
234 | - if ( $schedule['recurrence'] == "single" ) { |
|
235 | - $this->disable_single_cron( $schedule['id'] ); |
|
234 | + if ($schedule['recurrence'] == "single") { |
|
235 | + $this->disable_single_cron($schedule['id']); |
|
236 | 236 | } |
237 | 237 | |
238 | - if ( ! $schedule ) { |
|
239 | - $this->logger->info( sprintf( "Could not load schedule with id'%s'", $id ), array( "CRON" ) ); |
|
238 | + if (!$schedule) { |
|
239 | + $this->logger->info(sprintf("Could not load schedule with id'%s'", $id), array("CRON")); |
|
240 | 240 | |
241 | 241 | return; |
242 | 242 | } |
243 | 243 | |
244 | 244 | //echo $this->get_xcloner_container()->get_xcloner_settings()->get_hash(); exit; |
245 | 245 | |
246 | - $this->update_hash( $schedule['id'], $this->xcloner_settings->get_hash() ); |
|
246 | + $this->update_hash($schedule['id'], $this->xcloner_settings->get_hash()); |
|
247 | 247 | |
248 | - $this->logger->info( sprintf( "Starting cron schedule '%s'", $schedule['name'] ), array( "CRON" ) ); |
|
248 | + $this->logger->info(sprintf("Starting cron schedule '%s'", $schedule['name']), array("CRON")); |
|
249 | 249 | |
250 | - $this->xcloner_file_system->set_excluded_files( json_decode( $schedule['excluded_files'] ) ); |
|
250 | + $this->xcloner_file_system->set_excluded_files(json_decode($schedule['excluded_files'])); |
|
251 | 251 | |
252 | 252 | $init = 1; |
253 | 253 | $continue = 1; |
254 | 254 | |
255 | - while ( $continue ) { |
|
256 | - $continue = $this->xcloner_file_system->start_file_recursion( $init ); |
|
255 | + while ($continue) { |
|
256 | + $continue = $this->xcloner_file_system->start_file_recursion($init); |
|
257 | 257 | |
258 | 258 | $init = 0; |
259 | 259 | } |
260 | 260 | |
261 | - $this->logger->info( sprintf( "File scan finished" ), array( "CRON" ) ); |
|
261 | + $this->logger->info(sprintf("File scan finished"), array("CRON")); |
|
262 | 262 | |
263 | - $this->logger->info( sprintf( "Starting the database backup" ), array( "CRON" ) ); |
|
263 | + $this->logger->info(sprintf("Starting the database backup"), array("CRON")); |
|
264 | 264 | |
265 | 265 | $init = 1; |
266 | 266 | $return['finished'] = 0; |
267 | 267 | |
268 | - while ( ! $return['finished'] ) { |
|
269 | - $return = $this->xcloner_database->start_database_recursion( (array) json_decode( $schedule['table_params'] ), $return, $init ); |
|
268 | + while (!$return['finished']) { |
|
269 | + $return = $this->xcloner_database->start_database_recursion((array)json_decode($schedule['table_params']), $return, $init); |
|
270 | 270 | $init = 0; |
271 | 271 | } |
272 | 272 | |
273 | - $this->logger->info( sprintf( "Database backup done" ), array( "CRON" ) ); |
|
273 | + $this->logger->info(sprintf("Database backup done"), array("CRON")); |
|
274 | 274 | |
275 | - $this->logger->info( sprintf( "Starting file archive process" ), array( "CRON" ) ); |
|
275 | + $this->logger->info(sprintf("Starting file archive process"), array("CRON")); |
|
276 | 276 | |
277 | 277 | $init = 0; |
278 | 278 | $return['finished'] = 0; |
279 | 279 | $return['extra'] = array(); |
280 | 280 | |
281 | - while ( ! $return['finished'] ) { |
|
282 | - $return = $this->archive_system->start_incremental_backup( (array) $schedule['backup_params'], $return['extra'], $init ); |
|
281 | + while (!$return['finished']) { |
|
282 | + $return = $this->archive_system->start_incremental_backup((array)$schedule['backup_params'], $return['extra'], $init); |
|
283 | 283 | $init = 0; |
284 | 284 | } |
285 | - $this->logger->info( sprintf( "File archive process FINISHED." ), array( "CRON" ) ); |
|
285 | + $this->logger->info(sprintf("File archive process FINISHED."), array("CRON")); |
|
286 | 286 | |
287 | 287 | //getting the last backup archive file |
288 | 288 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension(); |
289 | - if ( $this->xcloner_file_system->is_part( $this->archive_system->get_archive_name_with_extension() ) ) { |
|
289 | + if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) { |
|
290 | 290 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
291 | 291 | } |
292 | 292 | |
293 | 293 | //Updating schedule last backup archive |
294 | - $this->update_last_backup( $schedule['id'], $return['extra']['backup_parent'] ); |
|
294 | + $this->update_last_backup($schedule['id'], $return['extra']['backup_parent']); |
|
295 | 295 | |
296 | 296 | //Encrypting the backup archive |
297 | 297 | $return_encrypted['finished'] = 0; |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | $part = 0; |
302 | 302 | $backup_parts = array(); |
303 | 303 | |
304 | - if( $schedule['backup_params']->backup_encrypt){ |
|
305 | - $this->logger->info( sprintf( "Encrypting backup archive %s.", $return['extra']['backup_parent'] ), array( "CRON" ) ); |
|
304 | + if ($schedule['backup_params']->backup_encrypt) { |
|
305 | + $this->logger->info(sprintf("Encrypting backup archive %s.", $return['extra']['backup_parent']), array("CRON")); |
|
306 | 306 | |
307 | 307 | $backup_file = $return['extra']['backup_parent']; |
308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $backup_file = $backup_parts[$part]; |
312 | 312 | } |
313 | 313 | |
314 | - while ( ! $return_encrypted['finished'] ) { |
|
314 | + while (!$return_encrypted['finished']) { |
|
315 | 315 | $return_encrypted = $this->xcloner_encryption->encrypt_file( |
316 | 316 | $backup_file, |
317 | 317 | "", |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | true |
323 | 323 | ); |
324 | 324 | |
325 | - if($return_encrypted['finished']) { |
|
325 | + if ($return_encrypted['finished']) { |
|
326 | 326 | ++$part; |
327 | 327 | |
328 | 328 | if ($part < sizeof($backup_parts)) { |
@@ -334,37 +334,37 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | //Sending backup to remote storage |
337 | - if ( isset( $schedule['remote_storage'] ) && $schedule['remote_storage'] && array_key_exists( $schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages() ) ) { |
|
337 | + if (isset($schedule['remote_storage']) && $schedule['remote_storage'] && array_key_exists($schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages())) { |
|
338 | 338 | $backup_file = $return['extra']['backup_parent']; |
339 | 339 | |
340 | - $this->logger->info( sprintf( "Transferring backup to remote storage %s", strtoupper( $schedule['remote_storage'] ) ), array( "CRON" ) ); |
|
340 | + $this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON")); |
|
341 | 341 | |
342 | - if ( method_exists( $this->xcloner_remote_storage, "upload_backup_to_storage" ) ) { |
|
343 | - call_user_func_array( array( |
|
342 | + if (method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) { |
|
343 | + call_user_func_array(array( |
|
344 | 344 | $this->xcloner_remote_storage, |
345 | 345 | "upload_backup_to_storage" |
346 | - ), array( $backup_file, $schedule['remote_storage'] ) ); |
|
346 | + ), array($backup_file, $schedule['remote_storage'])); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | 350 | //Sending email notification |
351 | - if ( isset( $schedule['backup_params']->email_notification ) and $to = $schedule['backup_params']->email_notification ) { |
|
351 | + if (isset($schedule['backup_params']->email_notification) and $to = $schedule['backup_params']->email_notification) { |
|
352 | 352 | try { |
353 | 353 | $from = ""; |
354 | 354 | $additional['lines_total'] = $return['extra']['lines_total']; |
355 | - $subject = sprintf( __( "%s - new backup generated %s" ), $schedule['name'], $return['extra']['backup_parent'] ); |
|
355 | + $subject = sprintf(__("%s - new backup generated %s"), $schedule['name'], $return['extra']['backup_parent']); |
|
356 | 356 | |
357 | - $this->archive_system->send_notification( $to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional ); |
|
357 | + $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional); |
|
358 | 358 | |
359 | - } catch ( Exception $e ) { |
|
360 | - $this->logger->error( $e->getMessage() ); |
|
359 | + }catch (Exception $e) { |
|
360 | + $this->logger->error($e->getMessage()); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | |
364 | 364 | //CHECK IF WE SHOULD DELETE BACKUP AFTER REMOTE TRANSFER IS DONE |
365 | - if ( $schedule['remote_storage'] && $this->xcloner_settings->get_xcloner_option( 'xcloner_cleanup_delete_after_remote_transfer' ) ) { |
|
366 | - $this->logger->info( sprintf( "Deleting %s from local storage matching rule xcloner_cleanup_delete_after_remote_transfer", $return['extra']['backup_parent'] ) ); |
|
367 | - $this->xcloner_file_system->delete_backup_by_name( $return['extra']['backup_parent'] ); |
|
365 | + if ($schedule['remote_storage'] && $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_delete_after_remote_transfer')) { |
|
366 | + $this->logger->info(sprintf("Deleting %s from local storage matching rule xcloner_cleanup_delete_after_remote_transfer", $return['extra']['backup_parent'])); |
|
367 | + $this->xcloner_file_system->delete_backup_by_name($return['extra']['backup_parent']); |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -378,28 +378,28 @@ discard block |
||
378 | 378 | $this->xcloner_file_system->cleanup_tmp_directories(); |
379 | 379 | } |
380 | 380 | |
381 | - public function xcloner_scheduler_callback( $id, $schedule = "" ) { |
|
382 | - if ( $id ) { |
|
383 | - $schedule = $this->get_schedule_by_id( $id ); |
|
381 | + public function xcloner_scheduler_callback($id, $schedule = "") { |
|
382 | + if ($id) { |
|
383 | + $schedule = $this->get_schedule_by_id($id); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | try { |
387 | - if( get_option('xcloner_disable_email_notification') ) { |
|
387 | + if (get_option('xcloner_disable_email_notification')) { |
|
388 | 388 | //we disable email notifications |
389 | 389 | $schedule['backup_params']->email_notification = ""; |
390 | 390 | } |
391 | - $this->_xcloner_scheduler_callback( $id, $schedule ); |
|
391 | + $this->_xcloner_scheduler_callback($id, $schedule); |
|
392 | 392 | |
393 | - } catch ( Exception $e ) { |
|
393 | + }catch (Exception $e) { |
|
394 | 394 | |
395 | 395 | //send email to site admin if email notification is not set in the scheduler |
396 | - if ( ! isset( $schedule['backup_params']->email_notification ) || ! $schedule['backup_params']->email_notification ) { |
|
397 | - $schedule['backup_params']->email_notification = get_option( 'admin_email' ); |
|
396 | + if (!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification) { |
|
397 | + $schedule['backup_params']->email_notification = get_option('admin_email'); |
|
398 | 398 | } |
399 | 399 | |
400 | - if ( isset( $schedule['backup_params']->email_notification ) && $to = $schedule['backup_params']->email_notification ) { |
|
400 | + if (isset($schedule['backup_params']->email_notification) && $to = $schedule['backup_params']->email_notification) { |
|
401 | 401 | $from = ""; |
402 | - $this->archive_system->send_notification( $to, $from, $schedule['name'] . " - backup error", "", "", $e->getMessage() ); |
|
402 | + $this->archive_system->send_notification($to, $from, $schedule['name']." - backup error", "", "", $e->getMessage()); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $new_name = $this->archive_name; |
149 | 149 | |
150 | 150 | if (!stristr($new_name, "-diff")) { |
151 | - $new_name = $this->archive_name . "-diff" . date("Y-m-d_H-i", $diff_timestamp_start); |
|
151 | + $new_name = $this->archive_name."-diff".date("Y-m-d_H-i", $diff_timestamp_start); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $this->archive_name = $new_name; |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | if (isset($part) and $part) { |
159 | - $new_name = preg_replace('/-part(\d*)/', "-part" . $part, $this->archive_name); |
|
159 | + $new_name = preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name); |
|
160 | 160 | if (!stristr($new_name, "-part")) { |
161 | - $new_name = $this->archive_name . "-part" . $part; |
|
161 | + $new_name = $this->archive_name."-part".$part; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | $this->archive_name = $new_name; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | public function get_archive_name_multipart() |
188 | 188 | { |
189 | 189 | $new_name = preg_replace('/-part(\d*)/', "", $this->archive_name); |
190 | - return $new_name . "-multipart" . $this->xcloner_settings->get_backup_extension_name(".csv"); |
|
190 | + return $new_name."-multipart".$this->xcloner_settings->get_backup_extension_name(".csv"); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /* |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function get_archive_name_with_extension() |
199 | 199 | { |
200 | - return $this->archive_name . $this->xcloner_settings->get_backup_extension_name(); |
|
200 | + return $this->archive_name.$this->xcloner_settings->get_backup_extension_name(); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /* |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $headers = array('Content-Type: text/html; charset=UTF-8'); |
234 | 234 | |
235 | 235 | if ($admin_email and $from) { |
236 | - $headers[] = 'From: ' . $from . ' <' . $admin_email . '>'; |
|
236 | + $headers[] = 'From: '.$from.' <'.$admin_email.'>'; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | $return = wp_mail($to, $subject, $body, $headers); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | public function get_xcloner_encryption_key() { |
58 | 58 | |
59 | - if(!get_option('xcloner_encryption_key') ) |
|
59 | + if (!get_option('xcloner_encryption_key')) |
|
60 | 60 | { |
61 | 61 | return $this->randomString(35); |
62 | 62 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | private function randomString($length = 6) { |
74 | 74 | $str = ""; |
75 | - $characters = array_merge(range('A','Z'), range('a','z'), range('0','9')); |
|
75 | + $characters = array_merge(range('A', 'Z'), range('a', 'z'), range('0', '9')); |
|
76 | 76 | $max = count($characters) - 1; |
77 | 77 | for ($i = 0; $i < $length; $i++) { |
78 | 78 | $rand = mt_rand(0, $max); |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * @param string $option |
215 | 215 | */ |
216 | - public function get_xcloner_option( $option ) { |
|
217 | - $data = get_option( $option ); |
|
216 | + public function get_xcloner_option($option) { |
|
217 | + $data = get_option($option); |
|
218 | 218 | |
219 | 219 | return $data; |
220 | 220 | } |
221 | 221 | |
222 | - public function get_server_unique_hash( $strlen = 0 ) { |
|
223 | - $hash = md5( get_home_url() . __DIR__ ); |
|
222 | + public function get_server_unique_hash($strlen = 0) { |
|
223 | + $hash = md5(get_home_url().__DIR__); |
|
224 | 224 | |
225 | - if ( $strlen ) { |
|
226 | - $hash = substr( $hash, 0, $strlen ); |
|
225 | + if ($strlen) { |
|
226 | + $hash = substr($hash, 0, $strlen); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | return $hash; |
@@ -287,287 +287,287 @@ discard block |
||
287 | 287 | //CRON section |
288 | 288 | add_settings_section( |
289 | 289 | 'xcloner_cron_settings_group', |
290 | - __( ' ' ), |
|
291 | - array( $this, 'xcloner_settings_section_cb' ), |
|
290 | + __(' '), |
|
291 | + array($this, 'xcloner_settings_section_cb'), |
|
292 | 292 | 'xcloner_cron_settings_page' |
293 | 293 | ); |
294 | 294 | |
295 | 295 | |
296 | 296 | //REGISTERING THE 'GENERAL SECTION' FIELDS |
297 | - register_setting( 'xcloner_general_settings_group', 'xcloner_backup_compression_level', array( |
|
297 | + register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array( |
|
298 | 298 | $this->xcloner_sanitization, |
299 | 299 | "sanitize_input_as_int" |
300 | - ) ); |
|
300 | + )); |
|
301 | 301 | add_settings_field( |
302 | 302 | 'xcloner_backup_compression_level', |
303 | - __( 'Backup Compression Level', 'xcloner-backup-and-restore' ), |
|
304 | - array( $this, 'do_form_range_field' ), |
|
303 | + __('Backup Compression Level', 'xcloner-backup-and-restore'), |
|
304 | + array($this, 'do_form_range_field'), |
|
305 | 305 | 'xcloner_settings_page', |
306 | 306 | 'xcloner_general_settings_group', |
307 | 307 | array( |
308 | 308 | 'xcloner_backup_compression_level', |
309 | - __( 'Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore' ), |
|
309 | + __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore'), |
|
310 | 310 | 0, |
311 | 311 | 9 |
312 | 312 | ) |
313 | 313 | ); |
314 | 314 | |
315 | - register_setting( 'xcloner_general_settings_group', 'xcloner_start_path', array( |
|
315 | + register_setting('xcloner_general_settings_group', 'xcloner_start_path', array( |
|
316 | 316 | $this->xcloner_sanitization, |
317 | 317 | "sanitize_input_as_absolute_path" |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | add_settings_field( |
320 | 320 | 'xcloner_start_path', |
321 | - __( 'Backup Start Location', 'xcloner-backup-and-restore' ), |
|
322 | - array( $this, 'do_form_text_field' ), |
|
321 | + __('Backup Start Location', 'xcloner-backup-and-restore'), |
|
322 | + array($this, 'do_form_text_field'), |
|
323 | 323 | 'xcloner_settings_page', |
324 | 324 | 'xcloner_general_settings_group', |
325 | 325 | array( |
326 | 326 | 'xcloner_start_path', |
327 | - __( 'Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore' ), |
|
327 | + __('Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore'), |
|
328 | 328 | $this->get_xcloner_start_path(), |
329 | 329 | //'disabled' |
330 | 330 | ) |
331 | 331 | ); |
332 | 332 | |
333 | - register_setting( 'xcloner_general_settings_group', 'xcloner_store_path', array( |
|
333 | + register_setting('xcloner_general_settings_group', 'xcloner_store_path', array( |
|
334 | 334 | $this->xcloner_sanitization, |
335 | 335 | "sanitize_input_as_absolute_path" |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | add_settings_field( |
338 | 338 | 'xcloner_store_path', |
339 | - __( 'Backup Storage Location', 'xcloner-backup-and-restore' ), |
|
340 | - array( $this, 'do_form_text_field' ), |
|
339 | + __('Backup Storage Location', 'xcloner-backup-and-restore'), |
|
340 | + array($this, 'do_form_text_field'), |
|
341 | 341 | 'xcloner_settings_page', |
342 | 342 | 'xcloner_general_settings_group', |
343 | 343 | array( |
344 | 344 | 'xcloner_store_path', |
345 | - __( 'Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore' ), |
|
345 | + __('Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore'), |
|
346 | 346 | $this->get_xcloner_store_path(), |
347 | 347 | //'disabled' |
348 | 348 | ) |
349 | 349 | ); |
350 | 350 | |
351 | - register_setting( 'xcloner_general_settings_group', 'xcloner_encryption_key', array( |
|
351 | + register_setting('xcloner_general_settings_group', 'xcloner_encryption_key', array( |
|
352 | 352 | $this->xcloner_sanitization, |
353 | 353 | "sanitize_input_as_string" |
354 | - ) ); |
|
354 | + )); |
|
355 | 355 | add_settings_field( |
356 | 356 | 'xcloner_encryption_key', |
357 | - __( 'Backup Encryption Key', 'xcloner-backup-and-restore' ), |
|
358 | - array( $this, 'do_form_text_field' ), |
|
357 | + __('Backup Encryption Key', 'xcloner-backup-and-restore'), |
|
358 | + array($this, 'do_form_text_field'), |
|
359 | 359 | 'xcloner_settings_page', |
360 | 360 | 'xcloner_general_settings_group', |
361 | 361 | array( |
362 | 362 | 'xcloner_encryption_key', |
363 | - __( 'Backup Encryption Key used to Encrypt/Decrypt backups, you might want to save this somewhere else as well.', 'xcloner-backup-and-restore' ), |
|
363 | + __('Backup Encryption Key used to Encrypt/Decrypt backups, you might want to save this somewhere else as well.', 'xcloner-backup-and-restore'), |
|
364 | 364 | $this->get_xcloner_encryption_key(), |
365 | 365 | //'disabled' |
366 | 366 | ) |
367 | 367 | ); |
368 | 368 | |
369 | - register_setting( 'xcloner_general_settings_group', 'xcloner_enable_log', array( |
|
369 | + register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array( |
|
370 | 370 | $this->xcloner_sanitization, |
371 | 371 | "sanitize_input_as_int" |
372 | - ) ); |
|
372 | + )); |
|
373 | 373 | add_settings_field( |
374 | 374 | 'xcloner_enable_log', |
375 | - __( 'Enable XCloner Backup Log', 'xcloner-backup-and-restore' ), |
|
376 | - array( $this, 'do_form_switch_field' ), |
|
375 | + __('Enable XCloner Backup Log', 'xcloner-backup-and-restore'), |
|
376 | + array($this, 'do_form_switch_field'), |
|
377 | 377 | 'xcloner_settings_page', |
378 | 378 | 'xcloner_general_settings_group', |
379 | 379 | array( |
380 | 380 | 'xcloner_enable_log', |
381 | - sprintf( __( 'Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s', 'xcloner-backup-and-restore' ), $this->get_logger_filename() ) |
|
381 | + sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s', 'xcloner-backup-and-restore'), $this->get_logger_filename()) |
|
382 | 382 | ) |
383 | 383 | ); |
384 | 384 | |
385 | - register_setting( 'xcloner_general_settings_group', 'xcloner_enable_pre_update_backup', array( |
|
385 | + register_setting('xcloner_general_settings_group', 'xcloner_enable_pre_update_backup', array( |
|
386 | 386 | $this->xcloner_sanitization, |
387 | 387 | "sanitize_input_as_int" |
388 | - ) ); |
|
388 | + )); |
|
389 | 389 | add_settings_field( |
390 | 390 | 'xcloner_enable_pre_update_backup', |
391 | - __( 'Generate Backups before Automatic WP Upgrades', 'xcloner-backup-and-restore' ), |
|
392 | - array( $this, 'do_form_switch_field' ), |
|
391 | + __('Generate Backups before Automatic WP Upgrades', 'xcloner-backup-and-restore'), |
|
392 | + array($this, 'do_form_switch_field'), |
|
393 | 393 | 'xcloner_settings_page', |
394 | 394 | 'xcloner_general_settings_group', |
395 | 395 | array( |
396 | 396 | 'xcloner_enable_pre_update_backup', |
397 | - sprintf( __( 'Attempt to generate a core, plugins, themes or languages files backup before the automatic update of Wordpress core, plugins, themes or languages files.', 'xcloner-backup-and-restore' ), $this->get_logger_filename() ) |
|
397 | + sprintf(__('Attempt to generate a core, plugins, themes or languages files backup before the automatic update of Wordpress core, plugins, themes or languages files.', 'xcloner-backup-and-restore'), $this->get_logger_filename()) |
|
398 | 398 | ) |
399 | 399 | ); |
400 | 400 | |
401 | - register_setting( 'xcloner_general_settings_group', 'xcloner_regex_exclude', array( |
|
401 | + register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array( |
|
402 | 402 | $this->xcloner_sanitization, |
403 | 403 | "sanitize_input_as_raw" |
404 | - ) ); |
|
404 | + )); |
|
405 | 405 | add_settings_field( |
406 | 406 | 'xcloner_regex_exclude', |
407 | - __( 'Regex Exclude Files', 'xcloner-backup-and-restore' ), |
|
408 | - array( $this, 'do_form_textarea_field' ), |
|
407 | + __('Regex Exclude Files', 'xcloner-backup-and-restore'), |
|
408 | + array($this, 'do_form_textarea_field'), |
|
409 | 409 | 'xcloner_settings_page', |
410 | 410 | 'xcloner_general_settings_group', |
411 | 411 | array( |
412 | 412 | 'xcloner_regex_exclude', |
413 | - __( 'Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore' ), |
|
413 | + __('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore'), |
|
414 | 414 | //$this->get_xcloner_store_path(), |
415 | 415 | //'disabled' |
416 | 416 | ) |
417 | 417 | ); |
418 | 418 | |
419 | 419 | //REGISTERING THE 'MYSQL SECTION' FIELDS |
420 | - register_setting( 'xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array( |
|
420 | + register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array( |
|
421 | 421 | $this->xcloner_sanitization, |
422 | 422 | "sanitize_input_as_int" |
423 | - ) ); |
|
423 | + )); |
|
424 | 424 | add_settings_field( |
425 | 425 | 'xcloner_enable_mysql_backup', |
426 | - __( 'Enable Mysql Backup', 'xcloner-backup-and-restore' ), |
|
427 | - array( $this, 'do_form_switch_field' ), |
|
426 | + __('Enable Mysql Backup', 'xcloner-backup-and-restore'), |
|
427 | + array($this, 'do_form_switch_field'), |
|
428 | 428 | 'xcloner_mysql_settings_page', |
429 | 429 | 'xcloner_mysql_settings_group', |
430 | 430 | array( |
431 | 431 | 'xcloner_enable_mysql_backup', |
432 | - __( 'Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore' ) |
|
432 | + __('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore') |
|
433 | 433 | ) |
434 | 434 | ); |
435 | 435 | |
436 | - register_setting( 'xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables' ); |
|
436 | + register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables'); |
|
437 | 437 | add_settings_field( |
438 | 438 | 'xcloner_backup_only_wp_tables', |
439 | - __( 'Backup only WP tables', 'xcloner-backup-and-restore' ), |
|
440 | - array( $this, 'do_form_switch_field' ), |
|
439 | + __('Backup only WP tables', 'xcloner-backup-and-restore'), |
|
440 | + array($this, 'do_form_switch_field'), |
|
441 | 441 | 'xcloner_mysql_settings_page', |
442 | 442 | 'xcloner_mysql_settings_group', |
443 | 443 | array( |
444 | 444 | 'xcloner_backup_only_wp_tables', |
445 | - sprintf( __( 'Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore' ), $this->get_table_prefix() ) |
|
445 | + sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
446 | 446 | ) |
447 | 447 | ); |
448 | 448 | |
449 | - register_setting( 'xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array( |
|
449 | + register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array( |
|
450 | 450 | $this->xcloner_sanitization, |
451 | 451 | "sanitize_input_as_raw" |
452 | - ) ); |
|
452 | + )); |
|
453 | 453 | add_settings_field( |
454 | 454 | 'xcloner_mysql_hostname', |
455 | - __( 'Mysql Hostname', 'xcloner-backup-and-restore' ), |
|
456 | - array( $this, 'do_form_text_field' ), |
|
455 | + __('Mysql Hostname', 'xcloner-backup-and-restore'), |
|
456 | + array($this, 'do_form_text_field'), |
|
457 | 457 | 'xcloner_mysql_settings_page', |
458 | 458 | 'xcloner_mysql_settings_group', |
459 | 459 | array( |
460 | 460 | 'xcloner_mysql_hostname', |
461 | - __( 'Wordpress mysql hostname', 'xcloner-backup-and-restore' ), |
|
461 | + __('Wordpress mysql hostname', 'xcloner-backup-and-restore'), |
|
462 | 462 | $this->get_db_hostname(), |
463 | 463 | 'disabled' |
464 | 464 | ) |
465 | 465 | ); |
466 | 466 | |
467 | - register_setting( 'xcloner_mysql_settings_group', 'xcloner_mysql_username', array( |
|
467 | + register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array( |
|
468 | 468 | $this->xcloner_sanitization, |
469 | 469 | "sanitize_input_as_raw" |
470 | - ) ); |
|
470 | + )); |
|
471 | 471 | add_settings_field( |
472 | 472 | 'xcloner_mysql_username', |
473 | - __( 'Mysql Username', 'xcloner-backup-and-restore' ), |
|
474 | - array( $this, 'do_form_text_field' ), |
|
473 | + __('Mysql Username', 'xcloner-backup-and-restore'), |
|
474 | + array($this, 'do_form_text_field'), |
|
475 | 475 | 'xcloner_mysql_settings_page', |
476 | 476 | 'xcloner_mysql_settings_group', |
477 | 477 | array( |
478 | 478 | 'xcloner_mysql_username', |
479 | - __( 'Wordpress mysql username', 'xcloner-backup-and-restore' ), |
|
479 | + __('Wordpress mysql username', 'xcloner-backup-and-restore'), |
|
480 | 480 | $this->get_db_username(), |
481 | 481 | 'disabled' |
482 | 482 | ) |
483 | 483 | ); |
484 | 484 | |
485 | - register_setting( 'xcloner_mysql_settings_group', 'xcloner_mysql_database', array( |
|
485 | + register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array( |
|
486 | 486 | $this->xcloner_sanitization, |
487 | 487 | "sanitize_input_as_raw" |
488 | - ) ); |
|
488 | + )); |
|
489 | 489 | add_settings_field( |
490 | 490 | 'xcloner_mysql_database', |
491 | - __( 'Mysql Database', 'xcloner-backup-and-restore' ), |
|
492 | - array( $this, 'do_form_text_field' ), |
|
491 | + __('Mysql Database', 'xcloner-backup-and-restore'), |
|
492 | + array($this, 'do_form_text_field'), |
|
493 | 493 | 'xcloner_mysql_settings_page', |
494 | 494 | 'xcloner_mysql_settings_group', |
495 | 495 | array( |
496 | 496 | 'xcloner_mysql_database', |
497 | - __( 'Wordpress mysql database', 'xcloner-backup-and-restore' ), |
|
497 | + __('Wordpress mysql database', 'xcloner-backup-and-restore'), |
|
498 | 498 | $this->get_db_database(), |
499 | 499 | 'disabled' |
500 | 500 | ) |
501 | 501 | ); |
502 | 502 | |
503 | 503 | //REGISTERING THE 'SYSTEM SECTION' FIELDS |
504 | - register_setting( 'xcloner_system_settings_group', 'xcloner_size_limit_per_request', array( |
|
504 | + register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array( |
|
505 | 505 | $this->xcloner_sanitization, |
506 | 506 | "sanitize_input_as_int" |
507 | - ) ); |
|
507 | + )); |
|
508 | 508 | add_settings_field( |
509 | 509 | 'xcloner_size_limit_per_request', |
510 | - __( 'Data Size Limit Per Request', 'xcloner-backup-and-restore' ), |
|
511 | - array( $this, 'do_form_range_field' ), |
|
510 | + __('Data Size Limit Per Request', 'xcloner-backup-and-restore'), |
|
511 | + array($this, 'do_form_range_field'), |
|
512 | 512 | 'xcloner_system_settings_page', |
513 | 513 | 'xcloner_system_settings_group', |
514 | 514 | array( |
515 | 515 | 'xcloner_size_limit_per_request', |
516 | - __( 'Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore' ), |
|
516 | + __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore'), |
|
517 | 517 | 0, |
518 | 518 | 1024 |
519 | 519 | ) |
520 | 520 | ); |
521 | 521 | |
522 | - register_setting( 'xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array( |
|
522 | + register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array( |
|
523 | 523 | $this->xcloner_sanitization, |
524 | 524 | "sanitize_input_as_int" |
525 | - ) ); |
|
525 | + )); |
|
526 | 526 | add_settings_field( |
527 | 527 | 'xcloner_files_to_process_per_request', |
528 | - __( 'Files To Process Per Request', 'xcloner-backup-and-restore' ), |
|
529 | - array( $this, 'do_form_range_field' ), |
|
528 | + __('Files To Process Per Request', 'xcloner-backup-and-restore'), |
|
529 | + array($this, 'do_form_range_field'), |
|
530 | 530 | 'xcloner_system_settings_page', |
531 | 531 | 'xcloner_system_settings_group', |
532 | 532 | array( |
533 | 533 | 'xcloner_files_to_process_per_request', |
534 | - __( 'Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore' ), |
|
534 | + __('Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore'), |
|
535 | 535 | 0, |
536 | 536 | 1000 |
537 | 537 | ) |
538 | 538 | ); |
539 | 539 | |
540 | - register_setting( 'xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array( |
|
540 | + register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array( |
|
541 | 541 | $this->xcloner_sanitization, |
542 | 542 | "sanitize_input_as_int" |
543 | - ) ); |
|
543 | + )); |
|
544 | 544 | add_settings_field( |
545 | 545 | 'xcloner_directories_to_scan_per_request', |
546 | - __( 'Directories To Scan Per Request', 'xcloner-backup-and-restore' ), |
|
547 | - array( $this, 'do_form_range_field' ), |
|
546 | + __('Directories To Scan Per Request', 'xcloner-backup-and-restore'), |
|
547 | + array($this, 'do_form_range_field'), |
|
548 | 548 | 'xcloner_system_settings_page', |
549 | 549 | 'xcloner_system_settings_group', |
550 | 550 | array( |
551 | 551 | 'xcloner_directories_to_scan_per_request', |
552 | - __( 'Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore' ), |
|
552 | + __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore'), |
|
553 | 553 | 0, |
554 | 554 | 1000 |
555 | 555 | ) |
556 | 556 | ); |
557 | 557 | |
558 | - register_setting( 'xcloner_system_settings_group', 'xcloner_database_records_per_request', array( |
|
558 | + register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array( |
|
559 | 559 | $this->xcloner_sanitization, |
560 | 560 | "sanitize_input_as_int" |
561 | - ) ); |
|
561 | + )); |
|
562 | 562 | add_settings_field( |
563 | 563 | 'xcloner_database_records_per_request', |
564 | - __( 'Database Records Per Request', 'xcloner-backup-and-restore' ), |
|
565 | - array( $this, 'do_form_range_field' ), |
|
564 | + __('Database Records Per Request', 'xcloner-backup-and-restore'), |
|
565 | + array($this, 'do_form_range_field'), |
|
566 | 566 | 'xcloner_system_settings_page', |
567 | 567 | 'xcloner_system_settings_group', |
568 | 568 | array( |
569 | 569 | 'xcloner_database_records_per_request', |
570 | - __( 'Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all. Range 0-100000 records', 'xcloner-backup-and-restore' ), |
|
570 | + __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all. Range 0-100000 records', 'xcloner-backup-and-restore'), |
|
571 | 571 | 0, |
572 | 572 | 100000 |
573 | 573 | ) |
@@ -585,140 +585,140 @@ discard block |
||
585 | 585 | ) |
586 | 586 | );*/ |
587 | 587 | |
588 | - register_setting( 'xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array( |
|
588 | + register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array( |
|
589 | 589 | $this->xcloner_sanitization, |
590 | 590 | "sanitize_input_as_int" |
591 | - ) ); |
|
591 | + )); |
|
592 | 592 | add_settings_field( |
593 | 593 | 'xcloner_exclude_files_larger_than_mb', |
594 | - __( 'Exclude files larger than (MB)', 'xcloner-backup-and-restore' ), |
|
595 | - array( $this, 'do_form_number_field' ), |
|
594 | + __('Exclude files larger than (MB)', 'xcloner-backup-and-restore'), |
|
595 | + array($this, 'do_form_number_field'), |
|
596 | 596 | 'xcloner_system_settings_page', |
597 | 597 | 'xcloner_system_settings_group', |
598 | 598 | array( |
599 | 599 | 'xcloner_exclude_files_larger_than_mb', |
600 | - __( 'Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore' ), |
|
600 | + __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore'), |
|
601 | 601 | ) |
602 | 602 | ); |
603 | 603 | |
604 | - register_setting( 'xcloner_system_settings_group', 'xcloner_split_backup_limit', array( |
|
604 | + register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array( |
|
605 | 605 | $this->xcloner_sanitization, |
606 | 606 | "sanitize_input_as_int" |
607 | - ) ); |
|
607 | + )); |
|
608 | 608 | add_settings_field( |
609 | 609 | 'xcloner_split_backup_limit', |
610 | - __( 'Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore' ), |
|
611 | - array( $this, 'do_form_number_field' ), |
|
610 | + __('Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore'), |
|
611 | + array($this, 'do_form_number_field'), |
|
612 | 612 | 'xcloner_system_settings_page', |
613 | 613 | 'xcloner_system_settings_group', |
614 | 614 | array( |
615 | 615 | 'xcloner_split_backup_limit', |
616 | - __( 'Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB', 'xcloner-backup-and-restore' ), |
|
616 | + __('Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB', 'xcloner-backup-and-restore'), |
|
617 | 617 | ) |
618 | 618 | ); |
619 | 619 | |
620 | - register_setting( 'xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root' ); |
|
620 | + register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root'); |
|
621 | 621 | add_settings_field( |
622 | 622 | 'xcloner_force_tmp_path_site_root', |
623 | - __( 'Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore' ), |
|
624 | - array( $this, 'do_form_switch_field' ), |
|
623 | + __('Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore'), |
|
624 | + array($this, 'do_form_switch_field'), |
|
625 | 625 | 'xcloner_system_settings_page', |
626 | 626 | 'xcloner_system_settings_group', |
627 | 627 | array( |
628 | 628 | 'xcloner_force_tmp_path_site_root', |
629 | - sprintf( __( 'Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location', 'xcloner-backup-and-restore' ), $this->get_table_prefix() ) |
|
629 | + sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location', 'xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
630 | 630 | ) |
631 | 631 | ); |
632 | 632 | |
633 | - register_setting( 'xcloner_system_settings_group', 'xcloner_disable_email_notification' ); |
|
633 | + register_setting('xcloner_system_settings_group', 'xcloner_disable_email_notification'); |
|
634 | 634 | add_settings_field( |
635 | 635 | 'xcloner_disable_email_notification', |
636 | - __( 'Disable Email Notifications', 'xcloner-backup-and-restore' ), |
|
637 | - array( $this, 'do_form_switch_field' ), |
|
636 | + __('Disable Email Notifications', 'xcloner-backup-and-restore'), |
|
637 | + array($this, 'do_form_switch_field'), |
|
638 | 638 | 'xcloner_system_settings_page', |
639 | 639 | 'xcloner_system_settings_group', |
640 | 640 | array( |
641 | 641 | 'xcloner_disable_email_notification', |
642 | - sprintf( __( 'Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore' ), $this->get_table_prefix() ) |
|
642 | + sprintf(__('Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
643 | 643 | ) |
644 | 644 | ); |
645 | 645 | |
646 | 646 | //REGISTERING THE 'CLEANUP SECTION' FIELDS |
647 | - register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array( |
|
647 | + register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array( |
|
648 | 648 | $this->xcloner_sanitization, |
649 | 649 | "sanitize_input_as_int" |
650 | - ) ); |
|
650 | + )); |
|
651 | 651 | add_settings_field( |
652 | 652 | 'xcloner_cleanup_retention_limit_days', |
653 | - __( 'Cleanup by Date(days)', 'xcloner-backup-and-restore' ), |
|
654 | - array( $this, 'do_form_number_field' ), |
|
653 | + __('Cleanup by Date(days)', 'xcloner-backup-and-restore'), |
|
654 | + array($this, 'do_form_number_field'), |
|
655 | 655 | 'xcloner_cleanup_settings_page', |
656 | 656 | 'xcloner_cleanup_settings_group', |
657 | 657 | array( |
658 | 658 | 'xcloner_cleanup_retention_limit_days', |
659 | - __( 'Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore' ) |
|
659 | + __('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore') |
|
660 | 660 | ) |
661 | 661 | ); |
662 | 662 | |
663 | - register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array( |
|
663 | + register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array( |
|
664 | 664 | $this->xcloner_sanitization, |
665 | 665 | "sanitize_input_as_int" |
666 | - ) ); |
|
666 | + )); |
|
667 | 667 | add_settings_field( |
668 | 668 | 'xcloner_cleanup_retention_limit_archives', |
669 | - __( 'Cleanup by Quantity', 'xcloner-backup-and-restore' ), |
|
670 | - array( $this, 'do_form_number_field' ), |
|
669 | + __('Cleanup by Quantity', 'xcloner-backup-and-restore'), |
|
670 | + array($this, 'do_form_number_field'), |
|
671 | 671 | 'xcloner_cleanup_settings_page', |
672 | 672 | 'xcloner_cleanup_settings_group', |
673 | 673 | array( |
674 | 674 | 'xcloner_cleanup_retention_limit_archives', |
675 | - __( 'Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore' ) |
|
675 | + __('Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore') |
|
676 | 676 | ) |
677 | 677 | ); |
678 | 678 | |
679 | - register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array( |
|
679 | + register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array( |
|
680 | 680 | $this->xcloner_sanitization, |
681 | 681 | "sanitize_input_as_int" |
682 | - ) ); |
|
682 | + )); |
|
683 | 683 | add_settings_field( |
684 | 684 | 'xcloner_cleanup_capacity_limit', |
685 | - __( 'Cleanup by Capacity(MB)', 'xcloner-backup-and-restore' ), |
|
686 | - array( $this, 'do_form_number_field' ), |
|
685 | + __('Cleanup by Capacity(MB)', 'xcloner-backup-and-restore'), |
|
686 | + array($this, 'do_form_number_field'), |
|
687 | 687 | 'xcloner_cleanup_settings_page', |
688 | 688 | 'xcloner_cleanup_settings_group', |
689 | 689 | array( |
690 | 690 | 'xcloner_cleanup_capacity_limit', |
691 | - __( 'Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore' ) |
|
691 | + __('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore') |
|
692 | 692 | ) |
693 | 693 | ); |
694 | 694 | |
695 | - register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_delete_after_remote_transfer', array( |
|
695 | + register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_delete_after_remote_transfer', array( |
|
696 | 696 | $this->xcloner_sanitization, |
697 | 697 | "sanitize_input_as_int" |
698 | - ) ); |
|
698 | + )); |
|
699 | 699 | add_settings_field( |
700 | 700 | 'xcloner_cleanup_delete_after_remote_transfer', |
701 | - __( 'Delete Backup After Remote Storage Transfer', 'xcloner-backup-and-restore' ), |
|
702 | - array( $this, 'do_form_switch_field' ), |
|
701 | + __('Delete Backup After Remote Storage Transfer', 'xcloner-backup-and-restore'), |
|
702 | + array($this, 'do_form_switch_field'), |
|
703 | 703 | 'xcloner_cleanup_settings_page', |
704 | 704 | 'xcloner_cleanup_settings_group', |
705 | 705 | array( |
706 | 706 | 'xcloner_cleanup_delete_after_remote_transfer', |
707 | - __( 'Remove backup created automatically from local storage after sending the backup to Remote Storage', 'xcloner-backup-and-restore' ) |
|
707 | + __('Remove backup created automatically from local storage after sending the backup to Remote Storage', 'xcloner-backup-and-restore') |
|
708 | 708 | ) |
709 | 709 | ); |
710 | 710 | |
711 | 711 | //REGISTERING THE 'CRON SECTION' FIELDS |
712 | - register_setting( 'xcloner_cron_settings_group', 'xcloner_cron_frequency' ); |
|
712 | + register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency'); |
|
713 | 713 | add_settings_field( |
714 | 714 | 'xcloner_cron_frequency', |
715 | - __( 'Cron frequency', 'xcloner-backup-and-restore' ), |
|
716 | - array( $this, 'do_form_text_field' ), |
|
715 | + __('Cron frequency', 'xcloner-backup-and-restore'), |
|
716 | + array($this, 'do_form_text_field'), |
|
717 | 717 | 'xcloner_cron_settings_page', |
718 | 718 | 'xcloner_cron_settings_group', |
719 | 719 | array( |
720 | 720 | 'xcloner_cron_frequency', |
721 | - __( 'Cron frequency' ) |
|
721 | + __('Cron frequency') |
|
722 | 722 | ) |
723 | 723 | ); |
724 | 724 | } |
@@ -162,26 +162,26 @@ discard block |
||
162 | 162 | private $logger; |
163 | 163 | private $xcloner; |
164 | 164 | |
165 | - public function __construct( Xcloner $xcloner_container ) { |
|
165 | + public function __construct(Xcloner $xcloner_container) { |
|
166 | 166 | $this->xcloner_sanitization = $xcloner_container->get_xcloner_sanitization(); |
167 | 167 | $this->xcloner_file_system = $xcloner_container->get_xcloner_filesystem(); |
168 | - $this->logger = $xcloner_container->get_xcloner_logger()->withName( "xcloner_remote_storage" ); |
|
168 | + $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_remote_storage"); |
|
169 | 169 | $this->xcloner = $xcloner_container; |
170 | 170 | |
171 | - foreach($this->storage_fields as $main_key=>$array){ |
|
171 | + foreach ($this->storage_fields as $main_key=>$array) { |
|
172 | 172 | |
173 | - if(is_array($array)) { |
|
173 | + if (is_array($array)) { |
|
174 | 174 | foreach ($array as $key => $type) { |
175 | 175 | |
176 | - if( $type == "raw") { |
|
177 | - add_filter("pre_update_option_" . $this->storage_fields['option_prefix'] . $key, |
|
178 | - function ($value) { |
|
176 | + if ($type == "raw") { |
|
177 | + add_filter("pre_update_option_".$this->storage_fields['option_prefix'].$key, |
|
178 | + function($value) { |
|
179 | 179 | |
180 | 180 | return $this->simple_crypt($value, 'e'); |
181 | 181 | |
182 | 182 | }, 10, 1); |
183 | 183 | |
184 | - add_filter("option_" . $this->storage_fields['option_prefix'] . $key, function ($value) { |
|
184 | + add_filter("option_".$this->storage_fields['option_prefix'].$key, function($value) { |
|
185 | 185 | |
186 | 186 | return $this->simple_crypt($value, 'd'); |
187 | 187 | |
@@ -201,22 +201,22 @@ discard block |
||
201 | 201 | * @param string $action |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - private function simple_crypt( $string, $action = 'e' ) { |
|
204 | + private function simple_crypt($string, $action = 'e') { |
|
205 | 205 | // you may change these values to your own |
206 | 206 | $secret_key = NONCE_KEY; |
207 | 207 | $secret_iv = NONCE_SALT; |
208 | 208 | |
209 | 209 | $output = $string; |
210 | 210 | $encrypt_method = "AES-256-CBC"; |
211 | - $key = hash( 'sha256', $secret_key ); |
|
212 | - $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 ); |
|
211 | + $key = hash('sha256', $secret_key); |
|
212 | + $iv = substr(hash('sha256', $secret_iv), 0, 16); |
|
213 | 213 | |
214 | - if( $action == 'e' && function_exists('openssl_encrypt')) { |
|
215 | - $output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) ); |
|
214 | + if ($action == 'e' && function_exists('openssl_encrypt')) { |
|
215 | + $output = base64_encode(openssl_encrypt($string, $encrypt_method, $key, 0, $iv)); |
|
216 | 216 | } |
217 | - else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){ |
|
218 | - $decrypt = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv ); |
|
219 | - if($decrypt) { |
|
217 | + else if ($action == 'd' && function_exists('openssl_decrypt') && base64_decode($string)) { |
|
218 | + $decrypt = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); |
|
219 | + if ($decrypt) { |
|
220 | 220 | //we check if decrypt was succesful |
221 | 221 | $output = $decrypt; |
222 | 222 | } |
@@ -231,121 +231,121 @@ discard block |
||
231 | 231 | |
232 | 232 | public function get_available_storages() { |
233 | 233 | $return = array(); |
234 | - foreach ( $this->storage_fields as $storage => $data ) { |
|
235 | - $check_field = $this->storage_fields["option_prefix"] . $storage . "_enable"; |
|
236 | - if ( get_option( $check_field ) ) { |
|
237 | - $return[ $storage ] = $data['text']; |
|
234 | + foreach ($this->storage_fields as $storage => $data) { |
|
235 | + $check_field = $this->storage_fields["option_prefix"].$storage."_enable"; |
|
236 | + if (get_option($check_field)) { |
|
237 | + $return[$storage] = $data['text']; |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | 241 | return $return; |
242 | 242 | } |
243 | 243 | |
244 | - public function save( $action = "ftp" ) { |
|
245 | - if ( ! $action ) { |
|
244 | + public function save($action = "ftp") { |
|
245 | + if (!$action) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | |
249 | - $storage = $this->xcloner_sanitization->sanitize_input_as_string( $action ); |
|
250 | - $this->logger->debug( sprintf( "Saving the remote storage %s options", strtoupper( $action ) ) ); |
|
249 | + $storage = $this->xcloner_sanitization->sanitize_input_as_string($action); |
|
250 | + $this->logger->debug(sprintf("Saving the remote storage %s options", strtoupper($action))); |
|
251 | 251 | |
252 | - if ( is_array( $this->storage_fields[ $storage ] ) ) { |
|
253 | - foreach ( $this->storage_fields[ $storage ] as $field => $validation ) { |
|
254 | - $check_field = $this->storage_fields["option_prefix"] . $field; |
|
255 | - $sanitize_method = "sanitize_input_as_" . $validation; |
|
252 | + if (is_array($this->storage_fields[$storage])) { |
|
253 | + foreach ($this->storage_fields[$storage] as $field => $validation) { |
|
254 | + $check_field = $this->storage_fields["option_prefix"].$field; |
|
255 | + $sanitize_method = "sanitize_input_as_".$validation; |
|
256 | 256 | |
257 | - if ( ! isset( $_POST[ $check_field ] ) ) { |
|
258 | - $_POST[ $check_field ] = 0; |
|
257 | + if (!isset($_POST[$check_field])) { |
|
258 | + $_POST[$check_field] = 0; |
|
259 | 259 | } |
260 | 260 | |
261 | - if ( ! method_exists( $this->xcloner_sanitization, $sanitize_method ) ) { |
|
261 | + if (!method_exists($this->xcloner_sanitization, $sanitize_method)) { |
|
262 | 262 | $sanitize_method = "sanitize_input_as_string"; |
263 | 263 | } |
264 | 264 | |
265 | - $sanitized_value = $this->xcloner_sanitization->$sanitize_method( stripslashes( $_POST[ $check_field ] ) ); |
|
266 | - update_option( $check_field, $sanitized_value ); |
|
265 | + $sanitized_value = $this->xcloner_sanitization->$sanitize_method(stripslashes($_POST[$check_field])); |
|
266 | + update_option($check_field, $sanitized_value); |
|
267 | 267 | } |
268 | 268 | |
269 | - $this->xcloner->trigger_message( __( "%s storage settings saved.", 'xcloner-backup-and-restore' ), "success", $this->storage_fields[ $action ]['text'] ); |
|
269 | + $this->xcloner->trigger_message(__("%s storage settings saved.", 'xcloner-backup-and-restore'), "success", $this->storage_fields[$action]['text']); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - public function check( $action = "ftp" ) { |
|
274 | + public function check($action = "ftp") { |
|
275 | 275 | try { |
276 | - $this->verify_filesystem( $action ); |
|
277 | - $this->xcloner->trigger_message( __( "%s connection is valid.", 'xcloner-backup-and-restore' ), "success", $this->storage_fields[ $action ]['text'] ); |
|
278 | - $this->logger->debug( sprintf( "Connection to remote storage %s is valid", strtoupper( $action ) ) ); |
|
279 | - } catch ( Exception $e ) { |
|
280 | - $this->xcloner->trigger_message( "%s connection error: " . $e->getMessage(), "error", $this->storage_fields[ $action ]['text'] ); |
|
276 | + $this->verify_filesystem($action); |
|
277 | + $this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", $this->storage_fields[$action]['text']); |
|
278 | + $this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action))); |
|
279 | + }catch (Exception $e) { |
|
280 | + $this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", $this->storage_fields[$action]['text']); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | 285 | * @param string $storage_type |
286 | 286 | */ |
287 | - public function verify_filesystem( $storage_type ) { |
|
288 | - $method = "get_" . $storage_type . "_filesystem"; |
|
287 | + public function verify_filesystem($storage_type) { |
|
288 | + $method = "get_".$storage_type."_filesystem"; |
|
289 | 289 | |
290 | - $this->logger->info( sprintf( "Checking validity of the remote storage %s filesystem", strtoupper( $storage_type ) ) ); |
|
290 | + $this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", strtoupper($storage_type))); |
|
291 | 291 | |
292 | - if ( ! method_exists( $this, $method ) ) { |
|
292 | + if (!method_exists($this, $method)) { |
|
293 | 293 | return false; |
294 | 294 | } |
295 | 295 | |
296 | - list( $adapter, $filesystem ) = $this->$method(); |
|
296 | + list($adapter, $filesystem) = $this->$method(); |
|
297 | 297 | |
298 | - $test_file = substr( ".xcloner_" . md5( time() ), 0, 15 ); |
|
298 | + $test_file = substr(".xcloner_".md5(time()), 0, 15); |
|
299 | 299 | |
300 | - if ( $storage_type == "gdrive" ) { |
|
301 | - if ( ! is_array( $filesystem->listContents() ) ) { |
|
302 | - throw new Exception( __( "Could not read data", 'xcloner-backup-and-restore' ) ); |
|
300 | + if ($storage_type == "gdrive") { |
|
301 | + if (!is_array($filesystem->listContents())) { |
|
302 | + throw new Exception(__("Could not read data", 'xcloner-backup-and-restore')); |
|
303 | 303 | } |
304 | - $this->logger->debug( sprintf( "I can list data from remote storage %s", strtoupper( $storage_type ) ) ); |
|
304 | + $this->logger->debug(sprintf("I can list data from remote storage %s", strtoupper($storage_type))); |
|
305 | 305 | |
306 | 306 | return true; |
307 | 307 | } |
308 | 308 | |
309 | 309 | //testing write access |
310 | - if ( ! $filesystem->write( $test_file, "data" ) ) { |
|
311 | - throw new Exception( __( "Could not write data", 'xcloner-backup-and-restore' ) ); |
|
310 | + if (!$filesystem->write($test_file, "data")) { |
|
311 | + throw new Exception(__("Could not write data", 'xcloner-backup-and-restore')); |
|
312 | 312 | } |
313 | - $this->logger->debug( sprintf( "I can write data to remote storage %s", strtoupper( $storage_type ) ) ); |
|
313 | + $this->logger->debug(sprintf("I can write data to remote storage %s", strtoupper($storage_type))); |
|
314 | 314 | |
315 | 315 | //testing read access |
316 | - if ( ! $filesystem->has( $test_file ) ) { |
|
317 | - throw new Exception( __( "Could not read data", 'xcloner-backup-and-restore' ) ); |
|
316 | + if (!$filesystem->has($test_file)) { |
|
317 | + throw new Exception(__("Could not read data", 'xcloner-backup-and-restore')); |
|
318 | 318 | } |
319 | - $this->logger->debug( sprintf( "I can read data to remote storage %s", strtoupper( $storage_type ) ) ); |
|
319 | + $this->logger->debug(sprintf("I can read data to remote storage %s", strtoupper($storage_type))); |
|
320 | 320 | |
321 | 321 | //delete test file |
322 | - if ( ! $filesystem->delete( $test_file ) ) { |
|
323 | - throw new Exception( __( "Could not delete data", 'xcloner-backup-and-restore' ) ); |
|
322 | + if (!$filesystem->delete($test_file)) { |
|
323 | + throw new Exception(__("Could not delete data", 'xcloner-backup-and-restore')); |
|
324 | 324 | } |
325 | - $this->logger->debug( sprintf( "I can delete data to remote storage %s", strtoupper( $storage_type ) ) ); |
|
325 | + $this->logger->debug(sprintf("I can delete data to remote storage %s", strtoupper($storage_type))); |
|
326 | 326 | |
327 | 327 | return true; |
328 | 328 | } |
329 | 329 | |
330 | - public function upload_backup_to_storage( $file, $storage ) { |
|
331 | - if ( ! $this->xcloner_file_system->get_storage_filesystem()->has( $file ) ) { |
|
332 | - $this->logger->info( sprintf( "File not found %s in local storage", $file ) ); |
|
330 | + public function upload_backup_to_storage($file, $storage) { |
|
331 | + if (!$this->xcloner_file_system->get_storage_filesystem()->has($file)) { |
|
332 | + $this->logger->info(sprintf("File not found %s in local storage", $file)); |
|
333 | 333 | |
334 | 334 | return false; |
335 | 335 | } |
336 | 336 | |
337 | - $method = "get_" . $storage . "_filesystem"; |
|
337 | + $method = "get_".$storage."_filesystem"; |
|
338 | 338 | |
339 | - if ( ! method_exists( $this, $method ) ) { |
|
339 | + if (!method_exists($this, $method)) { |
|
340 | 340 | return false; |
341 | 341 | } |
342 | 342 | |
343 | - list( $remote_storage_adapter, $remote_storage_filesystem ) = $this->$method(); |
|
343 | + list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method(); |
|
344 | 344 | |
345 | 345 | //doing remote storage cleaning here |
346 | - $this->clean_remote_storage( $storage, $remote_storage_filesystem ); |
|
346 | + $this->clean_remote_storage($storage, $remote_storage_filesystem); |
|
347 | 347 | |
348 | - $this->logger->info( sprintf( "Transferring backup %s to remote storage %s", $file, strtoupper( $storage ) ), array( "" ) ); |
|
348 | + $this->logger->info(sprintf("Transferring backup %s to remote storage %s", $file, strtoupper($storage)), array("")); |
|
349 | 349 | |
350 | 350 | /*if(!$this->xcloner_file_system->get_storage_filesystem()->has($file)) |
351 | 351 | { |