GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch dev (7ec9be)
by Liuta
01:54
created
includes/class-xcloner-sanitization.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
includes/class-xcloner-api.php 2 patches
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Braces   +21 added lines, -13 removed lines patch added patch discarded remove patch
@@ -797,23 +797,23 @@  discard block
 block discarded – undo
797 797
 
798 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 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 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']);
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
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();
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
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
 		}
@@ -994,7 +994,8 @@  discard block
 block discarded – undo
994 994
                                                    title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>">
995 995
                                                     <i class="material-icons">enhanced_encryption</i>
996 996
                                                 </a>
997
-                                            <?php else: ?>
997
+                                            <?php else {
998
+	: ?>
998 999
                                                 <a href="#<?php echo $child[0] ?>" class="list-backup-content"
999 1000
                                                    title="<?php echo __('List Backup Content',
1000 1001
 													   'xcloner-backup-and-restore') ?>"><i
@@ -1013,7 +1014,9 @@  discard block
 block discarded – undo
1013 1014
                                                         class="material-icons">file_upload</i></a>
1014 1015
                                         <?php endif ?>
1015 1016
                                     </li>
1016
-                                <?php endforeach; ?>
1017
+                                <?php endforeach;
1018
+}
1019
+?>
1017 1020
                             </ul>
1018 1021
                         <?php endif; ?>
1019 1022
                 <?php
@@ -1021,11 +1024,12 @@  discard block
 block discarded – undo
1021 1024
 				ob_end_clean();
1022 1025
 				?>
1023 1026
                     <?php ob_start(); ?>
1024
-                        <?php if (isset($file_info['timestamp']))
1027
+                        <?php if (isset($file_info['timestamp'])) {
1025 1028
 							echo date("Y-m-d H:i", $file_info['timestamp'])
1026 1029
 						?>
1027 1030
                     <?php
1028 1031
 						$return['data'][$i][] = ob_get_contents();
1032
+}
1029 1033
 						ob_end_clean();
1030 1034
 						?>
1031 1035
 
@@ -1050,15 +1054,17 @@  discard block
 block discarded – undo
1050 1054
                             <?php endif ?>
1051 1055
                             <?php
1052 1056
 							$basename = $file_info['basename'];
1053
-							if(isset($file_info['childs']) and sizeof($file_info['childs']))
1054
-								$basename = $file_info['childs'][0][0];
1057
+							if(isset($file_info['childs']) and sizeof($file_info['childs'])) {
1058
+															$basename = $file_info['childs'][0][0];
1059
+							}
1055 1060
 							?>
1056 1061
                             <?php if($this->xcloner_encryption->is_encrypted_file($basename)) :?>
1057 1062
                                 <a href="#<?php echo $file_info['basename'] ?>" class="backup-decryption"
1058 1063
                                    title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>">
1059 1064
                                     <i class="material-icons">enhanced_encryption</i>
1060 1065
                                 </a>
1061
-                            <?php else: ?>
1066
+                            <?php else {
1067
+	: ?>
1062 1068
                                 <a href="#<?php echo $file_info['basename'] ?>" class="list-backup-content"
1063 1069
                                     title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore') ?>"><i
1064 1070
                                     class="material-icons">folder_open</i></a>
@@ -1068,7 +1074,9 @@  discard block
 block discarded – undo
1068 1074
                                     <i class="material-icons">no_encryption</i>
1069 1075
                                 </a>
1070 1076
                             <?php endif?>
1071
-                        <?php endif; ?>
1077
+                        <?php endif;
1078
+}
1079
+?>
1072 1080
 
1073 1081
                         <a href="#<?php echo $file_info['basename'] ?>" class="delete"
1074 1082
                            title="<?php echo __('Delete Backup', 'xcloner-backup-and-restore') ?>">
Please login to merge, or discard this patch.
includes/class-xcloner-scheduler.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
includes/class-xcloner-archive.php 2 patches
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
      * @return bool
215 215
      */
216 216
 
217
-    /**
218
-     * @param string $error_message
219
-     */
217
+	/**
218
+	 * @param string $error_message
219
+	 */
220 220
 	public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
