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-activator.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
 
62 62
 		global $wpdb;
63 63
 
64
-		if ( version_compare( phpversion(), Xcloner_Activator::xcloner_minimum_version, '<' ) ) {
65
-			wp_die( '<p>' . sprintf( __( "XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s" ), Xcloner_Activator::xcloner_minimum_version, phpversion() ) . '</p>', __( "XCloner Activation Error" ), array( 'response'  => 500,
64
+		if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) {
65
+			wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array('response'  => 500,
66 66
 																																																																   'back_link' => true
67
-			) );
67
+			));
68 68
 		}
69 69
 
70 70
 		$charset_collate = $wpdb->get_charset_collate();
71 71
 
72
-		$installed_ver = get_option( "xcloner_db_version" );
72
+		$installed_ver = get_option("xcloner_db_version");
73 73
 
74 74
 		$xcloner_db_version = Xcloner_Activator::xcloner_db_version;
75 75
 
76
-		$xcloner_scheduler_table = $wpdb->prefix . "xcloner_scheduler";
76
+		$xcloner_scheduler_table = $wpdb->prefix."xcloner_scheduler";
77 77
 
78
-		if ( $installed_ver != $xcloner_db_version ) {
79
-			$xcloner_schedule_sql = "CREATE TABLE `" . $xcloner_scheduler_table . "` (
78
+		if ($installed_ver != $xcloner_db_version) {
79
+			$xcloner_schedule_sql = "CREATE TABLE `".$xcloner_scheduler_table."` (
80 80
 				  `id` int(11) NOT NULL AUTO_INCREMENT,
81 81
 				  `name` varchar(255) NOT NULL,
82 82
 				  `recurrence` varchar(25) NOT NULL,
@@ -87,73 +87,73 @@  discard block
 block discarded – undo
87 87
 				  `status` int(1) NOT NULL,
88 88
 				  `last_backup` varchar(100) DEFAULT NULL,
89 89
 				  PRIMARY KEY  (`id`)
90
-				) " . $charset_collate . ";
90
+				) " . $charset_collate.";
91 91
 				";
92 92
 
93
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
94
-			dbDelta( $xcloner_schedule_sql );
93
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
94
+			dbDelta($xcloner_schedule_sql);
95 95
 
96
-			update_option( "xcloner_db_version", $xcloner_db_version );
96
+			update_option("xcloner_db_version", $xcloner_db_version);
97 97
 		}
98 98
 
