@@ -31,10 +31,13 @@ |
||
31 | 31 | <?php if ($storage_selection): ?> |
32 | 32 | <option value="" |
33 | 33 | selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option> |
34 | - <?php else: ?> |
|
34 | + <?php else { |
|
35 | + : ?> |
|
35 | 36 | <option value="" |
36 | 37 | selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option> |
37 | - <?php endif; ?> |
|
38 | + <?php endif; |
|
39 | +} |
|
40 | +?> |
|
38 | 41 | |
39 | 42 | <?php foreach ($available_storages as $storage => $text): ?> |
40 | 43 | <option value="<?php echo $storage ?>"<?php if ($storage == $storage_selection) |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | <label> |
27 | 27 | Off |
28 | 28 | <input type="checkbox" name="xcloner_ftp_enable" class="status" |
29 | - value="1" <?php if (get_option("xcloner_ftp_enable")) |
|
29 | + value="1" <?php if (get_option("xcloner_ftp_enable")) { |
|
30 | 30 | echo "checked" ?> \> |
31 | 31 | <span class="lever"></span> |
32 | 32 | On |
@@ -340,6 +340,7 @@ discard block |
||
340 | 340 | value=""><?php echo __("Please Select AWS S3 Region or Leave Unselected for Custom Endpoint") ?></option> |
341 | 341 | <?php |
342 | 342 | $aws_regions = $remote_storage->get_aws_regions(); |
343 | +} |
|
343 | 344 | |
344 | 345 | foreach ($aws_regions as $key => $region) { |
345 | 346 | ?> |
@@ -423,7 +424,7 @@ discard block |
||
423 | 424 | <label> |
424 | 425 | Off |
425 | 426 | <input type="checkbox" name="xcloner_dropbox_enable" class="status" |
426 | - value="1" <?php if (get_option("xcloner_dropbox_enable")) |
|
427 | + value="1" <?php if (get_option("xcloner_dropbox_enable")) { |
|
427 | 428 | echo "checked" ?> \> |
428 | 429 | <span class="lever"></span> |
429 | 430 | On |
@@ -957,6 +958,7 @@ discard block |
||
957 | 958 | <div class="center"> |
958 | 959 | <?php |
959 | 960 | $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=xcloner-google-drive'), 'install-plugin_xcloner-google-drive'); |
961 | +} |
|
960 | 962 | ?> |
961 | 963 | <h6><?php echo __("This storage option requires the XCloner-Google-Drive Wordpress Plugin to be installed and activated.") ?></h6> |
962 | 964 | <h6><?php echo __("PHP 5.5 minimum version is required.") ?></h6> |
@@ -110,7 +110,8 @@ discard block |
||
110 | 110 | echo date($date_format." ".$time_format, $latest_backup['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
111 | 111 | ?> |
112 | 112 | </div> |
113 | - <?php else: ?> |
|
113 | + <?php else { |
|
114 | + : ?> |
|
114 | 115 | <div class="item"> |
115 | 116 | <div class="title"><?php echo __("No Backup Yet", 'xcloner-backup-and-restore') ?></div> |
116 | 117 | </div> |
@@ -123,7 +124,9 @@ discard block |
||
123 | 124 | <div class="title"><?php echo __("Total Size", 'xcloner-backup-and-restore') ?> |
124 | 125 | : |
125 | 126 | </div> |
126 | - <?php echo size_format($xcloner_file_system->get_storage_usage()); ?> |
|
127 | + <?php echo size_format($xcloner_file_system->get_storage_usage()); |
|
128 | +} |
|
129 | +?> |
|
127 | 130 | </div> |
128 | 131 | </blockquote> |
129 | 132 | <h5><?php echo __("Next Scheduled Backup", 'xcloner-backup-and-restore') ?></h5> |
@@ -54,7 +54,7 @@ |
||
54 | 54 | if (is_a($xcloner_plugin, 'Xcloner')) { |
55 | 55 | try { |
56 | 56 | $xcloner_plugin->get_xcloner_filesystem()->cleanup_tmp_directories(); |
57 | - }catch (Exception $e) { |
|
57 | + } catch (Exception $e) { |
|
58 | 58 | $xcloner_plugin->trigger_message_notice($e->getMessage()); |
59 | 59 | } |
60 | 60 |
@@ -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>'; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | |
378 | 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 | } |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | |
490 | 490 | try { |
491 | 491 | $this->xcloner_scheduler->xcloner_scheduler_callback(0, $schedule); |
492 | - }catch (Exception $e) { |
|
492 | + } catch (Exception $e) { |
|
493 | 493 | $this->get_xcloner_logger()->error($e->getMessage()); |
494 | 494 | } |
495 | 495 |
@@ -612,10 +612,10 @@ |
||
612 | 612 | |
613 | 613 | } |
614 | 614 | |
615 | - /** |
|
616 | - * @param $schedules |
|
617 | - * @return mixed |
|
618 | - */ |
|
615 | + /** |
|
616 | + * @param $schedules |
|
617 | + * @return mixed |
|
618 | + */ |
|
619 | 619 | public function add_new_intervals($schedules) |
620 | 620 | { |
621 | 621 | //weekly scheduler interval |
@@ -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 |
@@ -44,11 +44,13 @@ discard block |
||
44 | 44 | $this->xcloner_settings = $xcloner_container->get_xcloner_settings(); |
45 | 45 | $this->fs = $xcloner_container->get_xcloner_filesystem(); |
46 | 46 | |
47 | - if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) |
|
48 | - $this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
47 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) { |
|
48 | + $this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
49 | + } |
|
49 | 50 | |
50 | - if (!$this->recordsPerSession) |
|
51 | - $this->recordsPerSession = 100; |
|
51 | + if (!$this->recordsPerSession) { |
|
52 | + $this->recordsPerSession = 100; |
|
53 | + } |
|
52 | 54 | |
53 | 55 | if (!$wp_user && !$wp_pass && !$wp_host && !$wp_db) |
54 | 56 | { |
@@ -108,37 +110,43 @@ discard block |
||
108 | 110 | { |
109 | 111 | foreach ($params['#'] as $database) |
110 | 112 | { |
111 | - if (!isset($params[$database]) or !is_array($params[$database])) |
|
112 | - $params[$database] = array(); |
|
113 | + if (!isset($params[$database]) or !is_array($params[$database])) { |
|
114 | + $params[$database] = array(); |
|
115 | + } |
|
113 | 116 | } |
114 | 117 | $db_count = -1; |
115 | 118 | } |
116 | 119 | |
117 | - if (isset($params) and is_array($params)) |
|
118 | - foreach ($params as $database=>$tables) |
|
120 | + if (isset($params) and is_array($params)) { |
|
121 | + foreach ($params as $database=>$tables) |
|
119 | 122 | { |
120 | 123 | if ($database != "#") |
121 | 124 | { |
122 | - $stats = $this->write_backup_process_list($database, $tables); |
|
125 | + $stats = $this->write_backup_process_list($database, $tables); |
|
126 | + } |
|
123 | 127 | $return['stats']['tables_count'] += $stats['tables_count']; |
124 | 128 | $return['stats']['total_records'] += $stats['total_records']; |
125 | 129 | } |
126 | 130 | } |
127 | 131 | |
128 | - if (sizeof($params)) |
|
129 | - $return['stats']['database_count'] = sizeof($params) + $db_count; |
|
130 | - else |
|
131 | - $return['stats']['database_count'] = 0; |
|
132 | + if (sizeof($params)) { |
|
133 | + $return['stats']['database_count'] = sizeof($params) + $db_count; |
|
134 | + } else { |
|
135 | + $return['stats']['database_count'] = 0; |
|
136 | + } |
|
132 | 137 | |
133 | 138 | return $return; |
134 | 139 | } |
135 | 140 | |
136 | - if (!isset($extra_params['startAtLine'])) |
|
137 | - $extra_params['startAtLine'] = 0; |
|
138 | - if (!isset($extra_params['startAtRecord'])) |
|
139 | - $extra_params['startAtRecord'] = 0; |
|
140 | - if (!isset($extra_params['dumpfile'])) |
|
141 | - $extra_params['dumpfile'] = ""; |
|
141 | + if (!isset($extra_params['startAtLine'])) { |
|
142 | + $extra_params['startAtLine'] = 0; |
|
143 | + } |
|
144 | + if (!isset($extra_params['startAtRecord'])) { |
|
145 | + $extra_params['startAtRecord'] = 0; |
|
146 | + } |
|
147 | + if (!isset($extra_params['dumpfile'])) { |
|
148 | + $extra_params['dumpfile'] = ""; |
|
149 | + } |
|
142 | 150 | |
143 | 151 | $return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']); |
144 | 152 | |
@@ -151,10 +159,12 @@ discard block |
||
151 | 159 | if ($message) { |
152 | 160 | $this->logger->info($message, array("")); |
153 | 161 | } else { |
154 | - if ($this->last_query) |
|
155 | - $this->logger->debug($this->last_query, array("")); |
|
156 | - if ($this->last_error) |
|
157 | - $this->logger->error($this->last_error, array("")); |
|
162 | + if ($this->last_query) { |
|
163 | + $this->logger->debug($this->last_query, array("")); |
|
164 | + } |
|
165 | + if ($this->last_error) { |
|
166 | + $this->logger->error($this->last_error, array("")); |
|
167 | + } |
|
158 | 168 | } |
159 | 169 | |
160 | 170 | return; |
@@ -225,11 +235,12 @@ discard block |
||
225 | 235 | $databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname); |
226 | 236 | $i++; |
227 | 237 | |
228 | - if (is_array($databases)) |
|
229 | - foreach ($databases as $db) { |
|
238 | + if (is_array($databases)) { |
|
239 | + foreach ($databases as $db) { |
|
230 | 240 | if ($db->Database != $this->dbname) |
231 | 241 | { |
232 | 242 | $databases_list[$i]['name'] = $db->Database; |
243 | + } |
|
233 | 244 | $databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database); |
234 | 245 | $i++; |
235 | 246 | } |
@@ -252,8 +263,9 @@ discard block |
||
252 | 263 | $tablesList[0] = array( ); |
253 | 264 | $inc = 0; |
254 | 265 | |
255 | - if (!$database) |
|
256 | - $database = $this->dbname; |
|
266 | + if (!$database) { |
|
267 | + $database = $this->dbname; |
|
268 | + } |
|
257 | 269 | |
258 | 270 | $this->logger->debug(sprintf(("Listing tables in %s database"), $database)); |
259 | 271 | |
@@ -277,10 +289,11 @@ discard block |
||
277 | 289 | |
278 | 290 | $tablesList[$inc]['excluded'] = 0; |
279 | 291 | |
280 | - if (sizeof($included) and is_array($included)) |
|
281 | - if (!in_array($table, $included)) |
|
292 | + if (sizeof($included) and is_array($included)) { |
|
293 | + if (!in_array($table, $included)) |
|
282 | 294 | { |
283 | 295 | $tablesList[$inc]['excluded'] = 1; |
296 | + } |
|
284 | 297 | $this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database)); |
285 | 298 | } |
286 | 299 | $inc++; |
@@ -299,19 +312,21 @@ discard block |
||
299 | 312 | |
300 | 313 | $tables = $this->list_tables($dbname, $incl_tables, 1); |
301 | 314 | |
302 | - if ($this->dbname != $dbname) |
|
303 | - $dumpfile = $dbname."-backup.sql"; |
|
304 | - else |
|
305 | - $dumpfile = $this->TEMP_DUMP_FILE; |
|
315 | + if ($this->dbname != $dbname) { |
|
316 | + $dumpfile = $dbname."-backup.sql"; |
|
317 | + } else { |
|
318 | + $dumpfile = $this->TEMP_DUMP_FILE; |
|
319 | + } |
|
306 | 320 | |
307 | 321 | $line = sprintf("###newdump###\t%s\t%s\n", $dbname, $dumpfile); |
308 | 322 | $this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line); |
309 | 323 | |
310 | 324 | // write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records |
311 | - foreach ($tables as $key=>$table) |
|
312 | - if ($table != "" and !$tables[$key]['excluded']) { |
|
325 | + foreach ($tables as $key=>$table) { |
|
326 | + if ($table != "" and !$tables[$key]['excluded']) { |
|
313 | 327 | |
314 | 328 | $line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']); |
329 | + } |
|
315 | 330 | $this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line); |
316 | 331 | $return['tables_count']++; |
317 | 332 | $return['total_records'] += $tables[$key]['records']; |
@@ -359,8 +374,9 @@ discard block |
||
359 | 374 | $return['finished'] = 0; |
360 | 375 | $lines = array(); |
361 | 376 | |
362 | - if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
363 | - $lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE))); |
|
377 | + if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) { |
|
378 | + $lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE))); |
|
379 | + } |
|
364 | 380 | |
365 | 381 | foreach ($lines as $buffer) { |
366 | 382 | |
@@ -387,12 +403,14 @@ discard block |
||
387 | 403 | //break; |
388 | 404 | } else { |
389 | 405 | //we export the table |
390 | - if ($tableInfo[0] == "###enddump###") |
|
391 | - $return['endDump'] = 1; |
|
406 | + if ($tableInfo[0] == "###enddump###") { |
|
407 | + $return['endDump'] = 1; |
|
408 | + } |
|
392 | 409 | |
393 | 410 | //table is excluded |
394 | - if ($tableInfo[2]) |
|
395 | - continue; |
|
411 | + if ($tableInfo[2]) { |
|
412 | + continue; |
|
413 | + } |
|
396 | 414 | |
397 | 415 | $next = $startAtRecord + $this->recordsPerSession; |
398 | 416 | |
@@ -408,14 +426,17 @@ discard block |
||
408 | 426 | |
409 | 427 | $processed_records = 0; |
410 | 428 | |
411 | - if (trim($tableName) != "" and !$tableInfo[2]) |
|
412 | - $processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile); |
|
429 | + if (trim($tableName) != "" and !$tableInfo[2]) { |
|
430 | + $processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile); |
|
431 | + } |
|
413 | 432 | |
414 | 433 | $return['processedRecords'] = $startAtRecord + $processed_records; |
415 | 434 | |
416 | - if ($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record |
|
435 | + if ($next >= $tableInfo[1]) { |
|
436 | + //we finished loading the records for next sessions, will go to the new record |
|
417 | 437 | { |
418 | 438 | $startAtLine++; |
439 | + } |
|
419 | 440 | $startAtRecord = 0; |
420 | 441 | } else { |
421 | 442 | $startAtRecord = $startAtRecord + $this->recordsPerSession; |
@@ -450,8 +471,9 @@ discard block |
||
450 | 471 | $return['finished'] = 1; |
451 | 472 | $return['startAtLine'] = $startAtLine; |
452 | 473 | |
453 | - if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
454 | - $this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE); |
|
474 | + if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) { |
|
475 | + $this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE); |
|
476 | + } |
|
455 | 477 | |
456 | 478 | $this->logger->debug(sprintf(("Database backup finished!"))); |
457 | 479 | |
@@ -484,8 +506,9 @@ discard block |
||
484 | 506 | |
485 | 507 | $records = 0; |
486 | 508 | |
487 | - if ($start == 0) |
|
488 | - $this->dump_structure($databaseName, $tableName, $dumpfile); |
|
509 | + if ($start == 0) { |
|
510 | + $this->dump_structure($databaseName, $tableName, $dumpfile); |
|
511 | + } |
|
489 | 512 | |
490 | 513 | $start = intval($start); |
491 | 514 | $limit = intval($limit); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | try { |
26 | 26 | $option = Util::normalizePath($path); |
27 | - }catch (Exception $e) { |
|
27 | + } catch (Exception $e) { |
|
28 | 28 | add_settings_error('xcloner_error_message', '', __($e->getMessage()), 'error'); |
29 | 29 | } |
30 | 30 |