221 221
 	{
222 222
 
@@ -255,486 +255,486 @@  discard block
 block discarded – undo
255 255
      *
256 256
      * @return bool
257 257
      */
258
-    public function send_notification(
259
-        $to,
260
-        $from,
261
-        $subject,
262
-        $backup_name,
263
-        $params,
264
-        $error_message = "",
265
-        $additional = array()
266
-    ) {
267
-        if (!$from) {
268
-            $from = "XCloner Backup";
269
-        }
258
+	public function send_notification(
259
+		$to,
260
+		$from,
261
+		$subject,
262
+		$backup_name,
263
+		$params,
264
+		$error_message = "",
265
+		$additional = array()
266
+	) {
267
+		if (!$from) {
268
+			$from = "XCloner Backup";
269
+		}
270 270
 
271
-        if (($error_message)) {
272
-            return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
273
-        }
271
+		if (($error_message)) {
272
+			return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
273
+		}
274 274
 
275
-        $params = (array)$params;
275
+		$params = (array)$params;
276 276
 
277
-        if (!$subject) {
278
-            $subject = sprintf(__("New backup generated %s"), $backup_name);
279
-        }
277
+		if (!$subject) {
278
+			$subject = sprintf(__("New backup generated %s"), $backup_name);
279
+		}
280 280
 
281
-        $body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
282
-        $body .= "<br /><br />";
281
+		$body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
282
+		$body .= "<br /><br />";
283 283
 
284
-        if (isset($additional['lines_total'])) {
285
-            $body .= sprintf(__("Total files added: %s"), $additional['lines_total']);
286
-            $body .= "<br /><br />";
287
-        }
284
+		if (isset($additional['lines_total'])) {
285
+			$body .= sprintf(__("Total files added: %s"), $additional['lines_total']);
286
+			$body .= "<br /><br />";
287
+		}
288 288
 
289
-        $backup_parts = $this->filesystem->get_multipart_files($backup_name);
289
+		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
290 290
 
291
-        if (!$backups_counter = sizeof($backup_parts)) {
292
-            $backups_counter = 1;
293
-        }
291
+		if (!$backups_counter = sizeof($backup_parts)) {
292
+			$backups_counter = 1;
293
+		}
294 294
 
295
-        $body .= sprintf(__("Backup Parts: %s"), $backups_counter);
296
-        $body .= "<br />";
295
+		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
296
+		$body .= "<br />";
297 297
 
298
-        if (sizeof($backup_parts)) {
299
-            $body .= implode("<br />", $backup_parts);
300
-            $body .= "<br />";
301
-        }
298
+		if (sizeof($backup_parts)) {
299
+			$body .= implode("<br />", $backup_parts);
300
+			$body .= "<br />";
301
+		}
302 302
 
303
-        $body .= "<br />";
303
+		$body .= "<br />";
304 304
 
305
-        $body .= sprintf(__("Backup Site Url: %s"), get_site_url());
306
-        $body .= "<br />";
305
+		$body .= sprintf(__("Backup Site Url: %s"), get_site_url());
306
+		$body .= "<br />";
307 307
 
308
-        if (isset($params['backup_params']->backup_comments)) {
309
-            $body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
310
-            $body .= "<br /><br />";
311
-        }
308
+		if (isset($params['backup_params']->backup_comments)) {
309
+			$body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
310
+			$body .= "<br /><br />";
311
+		}
312 312
 
313
-        if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
314
-            $body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n",
315
-                                                                        $this->logger->getLastDebugLines(50));
316
-        }
313
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
314
+			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n",
315
+																		$this->logger->getLastDebugLines(50));
316
+		}
317 317
 
318
-        $attachments = $this->filesystem->get_backup_attachments();
318
+		$attachments = $this->filesystem->get_backup_attachments();
319 319
 
320
-        $attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path().DS."info.tgz";
320
+		$attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path().DS."info.tgz";
321 321
 
322
-        $tar = new Tar();
323
-        $tar->create($attachments_archive);
322
+		$tar = new Tar();
323
+		$tar->create($attachments_archive);
324 324
 
325
-        foreach ($attachments as $key => $file) {
326
-            $tar->addFile($file, basename($file));
327
-        }
328
-        $tar->close();
325
+		foreach ($attachments as $key => $file) {
326
+			$tar->addFile($file, basename($file));
327
+		}
328
+		$tar->close();
329 329
 
330
-        $this->logger->info(sprintf("Sending backup notification to %s", $to));
330
+		$this->logger->info(sprintf("Sending backup notification to %s", $to));
331 331
 
332
-        $admin_email = get_option("admin_email");
332
+		$admin_email = get_option("admin_email");
333 333
 
334
-        $headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
334
+		$headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
335 335
 
336
-        $return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
336
+		$return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
337 337
 
338
-        return $return;
339
-    }
338
+		return $return;
339
+	}
340 340
 
341
-    /*
341
+	/*
342 342
      *
343 343
      * Incremental Backup method
344 344
      *
345 345
      */
346
-    public function start_incremental_backup($backup_params, $extra_params, $init)
347
-    {
348
-        $return = array();
349
-
350
-        if (!isset($extra_params['backup_part'])) {
351
-            $extra_params['backup_part'] = 0;
352
-        }
353
-
354
-        $return['extra']['backup_part'] = $extra_params['backup_part'];
346
+	public function start_incremental_backup($backup_params, $extra_params, $init)
347
+	{
348
+		$return = array();
355 349
 
356
-        if (isset($extra_params['backup_archive_name'])) {
357
-            $this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
358
-        } else {
359
-            $this->set_archive_name($backup_params['backup_name']);
360
-        }
350
+		if (!isset($extra_params['backup_part'])) {
351
+			$extra_params['backup_part'] = 0;
352
+		}
361 353
 
362
-        if (!$this->get_archive_name()) {
363
-            $this->set_archive_name();
364
-        }
354
+		$return['extra']['backup_part'] = $extra_params['backup_part'];
365 355
 
366
-        $this->backup_archive = new Tar();
367
-        $this->backup_archive->setCompression($this->compression_level);
356
+		if (isset($extra_params['backup_archive_name'])) {
357
+			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
358
+		} else {
359
+			$this->set_archive_name($backup_params['backup_name']);
360
+		}
368 361
 
369
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
362
+		if (!$this->get_archive_name()) {
363
+			$this->set_archive_name();
364
+		}
370 365
 
371
-        if ($init) {
372
-            $this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
366
+		$this->backup_archive = new Tar();
367
+		$this->backup_archive->setCompression($this->compression_level);
373 368
 
374
-            $this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
369
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
375 370
 
376
-            $return['extra']['backup_init'] = 1;
371
+		if ($init) {
372
+			$this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
377 373
 
378
-        } else {
379
-            $this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
374
+			$this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
380 375
 
381
-            $this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
376
+			$return['extra']['backup_init'] = 1;
382 377
 
383
-            $return['extra']['backup_init'] = 0;
378
+		} else {
379
+			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
384 380
 
385
-        }
381
+			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
386 382
 
387
-        $return['extra']['backup_archive_name'] = $this->get_archive_name();
388
-        $return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
383
+			$return['extra']['backup_init'] = 0;
389 384
 
390
-        if (!isset($extra_params['start_at_line'])) {
391
-            $extra_params['start_at_line'] = 0;
392
-        }
385
+		}
393 386
 
394
-        if (!isset($extra_params['start_at_byte'])) {
395
-            $extra_params['start_at_byte'] = 0;
396
-        }
387
+		$return['extra']['backup_archive_name'] = $this->get_archive_name();
388
+		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
397 389
 
398
-        if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler())) {
399
-            $this->logger->error(sprintf("Missing the includes file handler %s, aborting...",
400
-                $this->filesystem->get_included_files_handler()));
390
+		if (!isset($extra_params['start_at_line'])) {
391
+			$extra_params['start_at_line'] = 0;
392
+		}
401 393
 
402
-            $return['finished'] = 1;
403
-            return $return;
404
-        }
394
+		if (!isset($extra_params['start_at_byte'])) {
395
+			$extra_params['start_at_byte'] = 0;
396
+		}
405 397
 