99
-		if ( get_option( 'xcloner_backup_compression_level' ) === false ) {
100
-			update_option( 'xcloner_backup_compression_level', 0 );
99
+		if (get_option('xcloner_backup_compression_level') === false) {
100
+			update_option('xcloner_backup_compression_level', 0);
101 101
 		}
102 102
 
103
-		if ( get_option( 'xcloner_enable_log' ) === false ) {
104
-			update_option( 'xcloner_enable_log', 1 );
103
+		if (get_option('xcloner_enable_log') === false) {
104
+			update_option('xcloner_enable_log', 1);
105 105
 		}
106 106
 
107
-		if ( get_option( 'xcloner_enable_mysql_backup' ) === false ) {
108
-			update_option( 'xcloner_enable_mysql_backup', 1 );
107
+		if (get_option('xcloner_enable_mysql_backup') === false) {
108
+			update_option('xcloner_enable_mysql_backup', 1);
109 109
 		}
110 110
 
111
-		if ( get_option( 'xcloner_system_settings_page' ) === false ) {
112
-			update_option( 'xcloner_system_settings_page', 100 );
111
+		if (get_option('xcloner_system_settings_page') === false) {
112
+			update_option('xcloner_system_settings_page', 100);
113 113
 		}
114 114
 
115
-		if ( get_option( 'xcloner_files_to_process_per_request' ) === false ) {
116
-			update_option( 'xcloner_files_to_process_per_request', 250 );
115
+		if (get_option('xcloner_files_to_process_per_request') === false) {
116
+			update_option('xcloner_files_to_process_per_request', 250);
117 117
 		}
118 118
 
119
-		if ( get_option( 'xcloner_database_records_per_request' ) === false ) {
120
-			update_option( 'xcloner_database_records_per_request', 10000 );
119
+		if (get_option('xcloner_database_records_per_request') === false) {
120
+			update_option('xcloner_database_records_per_request', 10000);
121 121
 		}
122 122
 
123
-		if ( get_option( 'xcloner_exclude_files_larger_than_mb' ) === false ) {
124
-			update_option( 'xcloner_exclude_files_larger_than_mb', 0 );
123
+		if (get_option('xcloner_exclude_files_larger_than_mb') === false) {
124
+			update_option('xcloner_exclude_files_larger_than_mb', 0);
125 125
 		}
126 126
 
127
-		if ( get_option( 'xcloner_split_backup_limit' ) === false ) {
128
-			update_option( 'xcloner_split_backup_limit', 2048 );
127
+		if (get_option('xcloner_split_backup_limit') === false) {
128
+			update_option('xcloner_split_backup_limit', 2048);
129 129
 		}
130 130
 
131
-		if ( get_option( 'xcloner_size_limit_per_request' ) === false ) {
132
-			update_option( 'xcloner_size_limit_per_request', 50 );
131
+		if (get_option('xcloner_size_limit_per_request') === false) {
132
+			update_option('xcloner_size_limit_per_request', 50);
133 133
 		}
134 134
 
135
-		if ( get_option( 'xcloner_cleanup_retention_limit_days' ) === false ) {
136
-			update_option( 'xcloner_cleanup_retention_limit_days', 60 );
135
+		if (get_option('xcloner_cleanup_retention_limit_days') === false) {
136
+			update_option('xcloner_cleanup_retention_limit_days', 60);
137 137
 		}
138 138
 
139
-		if ( get_option( 'xcloner_cleanup_retention_limit_archives' ) === false ) {
140
-			update_option( 'xcloner_cleanup_retention_limit_archives', 100 );
139
+		if (get_option('xcloner_cleanup_retention_limit_archives') === false) {
140
+			update_option('xcloner_cleanup_retention_limit_archives', 100);
141 141
 		}
142 142
 
143
-		if ( get_option( 'xcloner_directories_to_scan_per_request' ) === false ) {
144
-			update_option( 'xcloner_directories_to_scan_per_request', 25 );
143
+		if (get_option('xcloner_directories_to_scan_per_request') === false) {
144
+			update_option('xcloner_directories_to_scan_per_request', 25);
145 145
 		}
146 146
 
147 147
 		/*if(!get_option('xcloner_diff_backup_recreate_period'))
148 148
 			update_option('xcloner_diff_backup_recreate_period', 10);
149 149
 			* */
150 150
 
151
-		if ( ! get_option( 'xcloner_regex_exclude' ) ) {
152
-			update_option( 'xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$" . PHP_EOL . "(.*)\.(svn|git)(.*)$" . PHP_EOL . "wp-content\/cache(.*)$" . PHP_EOL . "(.*)error_log$" );
151
+		if (!get_option('xcloner_regex_exclude')) {
152
+			update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$");
153 153
 		}
154 154
 
155
-		if ( ! get_option( 'xcloner_regex_exclude' ) ) {
156
-			update_option( 'xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$" . PHP_EOL . "(.*)\.(svn|git)(.*)$" . PHP_EOL . "wp-content\/cache(.*)$" . PHP_EOL . "(.*)error_log$" );
155
+		if (!get_option('xcloner_regex_exclude')) {
156
+			update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$");
157 157
 		}
158 158
 
159 159
 	}
Please login to merge, or discard this patch.
includes/class-xcloner-i18n.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 		load_plugin_textdomain(
53 53
 			'xcloner-backup-and-restore',
54 54
 			false,
55
-			dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
55
+			dirname(dirname(plugin_basename(__FILE__))).'/languages/'
56 56
 		);
57 57
 
58 58
 	}
Please login to merge, or discard this patch.
includes/class-xcloner-database.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -337,7 +337,7 @@
 block discarded – undo
337 337
 
338 338
 			$result = $this->get_var("SELECT count(*) FROM $table;");
339 339
 
340
-			return intval($result) ;// not max limit on 32 bit systems 2147483647; on 64 bit 999999999999
340
+			return intval($result); // not max limit on 32 bit systems 2147483647; on 64 bit 999999999999
341 341
 
342 342
 	}
343 343
 
Please login to merge, or discard this patch.
Braces   +71 added lines, -48 removed lines patch added patch discarded remove patch
@@ -44,11 +44,13 @@  discard block
 block discarded – undo
44 44
 		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
45 45
 		$this->fs = $xcloner_container->get_xcloner_filesystem();
46 46
 		
47
-		if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'))
48
-			$this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
47
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) {
48
+					$this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
49
+		}
49 50
 		
50
-		if (!$this->recordsPerSession)
51
-			$this->recordsPerSession = 100;
51
+		if (!$this->recordsPerSession) {
52
+					$this->recordsPerSession = 100;
53
+		}
52 54
 		
53 55
 		if (!$wp_user && !$wp_pass && !$wp_host && !$wp_db)
54 56
 		{
@@ -108,37 +110,43 @@  discard block
 block discarded – undo
108 110
 			{
109 111
 				foreach ($params['#'] as $database)
110 112
 				{
111
-					if (!isset($params[$database]) or !is_array($params[$database]))
112
-						$params[$database] = array();
113
+					if (!isset($params[$database]) or !is_array($params[$database])) {
114
+											$params[$database] = array();
115
+					}
113 116
 				}
114 117
 				$db_count = -1;
115 118
 			}
116 119
 			
117
-			if (isset($params) and is_array($params))
118
-				foreach ($params as $database=>$tables)
120
+			if (isset($params) and is_array($params)) {
121
+							foreach ($params as $database=>$tables)
119 122
 				{	
120 123
 					if ($database != "#")
121 124
 					{
122
-						$stats = $this->write_backup_process_list($database, $tables);	
125
+						$stats = $this->write_backup_process_list($database, $tables);
126
+			}
123 127
 						$return['stats']['tables_count'] += $stats['tables_count'];
124 128
 						$return['stats']['total_records'] += $stats['total_records'];
125 129
 					}
126 130
 				}
127 131
 
128
-			if (sizeof($params))
129
-				$return['stats']['database_count'] = sizeof($params) + $db_count;
130
-			else	
131
-				$return['stats']['database_count'] = 0;
132
+			if (sizeof($params)) {
133
+							$return['stats']['database_count'] = sizeof($params) + $db_count;
134
+			} else {
135
+							$return['stats']['database_count'] = 0;
136
+			}
132 137
 				
133 138
 			return $return;
134 139
 		}
135 140
 		
136
-		if (!isset($extra_params['startAtLine']))
137
-			$extra_params['startAtLine'] = 0;
138
-		if (!isset($extra_params['startAtRecord']))
139
-			$extra_params['startAtRecord'] = 0;
140
-		if (!isset($extra_params['dumpfile']))
141
-			$extra_params['dumpfile'] = "";
141
+		if (!isset($extra_params['startAtLine'])) {
142
+					$extra_params['startAtLine'] = 0;
143
+		}
144
+		if (!isset($extra_params['startAtRecord'])) {
145
+					$extra_params['startAtRecord'] = 0;
146
+		}
147
+		if (!isset($extra_params['dumpfile'])) {
148
+					$extra_params['dumpfile'] = "";
149
+		}
142 150
 		
143 151
 		$return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']);
144 152
 		
@@ -151,10 +159,12 @@  discard block
 block discarded – undo
151 159
 		if ($message) {
152 160
 			$this->logger->info($message, array(""));
153 161
 		} else {	
154
-			if ($this->last_query)
155
-				$this->logger->debug($this->last_query, array(""));
156
-			if ($this->last_error)
157
-				$this->logger->error($this->last_error, array(""));
162
+			if ($this->last_query) {
163
+							$this->logger->debug($this->last_query, array(""));
164
+			}
165
+			if ($this->last_error) {
166
+							$this->logger->error($this->last_error, array(""));
167
+			}
158 168
 		}
159 169
 		
160 170
 		return;
@@ -225,11 +235,12 @@  discard block
 block discarded – undo
225 235
 		$databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname);
226 236
 		$i++;
227 237
 		
228
-		if (is_array($databases))
229
-		foreach ($databases as $db) {
238
+		if (is_array($databases)) {
239
+				foreach ($databases as $db) {
230 240
 			if ($db->Database != $this->dbname)
231 241
 			{
232 242
 				$databases_list[$i]['name'] = $db->Database;
243
+		}
233 244
 				$databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database);
234 245
 				$i++;
235 246
 			}
@@ -252,8 +263,9 @@  discard block
 block discarded – undo
252 263
 		$tablesList[0] = array( );
253 264
 		$inc = 0;
254 265
 
255
-		if (!$database)
256
-			$database = $this->dbname;
266
+		if (!$database) {
267
+					$database = $this->dbname;
268
+		}
257 269
 		
258 270
 		$this->logger->debug(sprintf(("Listing tables in %s database"), $database));
259 271
 		
@@ -277,10 +289,11 @@  discard block
 block discarded – undo
277 289
 			
278 290
 			$tablesList[$inc]['excluded'] = 0;
279 291
 						
280
-			if (sizeof($included) and is_array($included))
281
-				if (!in_array($table, $included))
292
+			if (sizeof($included) and is_array($included)) {
293
+							if (!in_array($table, $included))
282 294
 				{
283 295
 					$tablesList[$inc]['excluded'] = 1;
296
+			}
284 297
 					$this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database));
285 298
 				}
286 299
 			$inc++;
@@ -299,19 +312,21 @@  discard block
 block discarded – undo
299 312
 		
300 313
 		$tables = $this->list_tables($dbname, $incl_tables, 1);
301 314
 		
302
-		if ($this->dbname != $dbname)
303
-			$dumpfile = $dbname."-backup.sql";
304
-		else
305
-			$dumpfile = $this->TEMP_DUMP_FILE;
315
+		if ($this->dbname != $dbname) {
316
+					$dumpfile = $dbname."-backup.sql";
317
+		} else {
318
+					$dumpfile = $this->TEMP_DUMP_FILE;
319
+		}
306 320
 		
307 321
 		$line = sprintf("###newdump###\t%s\t%s\n", $dbname, $dumpfile);
308 322
 		$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
309 323
 			
310 324
 		// write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records
311
-		foreach ($tables as $key=>$table) 
312
-		if ($table != "" and !$tables[$key]['excluded']) {
325
+		foreach ($tables as $key=>$table) {
326
+				if ($table != "" and !$tables[$key]['excluded']) {
313 327
 
314 328
 			$line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']);
329
+		}
315 330
 			$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
316 331
 			$return['tables_count']++;
317 332
 			$return['total_records'] += $tables[$key]['records'];
@@ -359,8 +374,9 @@  discard block
 block discarded – undo
359 374
 		$return['finished'] = 0;
360 375
 		$lines = array();
361 376
 		
362
-		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
363
-			$lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
377
+		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
378
+					$lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
379
+		}
364 380
 	
365 381
 		foreach ($lines as $buffer) {
366 382
 			
@@ -387,12 +403,14 @@  discard block
 block discarded – undo
387 403
 						//break;
388 404
 				} else {
389 405
 						//we export the table
390
-						if ($tableInfo[0] == "###enddump###")
391
-							$return['endDump'] = 1;
406
+						if ($tableInfo[0] == "###enddump###") {
407
+													$return['endDump'] = 1;
408
+						}
392 409
 	
393 410
 						//table is excluded
394
-						if ($tableInfo[2])
395
-							continue;
411
+						if ($tableInfo[2]) {
412
+													continue;
413
+						}
396 414
 							
397 415
 						$next = $startAtRecord + $this->recordsPerSession;
398 416
 						
@@ -408,14 +426,17 @@  discard block
 block discarded – undo
408 426
 
409 427
 						$processed_records = 0;
410 428
 						
411
-						if (trim($tableName) != "" and !$tableInfo[2])
412
-							$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
429
+						if (trim($tableName) != "" and !$tableInfo[2]) {
430
+													$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
431
+						}
413 432
 						
414 433
 						$return['processedRecords'] = $startAtRecord + $processed_records;
415 434
 						
416
-						if ($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record
435
+						if ($next >= $tableInfo[1]) {
436
+							//we finished loading the records for next sessions, will go to the new record
417 437
 						{
418 438
 								$startAtLine++;
439
+						}
419 440
 								$startAtRecord = 0;
420 441
 						} else {
421 442
 								$startAtRecord = $startAtRecord + $this->recordsPerSession;
@@ -450,8 +471,9 @@  discard block
 block discarded – undo
450 471
 		$return['finished'] = 1;
451 472
 		$return['startAtLine'] = $startAtLine;
452 473
 		
453
-		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
454
-			$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
474
+		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
475
+					$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
476
+		}
455 477
 		
456 478
 		$this->logger->debug(sprintf(("Database backup finished!")));
457 479
 		
@@ -484,8 +506,9 @@  discard block
 block discarded – undo
484 506
 		
485 507
 		$records = 0;
486 508
 		
487
-		if ($start == 0)
488
-			$this->dump_structure($databaseName, $tableName, $dumpfile);
509
+		if ($start == 0) {
510
+					$this->dump_structure($databaseName, $tableName, $dumpfile);
511
+		}
489 512
 
490 513
 		$start = intval($start);
491 514
 		$limit = intval($limit);
Please login to merge, or discard this patch.
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-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.