406
-        $included_files_handler = $this->filesystem->get_included_files_handler(1);
398
+		if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler())) {
399
+			$this->logger->error(sprintf("Missing the includes file handler %s, aborting...",
400
+				$this->filesystem->get_included_files_handler()));
407 401
 
408
-        $file = new SplFileObject($included_files_handler);
402
+			$return['finished'] = 1;
403
+			return $return;
404
+		}
409 405
 
410
-        $file->seek(PHP_INT_MAX);
406
+		$included_files_handler = $this->filesystem->get_included_files_handler(1);
411 407
 
412
-        $return['extra']['lines_total'] = ($file->key() - 1);
408
+		$file = new SplFileObject($included_files_handler);
413 409
 
414
-        //we skip the first CSV line with headers
415
-        if (!$extra_params['start_at_line']) {
416
-            $file->seek(1);
417
-        } else {
418
-            $file->seek($extra_params['start_at_line'] + 1);
419
-        }
410
+		$file->seek(PHP_INT_MAX);
420 411
 
421
-        $this->processed_size_bytes = 0;
412
+		$return['extra']['lines_total'] = ($file->key() - 1);
422 413
 
423
-        $counter = 0;
414
+		//we skip the first CSV line with headers
415
+		if (!$extra_params['start_at_line']) {
416
+			$file->seek(1);
417
+		} else {
418
+			$file->seek($extra_params['start_at_line'] + 1);
419
+		}
424 420
 
425
-        $start_byte = $extra_params['start_at_byte'];
421
+		$this->processed_size_bytes = 0;
426 422
 
427
-        $byte_limit = 0;
423
+		$counter = 0;
428 424
 
429
-        while (!$file->eof() and $counter <= $this->files_to_process_per_request) {
430
-            $current_line_str = $file->current();
425
+		$start_byte = $extra_params['start_at_byte'];
431 426
 
432
-            $line = str_getcsv($current_line_str);
427
+		$byte_limit = 0;
433 428
 
434
-            $relative_path = stripslashes($line[0]);
429
+		while (!$file->eof() and $counter <= $this->files_to_process_per_request) {
430
+			$current_line_str = $file->current();
435 431
 
436
-            $start_filesystem = "start_filesystem";
432
+			$line = str_getcsv($current_line_str);
437 433
 
438
-            if (isset($line[4])) {
439
-                $start_filesystem = $line[4];
440
-            }
434
+			$relative_path = stripslashes($line[0]);
441 435
 
442
-            //$adapter = $this->filesystem->get_adapter($start_filesystem);
436
+			$start_filesystem = "start_filesystem";
443 437
 
444
-            if (!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path)) {
445
-                if ($relative_path != "") {
446
-                    $this->logger->error(sprintf("Could not add file %b to backup archive, file not found",
447
-                        $relative_path));
448
-                }
438
+			if (isset($line[4])) {
439
+				$start_filesystem = $line[4];
440
+			}
449 441
 
450
-                $extra_params['start_at_line']++;
451
-                $file->next();
452
-                continue;
453
-            }
442
+			//$adapter = $this->filesystem->get_adapter($start_filesystem);
454 443
 
455
-            $file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
444
+			if (!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path)) {
445
+				if ($relative_path != "") {
446
+					$this->logger->error(sprintf("Could not add file %b to backup archive, file not found",
447
+						$relative_path));
448
+				}
456 449
 
457
-            if (!isset($file_info['size'])) {
458
-                $file_info['size'] = 0;
459
-            }
450
+				$extra_params['start_at_line']++;
451
+				$file->next();
452
+				continue;
453
+			}
460 454
 
461
-            if ($start_filesystem == "tmp_filesystem") {
462
-                $file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
463
-            }
455
+			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
464 456
 
465
-            $byte_limit = (int)$this->file_size_per_request_limit / 512;
457
+			if (!isset($file_info['size'])) {
458
+				$file_info['size'] = 0;
459
+			}
466 460
 
467
-            $append = 0;
461
+			if ($start_filesystem == "tmp_filesystem") {
462
+				$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
463
+			}
468 464
 
469
-            if ($file_info['size'] > $byte_limit * 512 or $start_byte) {
470
-                $append = 1;
471
-            }
465
+			$byte_limit = (int)$this->file_size_per_request_limit / 512;
472 466
 
473
-            if (!isset($return['extra']['backup_size'])) {
474
-                $return['extra']['backup_size'] = 0;
475
-            }
467
+			$append = 0;
476 468
 
477
-            $return['extra']['backup_size'] = $archive_info->getSize();
469
+			if ($file_info['size'] > $byte_limit * 512 or $start_byte) {
470
+				$append = 1;
471
+			}
478 472
 
479
-            $estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
473
+			if (!isset($return['extra']['backup_size'])) {
474
+				$return['extra']['backup_size'] = 0;
475
+			}
480 476
 
481
-            //we create a new backup part if we reach the Split Achive Limit
482
-            if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte)) {
483
-                $this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",
484
-                    $this->xcloner_split_backup_limit, $estimated_new_size));
485
-                list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
477
+			$return['extra']['backup_size'] = $archive_info->getSize();
486 478
 
487
-                if ($file_info['size'] > $this->xcloner_split_backup_limit) {
488
-                    $this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file",
489
-                        $file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
490
-                    $extra_params['start_at_line']++;
491
-                }
479
+			$estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
492 480
 
493
-                $return['extra']['start_at_line'] = $extra_params['start_at_line'];
494
-                $return['extra']['start_at_byte'] = 0;
481
+			//we create a new backup part if we reach the Split Achive Limit
482
+			if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte)) {
483
+				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",
484
+					$this->xcloner_split_backup_limit, $estimated_new_size));
485
+				list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
495 486
 
496
-                $return['finished'] = 0;
487
+				if ($file_info['size'] > $this->xcloner_split_backup_limit) {
488
+					$this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file",
489
+						$file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
490
+					$extra_params['start_at_line']++;
491
+				}
497 492
 
498
-                return $return;
499
-            }
493
+				$return['extra']['start_at_line'] = $extra_params['start_at_line'];
494
+				$return['extra']['start_at_byte'] = 0;
500 495
 
501
-            list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit,
502
-                $append, $start_filesystem);
503
-            $this->processed_size_bytes += $bytes_wrote;
496
+				$return['finished'] = 0;
504 497
 
505
-            //echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
506
-            $return['extra']['processed_file'] = $file_info['path'];
507
-            $return['extra']['processed_file_size'] = $file_info['size'];
508
-            $return['extra']['backup_size'] = $archive_info->getSize();
498
+				return $return;
499
+			}
509 500
 
510
-            if ($last_position > 0) {
511
-                $start_byte = $last_position;
512
-            } else {
513
-                $extra_params['start_at_line']++;
514
-                $file->next();
515
-                $start_byte = 0;
516
-                $counter++;
517
-            }
501
+			list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit,
502
+				$append, $start_filesystem);
503
+			$this->processed_size_bytes += $bytes_wrote;
504
+
505
+			//echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
506
+			$return['extra']['processed_file'] = $file_info['path'];
507
+			$return['extra']['processed_file_size'] = $file_info['size'];
508
+			$return['extra']['backup_size'] = $archive_info->getSize();
509
+
510
+			if ($last_position > 0) {
511
+				$start_byte = $last_position;
512
+			} else {
513
+				$extra_params['start_at_line']++;
514
+				$file->next();
515
+				$start_byte = 0;
516
+				$counter++;
517
+			}
518 518
 
519
-            if ($this->processed_size_bytes >= $this->file_size_per_request_limit) {
520
-                clearstatcache();
521
-                $return['extra']['backup_size'] = $archive_info->getSize();
519
+			if ($this->processed_size_bytes >= $this->file_size_per_request_limit) {
520
+				clearstatcache();
521
+				$return['extra']['backup_size'] = $archive_info->getSize();
522 522
 
523
-                $return['finished'] = 0;
524
-                $return['extra']['start_at_line'] = $extra_params['start_at_line'];
525
-                $return['extra']['start_at_byte'] = $last_position;
526
-                $this->logger->info(sprintf("Reached the maximum %s request data limit, returning response",
527
-                    $this->file_size_per_request_limit));
528
-                return $return;
529
-            }
530
-        }
523
+				$return['finished'] = 0;
524
+				$return['extra']['start_at_line'] = $extra_params['start_at_line'];
525
+				$return['extra']['start_at_byte'] = $last_position;
526
+				$this->logger->info(sprintf("Reached the maximum %s request data limit, returning response",
527
+					$this->file_size_per_request_limit));
528
+				return $return;
529
+			}
530
+		}
531 531
 
532
-        if (!$file->eof()) {
533
-            clearstatcache();
534
-            $return['extra']['backup_size'] = $archive_info->getSize();
532
+		if (!$file->eof()) {
533
+			clearstatcache();
534
+			$return['extra']['backup_size'] = $archive_info->getSize();
535 535
 
536
-            $return['finished'] = 0;
537
-            $return['extra']['start_at_line'] = $extra_params['start_at_line'];
538
-            $return['extra']['start_at_byte'] = $last_position;
539
-            $this->logger->info(sprintf("We have reached the maximum files to process per request limit of %s, returning response",
540
-                $this->files_to_process_per_request));
536
+			$return['finished'] = 0;
537
+			$return['extra']['start_at_line'] = $extra_params['start_at_line'];
538
+			$return['extra']['start_at_byte'] = $last_position;
539
+			$this->logger->info(sprintf("We have reached the maximum files to process per request limit of %s, returning response",
540
+				$this->files_to_process_per_request));
541 541
 
542
-            return $return;
543
-        }
542
+			return $return;
543
+		}
544 544
 
545
-        //close the backup archive by adding 2*512 blocks of zero bytes
546
-        $this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
547
-            $this->get_archive_name_with_extension()));
548
-        $this->backup_archive->close();
545
+		//close the backup archive by adding 2*512 blocks of zero bytes
546
+		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
547
+			$this->get_archive_name_with_extension()));
548
+		$this->backup_archive->close();
549 549
 
550
-        /**
551
-         * XCloner HOOK backup_archive_finished.
552
-         *
553
-         * This will get triggered when a backup archive is finished writing.
554
-         */
555
-        //do_action('backup_archive_finished', $this->backup_archive, $this);
550
+		/**
551
+		 * XCloner HOOK backup_archive_finished.
552
+		 *
553
+		 * This will get triggered when a backup archive is finished writing.
554
+		 */
555
+		//do_action('backup_archive_finished', $this->backup_archive, $this);
556 556
 
557
-        //updating archive_info
558
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
557
+		//updating archive_info
558
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
559 559
 
560
-        if ($return['extra']['backup_part']) {
561
-            $this->write_multipart_file($this->get_archive_name_with_extension());
562
-        }
560
+		if ($return['extra']['backup_part']) {
561
+			$this->write_multipart_file($this->get_archive_name_with_extension());
562
+		}
563 563
 
564
-        $return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
564
+		$return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
565 565
 
566
-        if (isset($file_info)) {
567
-            $return['extra']['processed_file'] = $file_info['path'];
568
-            $return['extra']['processed_file_size'] = $file_info['size'];
569
-        }
566
+		if (isset($file_info)) {
567
+			$return['extra']['processed_file'] = $file_info['path'];
568
+			$return['extra']['processed_file_size'] = $file_info['size'];
569
+		}
570 570
 
571
-        clearstatcache();
572
-        $return['extra']['backup_size'] = $archive_info->getSize();
571
+		clearstatcache();
572
+		$return['extra']['backup_size'] = $archive_info->getSize();
573 573
 
574
-        $return['finished'] = 1;
575
-        return $return;
576
-    }
574
+		$return['finished'] = 1;
575
+		return $return;
576
+	}
577 577
 
578
-    /*
578
+	/*
579 579
      *
580 580
      * Write multipart file components
581 581
      *
582 582
      */
583
-    private function write_multipart_file($path = "")
584
-    {
585
-        if (!$path) {
586
-            $path = $this->get_archive_name_with_extension();
587
-        }
583
+	private function write_multipart_file($path = "")
584
+	{
585
+		if (!$path) {
586
+			$path = $this->get_archive_name_with_extension();
587
+		}
588 588
 
589
-        $file = $this->filesystem->get_filesystem("storage_filesystem_append")->getMetadata($path);
590
-        //print_r($file_info);
591
-        $line = '"'.$file['path'].'","'.$file['timestamp'].'","'.$file['size'].'"'.PHP_EOL;
589
+		$file = $this->filesystem->get_filesystem("storage_filesystem_append")->getMetadata($path);
590
+		//print_r($file_info);
591
+		$line = '"'.$file['path'].'","'.$file['timestamp'].'","'.$file['size'].'"'.PHP_EOL;
592 592
 
593 593
 
594
-        $this->filesystem->get_filesystem("storage_filesystem_append")
595
-            ->write($this->get_archive_name_multipart(), $line);
596
-    }
594
+		$this->filesystem->get_filesystem("storage_filesystem_append")
595
+			->write($this->get_archive_name_multipart(), $line);
596
+	}
597 597
 
598
-    /*
598
+	/*
599 599
      *
600 600
      * Create a new backup part
601 601
      *
602 602
      */
603
-    private function create_new_backup_part($part = 0)
604
-    {
605
-        //close the backup archive by adding 2*512 blocks of zero bytes
606
-        $this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
607
-            $this->get_archive_name_with_extension()));
608
-        $this->backup_archive->close();
609
-
610
-        if (!$part) {
611
-            $old_name = $this->get_archive_name_with_extension();
612
-            $this->set_archive_name($this->get_archive_name(), ++$part);
613
-            $this->rename_archive($old_name, $this->get_archive_name_with_extension());
614
-
615
-            if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
616
-                $this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
617
-            }
603
+	private function create_new_backup_part($part = 0)
604
+	{
605
+		//close the backup archive by adding 2*512 blocks of zero bytes
606
+		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
607
+			$this->get_archive_name_with_extension()));
608
+		$this->backup_archive->close();
609
+
610
+		if (!$part) {
611
+			$old_name = $this->get_archive_name_with_extension();
612
+			$this->set_archive_name($this->get_archive_name(), ++$part);
613
+			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
614
+
615
+			if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
616
+				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
617
+			}
618 618
 
619
-            $this->write_multipart_file($this->get_archive_name_with_extension());
619
+			$this->write_multipart_file($this->get_archive_name_with_extension());
620 620
 
621
-        } else {
622
-            $this->logger->info(sprintf("Creating new multipart info file %s",
623
-                $this->get_archive_name_with_extension()));
624
-            $this->write_multipart_file($this->get_archive_name_with_extension());
625
-        }
621
+		} else {
622
+			$this->logger->info(sprintf("Creating new multipart info file %s",
623
+				$this->get_archive_name_with_extension()));
624
+			$this->write_multipart_file($this->get_archive_name_with_extension());
625
+		}
626 626
 
627
-        $this->set_archive_name($this->get_archive_name(), ++$part);
627
+		$this->set_archive_name($this->get_archive_name(), ++$part);
628 628
 
629
-        $this->logger->info(sprintf("Creating new backup archive part %s", $this->get_archive_name_with_extension()));
629
+		$this->logger->info(sprintf("Creating new backup archive part %s", $this->get_archive_name_with_extension()));
630 630
 
631
-        $this->backup_archive = new Tar();
632
-        $this->backup_archive->setCompression($this->compression_level);
633
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
634
-        $this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
631
+		$this->backup_archive = new Tar();
632
+		$this->backup_archive->setCompression($this->compression_level);
633
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
634
+		$this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
635 635
 
636
-        return array($archive_info, $part);
636
+		return array($archive_info, $part);
637 637
 
638
-    }
638
+	}
639 639
 
640
-    /*
640
+	/*
641 641
      *
642 642
      * Add file to archive
643 643
      *
644 644
      */
645 645
 
646
-    /**
647
-     * @param integer $append
648
-     */
649
-    public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
650
-    {
646
+	/**
647
+	 * @param integer $append
648
+	 */
649
+	public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
650
+	{
651 651
 
652
-        $start_adapter = $this->filesystem->get_adapter($filesystem);
653
-        $start_filesystem = $this->filesystem->get_adapter($filesystem);
652
+		$start_adapter = $this->filesystem->get_adapter($filesystem);
653
+		$start_filesystem = $this->filesystem->get_adapter($filesystem);
654 654
 
655
-        if (!$file_info['path']) {
656
-            return;
657
-        }
655
+		if (!$file_info['path']) {
656
+			return;
657
+		}
658 658
 
659
-        if (isset($file_info['archive_prefix_path'])) {
660
-            $file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
661
-        } else {
662
-            $file_info['target_path'] = $file_info['path'];
663
-        }
659
+		if (isset($file_info['archive_prefix_path'])) {
660
+			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
661
+		} else {
662
+			$file_info['target_path'] = $file_info['path'];
663
+		}
664 664
 
665
-        $last_position = $start_at_byte;
665
+		$last_position = $start_at_byte;
666 666
 
667
-        //$start_adapter = $this->filesystem->get_start_adapter();
667
+		//$start_adapter = $this->filesystem->get_start_adapter();
668 668
 
669
-        if (!$append) {
670
-            $bytes_wrote = $file_info['size'];
671
-            $this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote,
672
-                $file_info['target_path'], $this->get_archive_name_with_extension()));
673
-            $this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']),
674
-                $file_info['target_path']);
675
-        } else {
676
-            $tmp_file = md5($file_info['path']);
669
+		if (!$append) {
670
+			$bytes_wrote = $file_info['size'];
671
+			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote,
672
+				$file_info['target_path'], $this->get_archive_name_with_extension()));
673
+			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']),
674
+				$file_info['target_path']);
675
+		} else {
676
+			$tmp_file = md5($file_info['path']);
677 677
 
678
-            //we isolate file to tmp if we are at byte 0, the starting point of file reading
679
-            if (!$start_at_byte) {
680
-                $this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes",
681
-                    $file_info['path'], $tmp_file));
682
-                $file_stream = $start_filesystem->readStream($file_info['path']);
678
+			//we isolate file to tmp if we are at byte 0, the starting point of file reading
679
+			if (!$start_at_byte) {
680
+				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes",
681
+					$file_info['path'], $tmp_file));
682
+				$file_stream = $start_filesystem->readStream($file_info['path']);
683 683
 
684
-                if (is_resource($file_stream['stream'])) {
685
-                    $this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
686
-                }
687
-            }
684
+				if (is_resource($file_stream['stream'])) {
685
+					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
686
+				}
687
+			}
688 688
 
689
-            if ($this->filesystem->get_tmp_filesystem()->has($tmp_file)) {
690
-                $is_tmp = 1;
691
-                $last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()
692
-                                                        ->applyPathPrefix($tmp_file),
693
-                    $file_info['target_path'], $start_at_byte, $byte_limit);
694
-            } else {
695
-                $is_tmp = 0;
696
-                $last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']),
697
-                    $file_info['target_path'], $start_at_byte, $byte_limit);
698
-            }
689
+			if ($this->filesystem->get_tmp_filesystem()->has($tmp_file)) {
690
+				$is_tmp = 1;
691
+				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()
692
+														->applyPathPrefix($tmp_file),
693
+					$file_info['target_path'], $start_at_byte, $byte_limit);
694
+			} else {
695
+				$is_tmp = 0;
696
+				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']),
697
+					$file_info['target_path'], $start_at_byte, $byte_limit);
698
+			}
699 699
 
700 700
 
701
-            if ($last_position == -1) {
702
-                $bytes_wrote = $file_info['size'] - $start_at_byte;
703
-            } else {
704
-                $bytes_wrote = $last_position - $start_at_byte;
705
-            }
701
+			if ($last_position == -1) {
702
+				$bytes_wrote = $file_info['size'] - $start_at_byte;
703
+			} else {
704
+				$bytes_wrote = $last_position - $start_at_byte;
705
+			}
706 706
 
707 707
 
708
-            if ($is_tmp) {
709
-                $this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ",
710
-                    $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
711
-            } else {
712
-                $this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ",
713
-                    $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
714
-            }
708
+			if ($is_tmp) {
709
+				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ",
710
+					$bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
711
+			} else {
712
+				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ",
713
+					$bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
714
+			}
715 715
 
716
-            //we delete here the isolated tmp file
717
-            if ($last_position == -1) {
718
-                if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file)) {
719
-                    $this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
720
-                    $this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
721
-                }
722
-            }
716
+			//we delete here the isolated tmp file
717
+			if ($last_position == -1) {
718
+				if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file)) {
719
+					$this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
720
+					$this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
721
+				}
722
+			}
723 723
 
724
-        }
724
+		}
725 725
 
726
-        return array($bytes_wrote, $last_position);
727
-    }
726
+		return array($bytes_wrote, $last_position);
727
+	}
728 728
 
729
-    /**
730
-     * Open a TAR archive and put the file cursor at the end for data appending
731
-     *
732
-     * If $file is empty, the tar file will be created in memory
733
-     *
734
-     * @param string $file
735
-     * @throws ArchiveIOException
736
-     */
737
-    /*
729
+	/**
730
+	 * Open a TAR archive and put the file cursor at the end for data appending
731
+	 *
732
+	 * If $file is empty, the tar file will be created in memory
733
+	 *
734
+	 * @param string $file
735
+	 * @throws ArchiveIOException
736
+	 */
737
+	/*
738 738
     public function openForAppend($file = '')
739 739
     {
740 740
         $this->file   = $file;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
includes/class-xcloner-encryption.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -377,6 +377,6 @@
 block discarded – undo
377 377
 			$xcloner_encryption->decrypt_file($argv[2], $argv[2].".dec", $argv[4], '', '', true);
378 378
 		}
379 379
 	}
380
-}catch (\Exception $e) {
380
+} catch (\Exception $e) {
381 381
 	echo "CAUGHT: ".$e->getMessage();
382 382
 }
Please login to merge, or discard this patch.
includes/class-xcloner-file-transfer.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -29,137 +29,137 @@
 block discarded – undo
29 29
 class Xcloner_File_Transfer extends Xcloner_File_System
30 30
 {
31 31
 
32
-    /**
33
-     * Target url web address of the restore script
34
-     * @var string
35
-     */
36
-    private $target_url;
37
-    /**
38
-     * Transfer data limit in bytes
39
-     * @var int
40
-     */
41
-    private $transfer_limit = 1048576; //bytes 1MB= 1048576 300KB = 358400
32
+	/**
33
+	 * Target url web address of the restore script
34
+	 * @var string
35
+	 */
36
+	private $target_url;
37
+	/**
38
+	 * Transfer data limit in bytes
39
+	 * @var int
40
+	 */
41
+	private $transfer_limit = 1048576; //bytes 1MB= 1048576 300KB = 358400
42 42
 
43 43
 
44
-    /**
45
-     * @param $target_url
46
-     *
47
-     * @return mixed
48
-     */
49
-    public function set_target($target_url)
50
-    {
51
-        return $this->target_url = $target_url;
52
-    }
44
+	/**
45
+	 * @param $target_url
46
+	 *
47
+	 * @return mixed
48
+	 */
49
+	public function set_target($target_url)
50
+	{
51
+		return $this->target_url = $target_url;
52
+	}
53 53
 
54
-    /**
55
-     * @return string
56
-     */
57
-    public function get_target()
58
-    {
59
-        return $this->target_url;
60
-    }
54
+	/**
55
+	 * @return string
56
+	 */
57
+	public function get_target()
58
+	{
59
+		return $this->target_url;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @param $file
65
-     * @param int $start
66
-     * @param string $hash
67
-     *
68
-     * @return bool|int
69
-     * @throws Exception
70
-     */
71
-    public function transfer_file($file, $start = 0, $hash = "")
72
-    {
73
-        if (!$this->target_url) {
74
-            throw new Exception("Please setup a target url for upload");
75
-        }
63
+	/**
64
+	 * @param $file
65
+	 * @param int $start
66
+	 * @param string $hash
67
+	 *
68
+	 * @return bool|int
69
+	 * @throws Exception
70
+	 */
71
+	public function transfer_file($file, $start = 0, $hash = "")
72
+	{
73
+		if (!$this->target_url) {
74
+			throw new Exception("Please setup a target url for upload");
75
+		}
76 76
 
77 77
 
78
-        $fp = $this->get_storage_filesystem()->readStream($file);
78
+		$fp = $this->get_storage_filesystem()->readStream($file);
79 79
 
80
-        fseek($fp, $start, SEEK_SET);
80
+		fseek($fp, $start, SEEK_SET);
81 81
 
82
-        $binary_data = fread($fp, $this->transfer_limit);
82
+		$binary_data = fread($fp, $this->transfer_limit);
83 83
 
84
-        $tmp_filename = "xcloner_upload_".substr(md5(time()), 0, 5);
84
+		$tmp_filename = "xcloner_upload_".substr(md5(time()), 0, 5);
85 85
 
86
-        $this->get_tmp_filesystem()->write($tmp_filename, $binary_data);
86
+		$this->get_tmp_filesystem()->write($tmp_filename, $binary_data);
87 87
 
88
-        $tmp_file_path = $this->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_filename);
88
+		$tmp_file_path = $this->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_filename);
89 89
 
90
-        $send_array = array();
90
+		$send_array = array();
91 91
 
92
-        $send_array['file'] = $file;
93
-        $send_array['start'] = $start;
94
-        $send_array['xcloner_action'] = "write_file";
95
-        $send_array['hash'] = $hash;
96
-        #$send_array['blob'] 	= $binary_data;
97
-        $send_array['blob'] = $this->curl_file_create($tmp_file_path, 'application/x-binary', $tmp_filename);
92
+		$send_array['file'] = $file;
93
+		$send_array['start'] = $start;
94
+		$send_array['xcloner_action'] = "write_file";
95
+		$send_array['hash'] = $hash;
96
+		#$send_array['blob'] 	= $binary_data;
97
+		$send_array['blob'] = $this->curl_file_create($tmp_file_path, 'application/x-binary', $tmp_filename);
98 98
 
99
-        //$data = http_build_query($send_array);
99
+		//$data = http_build_query($send_array);
100 100
 
101
-        $this->get_logger()->info(sprintf("Sending curl request to %s with %s data of file %s starting position %s using temporary file %s",
102
-            $this->target_url, $this->transfer_limit, $file, $start, $tmp_filename));
101
+		$this->get_logger()->info(sprintf("Sending curl request to %s with %s data of file %s starting position %s using temporary file %s",
102
+			$this->target_url, $this->transfer_limit, $file, $start, $tmp_filename));
103 103
 
104 104
 
105
-        $ch = curl_init();
106
-        curl_setopt($ch, CURLOPT_URL, $this->target_url);
105
+		$ch = curl_init();
106
+		curl_setopt($ch, CURLOPT_URL, $this->target_url);
107 107
 
108
-        curl_setopt($ch, CURLOPT_POST, 1);
109
-        //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
110
-        //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
111
-        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
112
-        curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
113
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
108
+		curl_setopt($ch, CURLOPT_POST, 1);
109
+		//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
110
+		//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
111
+		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
112
+		curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
113
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
114 114
 
115
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $send_array);
116
-        curl_setopt($ch, CURLOPT_VERBOSE, true);
115
+		curl_setopt($ch, CURLOPT_POSTFIELDS, $send_array);
116
+		curl_setopt($ch, CURLOPT_VERBOSE, true);
117 117
 
118
-        $original_result = curl_exec($ch);
118
+		$original_result = curl_exec($ch);
119 119
 
120 120
 
121
-        $this->get_tmp_filesystem()->delete($tmp_filename);
121
+		$this->get_tmp_filesystem()->delete($tmp_filename);
122 122
 
123
-        $result = json_decode($original_result);
123
+		$result = json_decode($original_result);
124 124
 
125
-        if (!$result) {
126
-            throw new Exception("We have received no valid response from the remote host, original message: ".$original_result);
127
-        }
125
+		if (!$result) {
126
+			throw new Exception("We have received no valid response from the remote host, original message: ".$original_result);
127
+		}
128 128
 
129
-        if ($result->status != 200) {
130
-            throw new Exception($result->response);
131
-        }
129
+		if ($result->status != 200) {
130
+			throw new Exception($result->response);
131
+		}
132 132
 
133
-        if (ftell($fp) >= $this->get_storage_filesystem()->getSize($file)) {
134
-            $this->get_logger()->info(sprintf("Upload done for file %s to target url %s, transferred a total of %s bytes",
135
-                $file, $this->target_url, ftell($fp)));
136
-            $this->remove_tmp_filesystem();
133
+		if (ftell($fp) >= $this->get_storage_filesystem()->getSize($file)) {
134
+			$this->get_logger()->info(sprintf("Upload done for file %s to target url %s, transferred a total of %s bytes",
135
+				$file, $this->target_url, ftell($fp)));
136
+			$this->remove_tmp_filesystem();
137 137
 
138
-            return false;
139
-        }
138
+			return false;
139
+		}
140 140
 
141
-        return ftell($fp);
142
-    }
141
+		return ftell($fp);
142
+	}
143 143
 
144
-    /**
145
-     * @param string $filename
146
-     * @param string $mimetype
147
-     * @param string $postname
148
-     *
149
-     * @return CURLFile|string
150
-     */
151
-    private function curl_file_create($filename, $mimetype = '', $postname = '')
152
-    {
153
-        if (!function_exists('curl_file_create')) {
144
+	/**
145
+	 * @param string $filename
146
+	 * @param string $mimetype
147
+	 * @param string $postname
148
+	 *
149
+	 * @return CURLFile|string
150
+	 */
151
+	private function curl_file_create($filename, $mimetype = '', $postname = '')
152
+	{
153
+		if (!function_exists('curl_file_create')) {
154 154
 
155
-            return "@$filename;filename="
156
-                . ($postname ?: basename($filename))
157
-                . ($mimetype ? ";type=$mimetype" : '');
155
+			return "@$filename;filename="
156
+				. ($postname ?: basename($filename))
157
+				. ($mimetype ? ";type=$mimetype" : '');
158 158
 
159
-        } else {
159
+		} else {
160 160
 
161
-            return curl_file_create($filename, $mimetype, $postname);
161
+			return curl_file_create($filename, $mimetype, $postname);
162 162
 
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 }
Please login to merge, or discard this patch.
includes/class-xcloner-settings.php 1 patch
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
includes/class-xcloner-remote-storage.php 2 patches
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -162,26 +162,26 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		{
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@
 block discarded – undo
213 213
 
214 214
 		if( $action == 'e' && function_exists('openssl_encrypt')) {
215 215
 			$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
216
-		}
217
-		else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
216
+		} else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
218 217
 			$decrypt = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
219 218
 			if($decrypt) {
220 219
 				//we check if decrypt was succesful
Please login to merge, or discard this patch.
xcloner.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
117 117
 
118 118
 try {
119 119
 	$xcloner_plugin = run_xcloner();
120
-}catch (Exception $e) {
120
+} catch (Exception $e) {
121 121
 	echo $e->getMessage();
122 122
 }
123 123
 
Please login to merge, or discard this patch.