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
Push — master ( 1a6a13...b32b6e )
by Liuta
03:37
created
includes/class-xcloner-api.php 2 patches
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use splitbrain\PHPArchive\FileInfo;
12 12
 
13 13
 
14
-class Xcloner_Api{
14
+class Xcloner_Api {
15 15
 
16 16
 	private $xcloner_database;
17 17
 	private $xcloner_settings;
@@ -27,33 +27,33 @@  discard block
 block discarded – undo
27 27
 		global $wpdb;
28 28
 		
29 29
 		error_reporting(0);
30
-		if( ob_get_length() )
30
+		if (ob_get_length())
31 31
 			ob_end_clean();
32 32
 		ob_start();
33 33
 		
34
-		$wpdb->show_errors		= false;
34
+		$wpdb->show_errors = false;
35 35
 		
36
-		$this->xcloner_settings 		= new Xcloner_Settings();
36
+		$this->xcloner_settings = new Xcloner_Settings();
37 37
 		
38 38
 		//generating the hash suffix for tmp xcloner store folder
39
-		if(isset($_POST['hash'])){
39
+		if (isset($_POST['hash'])) {
40 40
 			
41
-			if($_POST['hash'] == "generate_hash")
41
+			if ($_POST['hash'] == "generate_hash")
42 42
 				$this->xcloner_settings->generate_new_hash();
43 43
 			else
44 44
 				$this->xcloner_settings->set_hash($_POST['hash']);
45 45
 		}
46 46
 
47
-		$this->logger 					= new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash());
47
+		$this->logger = new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash());
48 48
 		$this->xcloner_file_system 		= new Xcloner_File_System($this->xcloner_settings->get_hash());
49 49
 		$this->xcloner_sanitization 	= new Xcloner_Sanitization();
50 50
 		$this->xcloner_requirements 	= new XCloner_Requirements();
51
-		$this->archive_system 			= new Xcloner_Archive($this->xcloner_settings->get_hash());
52
-		$this->xcloner_database 		= new XCloner_Database($this->xcloner_settings->get_hash());
51
+		$this->archive_system = new Xcloner_Archive($this->xcloner_settings->get_hash());
52
+		$this->xcloner_database = new XCloner_Database($this->xcloner_settings->get_hash());
53 53
 		
54 54
 		
55
-		if(isset($_POST['API_ID'])){
56
-			$this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0 , 15));
55
+		if (isset($_POST['API_ID'])) {
56
+			$this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0, 15));
57 57
 		}
58 58
 		
59 59
 	}
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
 		$data['dbDatabase'] = $this->xcloner_settings->get_db_database();
70 70
 		
71 71
 		
72
-		$data['recordsPerSession'] 		= $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
73
-		$data['TEMP_DBPROCESS_FILE'] 	= $this->xcloner_settings->get_xcloner_tmp_path().DS.".database";
74
-		$data['TEMP_DUMP_FILE'] 		= $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql";
72
+		$data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
73
+		$data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS.".database";
74
+		$data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql";
75 75
 		
76 76
 		try
77 77
 		{
78 78
 			//$xcloner_db = new XCloner_Database($data['dbUsername'], $data['dbPassword'], $data['dbDatabase'], $data['dbHostname']);
79 79
 			$this->xcloner_database->init($data);
80 80
 
81
-		}catch(Exception $e)
81
+		}catch (Exception $e)
82 82
 		{
83 83
 			$this->send_response($e->getMessage());
84 84
 			$this->logger->error($e->getMessage());
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 		$schedule = array();
108 108
 		$response = array();
109 109
 		
110
-		if(isset($_POST['data']))
110
+		if (isset($_POST['data']))
111 111
 			$params = json_decode(stripslashes($_POST['data']));
112 112
 		
113 113
 		$this->process_params($params);
114 114
 		
115
-		if(isset($_POST['id']))
115
+		if (isset($_POST['id']))
116 116
 		{
117 117
 			
118 118
 			$this->form_params['backup_params']['backup_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_name']);
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 			$tables = explode(PHP_EOL, $this->form_params['database']);
128 128
 			$return = array();
129 129
 			
130
-			foreach($tables as $table)
130
+			foreach ($tables as $table)
131 131
 			{
132
-					$table = str_replace("\r","", $table);
132
+					$table = str_replace("\r", "", $table);
133 133
 					$data = explode(".", $table);
134
-					if(isset($data[1]))
134
+					if (isset($data[1]))
135 135
 						$return[$data[0]][] = $data[1];
136 136
 			}
137 137
 			
@@ -140,29 +140,29 @@  discard block
 block discarded – undo
140 140
 			$excluded_files = explode(PHP_EOL, $this->form_params['excluded_files']);
141 141
 			$return = array();
142 142
 			
143
-			foreach($excluded_files as $file)
143
+			foreach ($excluded_files as $file)
144 144
 			{
145
-				$file = str_replace("\r","", $file);
146
-				if($file)
145
+				$file = str_replace("\r", "", $file);
146
+				if ($file)
147 147
 					$return[] = $file;
148 148
 			}
149 149
 			
150 150
 			$this->form_params['excluded_files'] = ($return);
151 151
 			
152
-			$schedule['start_at'] = $this->form_params['backup_params']['start_at'] ;
152
+			$schedule['start_at'] = $this->form_params['backup_params']['start_at'];
153 153
 			
154
-			if(!isset($_POST['status']))
154
+			if (!isset($_POST['status']))
155 155
 				$schedule['status'] = 0;
156 156
 			else	
157 157
 				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
158
-		}else{
158
+		} else {
159 159
 		
160 160
 			$schedule['status'] = 1;
161
-			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
161
+			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'].
162 162
 								" ".$this->form_params['backup_params']['schedule_start_time']);
163 163
 		}
164 164
 		
165
-		if(!$schedule['start_at'])						
165
+		if (!$schedule['start_at'])						
166 166
 			$schedule['start_at'] = time();
167 167
 		
168 168
 		$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at']);	
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		
174 174
 		$schedule['params'] = json_encode($this->form_params);
175 175
 		
176
-		if(!isset($_POST['id']))
176
+		if (!isset($_POST['id']))
177 177
 		{
178 178
 			$wpdb->insert( 
179 179
 				$wpdb->prefix.'xcloner_scheduler', 
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 					'%s' 
184 184
 				) 
185 185
 			);
186
-		}else		{
186
+		} else {
187 187
 			$wpdb->update( 
188 188
 				$wpdb->prefix.'xcloner_scheduler', 
189 189
 				$schedule, 
190
-				array( 'id' => $_POST['id'] ), 
190
+				array('id' => $_POST['id']), 
191 191
 				array( 
192 192
 					'%s', 
193 193
 					'%s' 
194 194
 				) 
195 195
 			);
196 196
 		}
197
-		if(isset($_POST['id']))
197
+		if (isset($_POST['id']))
198 198
 			$scheduler->update_cron_hook($_POST['id']);
199 199
 			
200
-		if( $wpdb->last_error ) {
200
+		if ($wpdb->last_error) {
201 201
             $response['error'] = 1;
202 202
             $response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/;
203 203
             
@@ -222,19 +222,19 @@  discard block
 block discarded – undo
222 222
 		
223 223
 		$params = json_decode(stripslashes($_POST['data']));
224 224
 		
225
-		$init 	= (int)$_POST['init'];
225
+		$init = (int)$_POST['init'];
226 226
 		
227
-		if($params === NULL)
228
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
227
+		if ($params === NULL)
228
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
229 229
 			 
230 230
 		$this->process_params($params);
231 231
 		
232 232
 		$return['finished'] = 1;
233 233
 
234 234
 		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
235
-		try{
235
+		try {
236 236
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
237
-		}catch(Exception $e)
237
+		}catch (Exception $e)
238 238
 		{
239 239
 			$return = array();
240 240
 			$return['error'] = true;
@@ -243,25 +243,25 @@  discard block
 block discarded – undo
243 243
 			return $this->send_response($return, $hash = 1);
244 244
 		}
245 245
 		
246
-		if($return['finished'])
246
+		if ($return['finished'])
247 247
 		{
248 248
 			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
249
-			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
249
+			if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
250 250
 				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
251 251
 		}
252 252
 		
253 253
 		$data = $return;
254 254
 		
255 255
 		//check if backup is finished
256
-		if($return['finished'] )
256
+		if ($return['finished'])
257 257
 		{
258
-			if(isset($this->form_params['backup_params']['email_notification']) and $to=$this->form_params['backup_params']['email_notification'])
258
+			if (isset($this->form_params['backup_params']['email_notification']) and $to = $this->form_params['backup_params']['email_notification'])
259 259
 			{
260
-				try{
260
+				try {
261 261
 					$from = "";
262 262
 					$subject = "";
263 263
 					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params);
264
-				}catch(Exception $e)
264
+				}catch (Exception $e)
265 265
 				{
266 266
 					$this->logger->error($e->getMessage());
267 267
 				}
@@ -285,17 +285,17 @@  discard block
 block discarded – undo
285 285
 		
286 286
 		$params = json_decode(stripslashes($_POST['data']));
287 287
 		
288
-		$init 	= (int)$_POST['init'];
288
+		$init = (int)$_POST['init'];
289 289
 		
290
-		if($params === NULL)
291
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
290
+		if ($params === NULL)
291
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
292 292
 		
293 293
 		$this->process_params($params);
294 294
 			
295 295
 		//$xcloner_database = $this->init_db();	
296 296
 		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init);
297 297
 		
298
-		if(isset($return['error']) and $return['error'])
298
+		if (isset($return['error']) and $return['error'])
299 299
 			$data['finished'] = 1;
300 300
 		else	
301 301
 			$data['finished'] = $return['finished'];
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 		}
318 318
 		
319 319
 		$params = json_decode(stripslashes($_POST['data']));
320
-		$init 	= (int)$_POST['init'];
320
+		$init = (int)$_POST['init'];
321 321
 		
322
-		if($params === NULL)
323
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
322
+		if ($params === NULL)
323
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
324 324
 			 
325 325
 		$hash = $this->process_params($params);
326 326
 		
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		$data["finished"] = !$return;
332 332
 		$data["total_files_num"] = $this->xcloner_file_system->get_scanned_files_num();
333 333
 		$data["last_logged_file"] = $this->xcloner_file_system->last_logged_file();
334
-		$data["total_files_size"] = sprintf("%.2f",$this->xcloner_file_system->get_scanned_files_total_size()/(1024*1024));
334
+		$data["total_files_size"] = sprintf("%.2f", $this->xcloner_file_system->get_scanned_files_total_size() / (1024 * 1024));
335 335
 		
336 336
 		return $this->send_response($data, $hash = 1);
337 337
 	}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 */ 
344 344
 	private function process_params($params)
345 345
 	{
346
-		if(isset($params->hash))
346
+		if (isset($params->hash))
347 347
 			$this->xcloner_settings->set_hash($params->hash);
348 348
 			
349 349
 		$this->form_params['extra'] = array();
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 		
352 352
 		$this->form_params['database'] = array();
353 353
 		
354
-		if(isset($params->backup_params))
354
+		if (isset($params->backup_params))
355 355
 		{
356
-			foreach($params->backup_params as $param)
356
+			foreach ($params->backup_params as $param)
357 357
 			{
358 358
 				$this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value);
359 359
 				$this->logger->debug("Adding form parameter ".$param->name.".".$param->value."\n", array('POST', 'fields filter'));
@@ -362,28 +362,28 @@  discard block
 block discarded – undo
362 362
 		
363 363
 		$this->form_params['database'] = array();
364 364
 		
365
-		if(isset($params->table_params))
365
+		if (isset($params->table_params))
366 366
 		{
367
-			foreach($params->table_params as $param)
367
+			foreach ($params->table_params as $param)
368 368
 			{
369 369
 				$this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id);
370 370
 				$this->logger->debug("Adding database filter ".$param->parent.".".$param->id."\n", array('POST', 'database filter'));
371 371
 			}
372 372
 		}
373 373
 		
374
-		$this->form_params['excluded_files'] =  array();
375
-		if(isset($params->files_params))
374
+		$this->form_params['excluded_files'] = array();
375
+		if (isset($params->files_params))
376 376
 		{
377
-			foreach($params->files_params as $param)
377
+			foreach ($params->files_params as $param)
378 378
 			{
379 379
 				$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
380 380
 			}
381 381
 			
382 382
 			$unique_exclude_files = array();
383 383
 			
384
-			foreach($params->files_params as $key=>$param)
384
+			foreach ($params->files_params as $key=>$param)
385 385
 			{
386
-				if(!in_array($param->parent, $this->form_params['excluded_files'])){
386
+				if (!in_array($param->parent, $this->form_params['excluded_files'])) {
387 387
 				//$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
388 388
 					$unique_exclude_files[] = $param->id;
389 389
 					$this->logger->debug("Adding file filter ".$param->id."\n", array('POST', 'exclude files filter'));
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
 		
396 396
 		//$this->form_params['excluded_files'] =  array_merge($this->form_params['excluded_files'], $this->exclude_files_by_default);
397 397
 		
398
-		if(isset($params->extra))
398
+		if (isset($params->extra))
399 399
 		{
400
-			foreach($params->extra as $key=>$value)
400
+			foreach ($params->extra as $key=>$value)
401 401
 				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
402 402
 		}
403 403
 			
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 		
420 420
 		$data = array();
421 421
 		
422
-		if($folder == "#"){
422
+		if ($folder == "#") {
423 423
 			
424 424
 			$folder = "/";
425 425
 			//$list_directory = $this->xcloner_settings->get_xcloner_start_path();
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 						);
434 434
 		}
435 435
 			
436
-			try{
436
+			try {
437 437
 				$files = $this->xcloner_file_system->list_directory($folder);
438
-			}catch(Exception $e){
438
+			}catch (Exception $e) {
439 439
 				
440 440
 				print $e->getMessage();
441 441
 				$this->logger->error($e->getMessage());
@@ -450,19 +450,19 @@  discard block
 block discarded – undo
450 450
 			}
451 451
 			array_multisort($type, SORT_ASC, $files);
452 452
 			
453
-			foreach($files as $file)
453
+			foreach ($files as $file)
454 454
 			{
455 455
 				$children = false;
456 456
 				$text = $file['basename'];
457 457
 				
458
-				if($file['type'] == "dir")
458
+				if ($file['type'] == "dir")
459 459
 					$children = true;
460 460
 				else
461
-					 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
461
+					 $text .= " (".$this->xcloner_requirements->file_format_size($file['size']).")";
462 462
 				
463 463
 				//if(in_array($file['path'], $this->xcloner_file_system->get_excluded_files()))
464 464
 				//echo $file['path']."--".$this->xcloner_file_system->is_excluded($file);
465
-				if($this->xcloner_file_system->is_excluded($file))
465
+				if ($this->xcloner_file_system->is_excluded($file))
466 466
 					$selected = true;
467 467
 				else
468 468
 					$selected = false;
@@ -499,25 +499,25 @@  discard block
 block discarded – undo
499 499
 		
500 500
 		$xcloner_backup_only_wp_tables = $this->xcloner_settings->get_xcloner_option('xcloner_backup_only_wp_tables');
501 501
 	
502
-		if($database == "#")
502
+		if ($database == "#")
503 503
 		{
504
-			try{
504
+			try {
505 505
 				$return = $this->xcloner_database->get_all_databases();
506
-			}catch(Exception $e){
506
+			}catch (Exception $e) {
507 507
 				$this->logger->error($e->getMessage());
508 508
 			}
509 509
 			
510
-			foreach($return as $database)
510
+			foreach ($return as $database)
511 511
 			{
512
-				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
512
+				if ($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
513 513
 					continue;
514 514
 					
515 515
 				$state = array();
516 516
 				
517
-				if($database['name'] == $this->xcloner_settings->get_db_database())
517
+				if ($database['name'] == $this->xcloner_settings->get_db_database())
518 518
 				{
519 519
 					$state['selected'] = true;
520
-					if($database['num_tables'] < 25)
520
+					if ($database['num_tables'] < 25)
521 521
 						$state['opened'] = false;
522 522
 				}
523 523
 					
@@ -533,22 +533,22 @@  discard block
 block discarded – undo
533 533
 			
534 534
 		}
535 535
 		
536
-		else{
536
+		else {
537 537
 			
538
-			try{
538
+			try {
539 539
 				$return = $this->xcloner_database->list_tables($database, "", 1);
540
-			}catch(Exception $e){
540
+			}catch (Exception $e) {
541 541
 				$this->logger->error($e->getMessage());
542 542
 			}
543 543
 			
544
-			foreach($return as $table)
544
+			foreach ($return as $table)
545 545
 			{
546 546
 				$state = array();
547 547
 				
548
-				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
548
+				if ($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
549 549
 					continue;
550 550
 				
551
-				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
551
+				if (isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
552 552
 					$state = array('selected' => true);
553 553
 					
554 554
 				$data[] = array(
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 		
579 579
 		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
580 580
 		$scheduler = new Xcloner_Scheduler();
581
-		$data  = $scheduler->get_schedule_by_id($schedule_id);
581
+		$data = $scheduler->get_schedule_by_id($schedule_id);
582 582
 		
583 583
 		return $this->send_response($data);
584 584
 	}
@@ -595,14 +595,14 @@  discard block
 block discarded – undo
595 595
 		}
596 596
 		
597 597
 		$scheduler = new Xcloner_Scheduler();
598
-		$data  = $scheduler->get_scheduler_list();
598
+		$data = $scheduler->get_scheduler_list();
599 599
 		$return['data'] = array();
600 600
 		
601
-		foreach($data as $res)
601
+		foreach ($data as $res)
602 602
 		{
603 603
 			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> 
604 604
 					<a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
605
-			if($res->status)
605
+			if ($res->status)
606 606
 				$status = '<i class="material-icons active status">timer</i>';
607 607
 			else
608 608
 				$status = '<i class="material-icons status inactive">timer_off</i>';
@@ -613,14 +613,14 @@  discard block
 block discarded – undo
613 613
 			
614 614
 			$remote_storage = $res->remote_storage;
615 615
 			
616
-			if(!$next_run_time >= time())
616
+			if (!$next_run_time >= time())
617 617
 				$next_run = " ";
618 618
 			
619
-			if(trim($next_run))
619
+			if (trim($next_run))
620 620
 			{
621 621
 				$date_text = $next_run;
622 622
 				
623
-				if($next_run_time >= time())
623
+				if ($next_run_time >= time())
624 624
 					$next_run = "in ".human_time_diff($next_run_time, time());
625 625
 				else
626 626
 					$next_run = __("executed", 'xcloner-backup-and-restore');
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
 			$backup_size = "";
634 634
 			$backup_time = "";
635 635
 			
636
-			if($res->last_backup)
636
+			if ($res->last_backup)
637 637
 			{
638
-				if( $this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup))
638
+				if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup))
639 639
 				{
640 640
 					$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup);
641 641
 					$backup_size  = size_format($metadata['size']);
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 				$backup_text = "<span title='".$backup_time."' class='shorten_string'>".$res->last_backup." (".$backup_size.")</span>";
646 646
 			}
647 647
 				
648
-			$return['data'][] = array($res->id, $res->name, $res->recurrence,/*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action);
648
+			$return['data'][] = array($res->id, $res->name, $res->recurrence, /*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action);
649 649
 		}
650 650
 		
651 651
 		return $this->send_response($return, 0);
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		
665 665
 		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
666 666
 		$scheduler = new Xcloner_Scheduler();
667
-		$data['finished']  = $scheduler->delete_schedule_by_id($schedule_id);
667
+		$data['finished'] = $scheduler->delete_schedule_by_id($schedule_id);
668 668
 		
669 669
 		return $this->send_response($data);
670 670
 	}
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 		
683 683
 		$backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_POST['name']);
684 684
 		
685
-		$data['finished']  = $this->xcloner_file_system->delete_backup_by_name($backup_name);
685
+		$data['finished'] = $this->xcloner_file_system->delete_backup_by_name($backup_name);
686 686
 		
687 687
 		return $this->send_response($data);
688 688
 	}
@@ -701,32 +701,32 @@  discard block
 block discarded – undo
701 701
 		
702 702
 		$backup_file = $source_backup_file;
703 703
 		
704
-		if($this->xcloner_file_system->is_multipart($backup_file))
704
+		if ($this->xcloner_file_system->is_multipart($backup_file))
705 705
 		{
706 706
 			$backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
707 707
 			$backup_file = $backup_parts[$return['part']];
708 708
 		}
709 709
 		
710
-		try{
710
+		try {
711 711
 			$tar = new Tar();
712 712
 			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
713 713
 		
714 714
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
715
-		}catch(Exception $e)
715
+		}catch (Exception $e)
716 716
 		{
717 717
 			$return['error'] = true;
718 718
 			$return['message'] = $e->getMessage();
719 719
 			$this->send_response($return, 0);
720 720
 		}
721 721
 		
722
-		$return['files'] 		= array();
723
-		$return['finished'] 	= 1;
724
-		$return['total_size'] 	= filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
722
+		$return['files'] = array();
723
+		$return['finished'] = 1;
724
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
725 725
 		$i = 0;
726 726
 		
727
-		if(isset($data['extracted_files']) and is_array($data['extracted_files']))
727
+		if (isset($data['extracted_files']) and is_array($data['extracted_files']))
728 728
 		{
729
-			foreach($data['extracted_files'] as $file)
729
+			foreach ($data['extracted_files'] as $file)
730 730
 			{
731 731
 				$return['files'][$i]['path'] = $file->getPath();
732 732
 				$return['files'][$i]['size'] = $file->getSize();
@@ -736,18 +736,18 @@  discard block
 block discarded – undo
736 736
 			}
737 737
 		}
738 738
 		
739
-		if(isset($data['start']))
739
+		if (isset($data['start']))
740 740
 		{
741 741
 			$return['start'] = $data['start'];
742 742
 			$return['finished'] = 0;	
743
-		}else{
744
-			if($this->xcloner_file_system->is_multipart($source_backup_file))
743
+		} else {
744
+			if ($this->xcloner_file_system->is_multipart($source_backup_file))
745 745
 			{
746 746
 				$return['start'] = 0;
747 747
 				
748 748
 				++$return['part'];
749 749
 			
750
-				if($return['part'] < sizeof($backup_parts))	
750
+				if ($return['part'] < sizeof($backup_parts))	
751 751
 					$return['finished'] = 0;
752 752
 				
753 753
 			}
@@ -776,17 +776,17 @@  discard block
 block discarded – undo
776 776
 		
777 777
 		try
778 778
 		{
779
-			if(method_exists($xcloner_remote_storage, "upload_backup_to_storage"))
779
+			if (method_exists($xcloner_remote_storage, "upload_backup_to_storage"))
780 780
 			{
781 781
 				$return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type));
782 782
 			}
783
-		}catch(Exception $e){
783
+		}catch (Exception $e) {
784 784
 		
785 785
 			$return['error'] = 1;
786 786
 			$return['message'] = $e->getMessage();
787 787
 		}
788 788
 		
789
-		if(!$return)
789
+		if (!$return)
790 790
 		{
791 791
 			$return['error'] = 1;
792 792
 			$return['message'] = "Upload failed, please check the error log for more information!";
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		
825 825
 		@ob_end_clean();
826 826
 		
827
-		$adapter = new Local(dirname(__DIR__) ,LOCK_EX, 'SKIP_LINKS');
827
+		$adapter = new Local(dirname(__DIR__), LOCK_EX, 'SKIP_LINKS');
828 828
 		$xcloner_plugin_filesystem = new Filesystem($adapter, new Config([
829 829
 				'disable_asserts' => true,
830 830
 			]));
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		//$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz");
839 839
 		
840 840
 		$files = $xcloner_plugin_filesystem->listContents("vendor/", true);
841
-		foreach($files as $file)
841
+		foreach ($files as $file)
842 842
 		{
843 843
 			$tar->addFile(dirname(__DIR__).DS.$file['path'], $file['path']);
844 844
 		}
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 		    header('Expires: 0');
858 858
 		    header('Cache-Control: must-revalidate');
859 859
 		    header('Pragma: public');
860
-		    header('Content-Length: ' . filesize($tmp_file));
860
+		    header('Content-Length: '.filesize($tmp_file));
861 861
 		    readfile($tmp_file);
862 862
 		    
863 863
 		}
@@ -882,9 +882,9 @@  discard block
 block discarded – undo
882 882
 		$backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_GET['name']);
883 883
 		
884 884
 		
885
-		$metadata  = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
885
+		$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
886 886
 		//$mimetype  = $this->xcloner_file_system->get_storage_filesystem()->getMimetype($backup_name);
887
-		$read_stream  = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
887
+		$read_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
888 888
 		
889 889
 		
890 890
 		header('Pragma: public');
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 	    header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
896 896
 	    //header('Content-Type: ' . $mimetype);
897 897
 	    header('Content-Type: application/octet-stream');
898
-	    header('Content-Length: ' . $metadata['size']);
898
+	    header('Content-Length: '.$metadata['size']);
899 899
 	    
900 900
 	    @ob_end_clean();
901 901
 	    
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
 		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
926 926
 		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
927 927
 		
928
-		if(isset($_POST['part']))
928
+		if (isset($_POST['part']))
929 929
 			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
930 930
 		
931
-		if(isset($_POST['uploaded_size']))
931
+		if (isset($_POST['uploaded_size']))
932 932
 			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
933 933
 		
934 934
 		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
@@ -936,46 +936,46 @@  discard block
 block discarded – undo
936 936
 		
937 937
 		$return['total_size'] = $this->xcloner_file_system->get_backup_size($file);
938 938
 		
939
-		if($this->xcloner_file_system->is_multipart($file))
939
+		if ($this->xcloner_file_system->is_multipart($file))
940 940
 		{
941 941
 			$backup_parts = $this->xcloner_file_system->get_multipart_files($file);
942 942
 			
943
-			$return['total_parts'] = sizeof($backup_parts)+1;
943
+			$return['total_parts'] = sizeof($backup_parts) + 1;
944 944
 			
945
-			if($return['part'] and isset($backup_parts[$return['part']-1]))
945
+			if ($return['part'] and isset($backup_parts[$return['part'] - 1]))
946 946
 			{
947
-				$file = $backup_parts[$return['part']-1];
947
+				$file = $backup_parts[$return['part'] - 1];
948 948
 			}
949 949
 			
950 950
 			$is_multipart = 1;	
951 951
 		}
952 952
 		
953
-		try{
953
+		try {
954 954
 		
955 955
 			$xcloner_file_transfer = new Xcloner_File_Transfer();
956 956
 			$xcloner_file_transfer->set_target($target_url);
957 957
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
958 958
 		
959
-		}catch(Exception $e){
959
+		}catch (Exception $e) {
960 960
 		
961 961
 			$return = array();
962 962
 			$return['error'] = true;
963 963
 			$return['status'] = 500;
964 964
 			$return['message'] = "CURL communication error with the restore host. ".$e->getMessage();
965
-			$this->send_response( $return, 0);
965
+			$this->send_response($return, 0);
966 966
 		
967 967
 		}
968 968
 		
969 969
 		$return['status'] = 200;
970 970
 		
971 971
 		//we have finished the upload
972
-		if(!$return['start'] and $is_multipart)
972
+		if (!$return['start'] and $is_multipart)
973 973
 		{
974 974
 			$return['part']++;
975 975
 			$return['uploaded_size'] += $this->xcloner_file_system->get_storage_filesystem()->getSize($file);
976 976
 		}
977 977
 		
978
-		$this->send_response( $return, 0);
978
+		$this->send_response($return, 0);
979 979
 	}
980 980
 	/*
981 981
 	 * 
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 	private function send_response($data, $attach_hash = 1)
986 986
 	{
987 987
 		
988
-		if($attach_hash and null !== $this->xcloner_settings->get_hash())
988
+		if ($attach_hash and null !== $this->xcloner_settings->get_hash())
989 989
 		{
990 990
 			$data['hash'] = $this->xcloner_settings->get_hash();
991 991
 		}
992 992
 			
993
-		if( ob_get_length() )
993
+		if (ob_get_length())
994 994
 			ob_clean();
995 995
 		wp_send_json($data);
996 996
 		
Please login to merge, or discard this patch.
Braces   +111 added lines, -85 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@  discard block
 block discarded – undo
27 27
 		global $wpdb;
28 28
 		
29 29
 		error_reporting(0);
30
-		if( ob_get_length() )
31
-			ob_end_clean();
30
+		if( ob_get_length() ) {
31
+					ob_end_clean();
32
+		}
32 33
 		ob_start();
33 34
 		
34 35
 		$wpdb->show_errors		= false;
@@ -38,10 +39,11 @@  discard block
 block discarded – undo
38 39
 		//generating the hash suffix for tmp xcloner store folder
39 40
 		if(isset($_POST['hash'])){
40 41
 			
41
-			if($_POST['hash'] == "generate_hash")
42
-				$this->xcloner_settings->generate_new_hash();
43
-			else
44
-				$this->xcloner_settings->set_hash($_POST['hash']);
42
+			if($_POST['hash'] == "generate_hash") {
43
+							$this->xcloner_settings->generate_new_hash();
44
+			} else {
45
+							$this->xcloner_settings->set_hash($_POST['hash']);
46
+			}
45 47
 		}
46 48
 
47 49
 		$this->logger 					= new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash());
@@ -78,7 +80,7 @@  discard block
 block discarded – undo
78 80
 			//$xcloner_db = new XCloner_Database($data['dbUsername'], $data['dbPassword'], $data['dbDatabase'], $data['dbHostname']);
79 81
 			$this->xcloner_database->init($data);
80 82
 
81
-		}catch(Exception $e)
83
+		} catch(Exception $e)
82 84
 		{
83 85
 			$this->send_response($e->getMessage());
84 86
 			$this->logger->error($e->getMessage());
@@ -107,8 +109,9 @@  discard block
 block discarded – undo
107 109
 		$schedule = array();
108 110
 		$response = array();
109 111
 		
110
-		if(isset($_POST['data']))
111
-			$params = json_decode(stripslashes($_POST['data']));
112
+		if(isset($_POST['data'])) {
113
+					$params = json_decode(stripslashes($_POST['data']));
114
+		}
112 115
 		
113 116
 		$this->process_params($params);
114 117
 		
@@ -131,8 +134,9 @@  discard block
 block discarded – undo
131 134
 			{
132 135
 					$table = str_replace("\r","", $table);
133 136
 					$data = explode(".", $table);
134
-					if(isset($data[1]))
135
-						$return[$data[0]][] = $data[1];
137
+					if(isset($data[1])) {
138
+											$return[$data[0]][] = $data[1];
139
+					}
136 140
 			}
137 141
 			
138 142
 			$this->form_params['database'] = ($return);
@@ -143,27 +147,30 @@  discard block
 block discarded – undo
143 147
 			foreach($excluded_files as $file)
144 148
 			{
145 149
 				$file = str_replace("\r","", $file);
146
-				if($file)
147
-					$return[] = $file;
150
+				if($file) {
151
+									$return[] = $file;
152
+				}
148 153
 			}
149 154
 			
150 155
 			$this->form_params['excluded_files'] = ($return);
151 156
 			
152 157
 			$schedule['start_at'] = $this->form_params['backup_params']['start_at'] ;
153 158
 			
154
-			if(!isset($_POST['status']))
155
-				$schedule['status'] = 0;
156
-			else	
157
-				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
158
-		}else{
159
+			if(!isset($_POST['status'])) {
160
+							$schedule['status'] = 0;
161
+			} else {
162
+							$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
163
+			}
164
+		} else{
159 165
 		
160 166
 			$schedule['status'] = 1;
161 167
 			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
162 168
 								" ".$this->form_params['backup_params']['schedule_start_time']);
163 169
 		}
164 170
 		
165
-		if(!$schedule['start_at'])						
166
-			$schedule['start_at'] = time();
171
+		if(!$schedule['start_at']) {
172
+					$schedule['start_at'] = time();
173
+		}
167 174
 		
168 175
 		$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at']);	
169 176
 		
@@ -183,7 +190,7 @@  discard block
 block discarded – undo
183 190
 					'%s' 
184 191
 				) 
185 192
 			);
186
-		}else		{
193
+		} else		{
187 194
 			$wpdb->update( 
188 195
 				$wpdb->prefix.'xcloner_scheduler', 
189 196
 				$schedule, 
@@ -194,8 +201,9 @@  discard block
 block discarded – undo
194 201
 				) 
195 202
 			);
196 203
 		}
197
-		if(isset($_POST['id']))
198
-			$scheduler->update_cron_hook($_POST['id']);
204
+		if(isset($_POST['id'])) {
205
+					$scheduler->update_cron_hook($_POST['id']);
206
+		}
199 207
 			
200 208
 		if( $wpdb->last_error ) {
201 209
             $response['error'] = 1;
@@ -224,8 +232,9 @@  discard block
 block discarded – undo
224 232
 		
225 233
 		$init 	= (int)$_POST['init'];
226 234
 		
227
-		if($params === NULL)
228
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
235
+		if($params === NULL) {
236
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
237
+		}
229 238
 			 
230 239
 		$this->process_params($params);
231 240
 		
@@ -234,7 +243,7 @@  discard block
 block discarded – undo
234 243
 		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
235 244
 		try{
236 245
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
237
-		}catch(Exception $e)
246
+		} catch(Exception $e)
238 247
 		{
239 248
 			$return = array();
240 249
 			$return['error'] = true;
@@ -246,8 +255,9 @@  discard block
 block discarded – undo
246 255
 		if($return['finished'])
247 256
 		{
248 257
 			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
249
-			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
250
-				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
258
+			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
259
+							$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
260
+			}
251 261
 		}
252 262
 		
253 263
 		$data = $return;
@@ -261,7 +271,7 @@  discard block
 block discarded – undo
261 271
 					$from = "";
262 272
 					$subject = "";
263 273
 					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params);
264
-				}catch(Exception $e)
274
+				} catch(Exception $e)
265 275
 				{
266 276
 					$this->logger->error($e->getMessage());
267 277
 				}
@@ -287,18 +297,20 @@  discard block
 block discarded – undo
287 297
 		
288 298
 		$init 	= (int)$_POST['init'];
289 299
 		
290
-		if($params === NULL)
291
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
300
+		if($params === NULL) {
301
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
302
+		}
292 303
 		
293 304
 		$this->process_params($params);
294 305
 			
295 306
 		//$xcloner_database = $this->init_db();	
296 307
 		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init);
297 308
 		
298
-		if(isset($return['error']) and $return['error'])
299
-			$data['finished'] = 1;
300
-		else	
301
-			$data['finished'] = $return['finished'];
309
+		if(isset($return['error']) and $return['error']) {
310
+					$data['finished'] = 1;
311
+		} else {
312
+					$data['finished'] = $return['finished'];
313
+		}
302 314
 			
303 315
 		$data['extra'] = $return;
304 316
 		
@@ -319,8 +331,9 @@  discard block
 block discarded – undo
319 331
 		$params = json_decode(stripslashes($_POST['data']));
320 332
 		$init 	= (int)$_POST['init'];
321 333
 		
322
-		if($params === NULL)
323
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
334
+		if($params === NULL) {
335
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
336
+		}
324 337
 			 
325 338
 		$hash = $this->process_params($params);
326 339
 		
@@ -343,8 +356,9 @@  discard block
 block discarded – undo
343 356
 	 */ 
344 357
 	private function process_params($params)
345 358
 	{
346
-		if(isset($params->hash))
347
-			$this->xcloner_settings->set_hash($params->hash);
359
+		if(isset($params->hash)) {
360
+					$this->xcloner_settings->set_hash($params->hash);
361
+		}
348 362
 			
349 363
 		$this->form_params['extra'] = array();
350 364
 		$this->form_params['backup_params'] = array();
@@ -397,8 +411,9 @@  discard block
 block discarded – undo
397 411
 		
398 412
 		if(isset($params->extra))
399 413
 		{
400
-			foreach($params->extra as $key=>$value)
401
-				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
414
+			foreach($params->extra as $key=>$value) {
415
+							$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
416
+			}
402 417
 		}
403 418
 			
404 419
 		return $this->xcloner_settings->get_hash();
@@ -435,7 +450,7 @@  discard block
 block discarded – undo
435 450
 			
436 451
 			try{
437 452
 				$files = $this->xcloner_file_system->list_directory($folder);
438
-			}catch(Exception $e){
453
+			} catch(Exception $e){
439 454
 				
440 455
 				print $e->getMessage();
441 456
 				$this->logger->error($e->getMessage());
@@ -455,17 +470,19 @@  discard block
 block discarded – undo
455 470
 				$children = false;
456 471
 				$text = $file['basename'];
457 472
 				
458
-				if($file['type'] == "dir")
459
-					$children = true;
460
-				else
461
-					 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
473
+				if($file['type'] == "dir") {
474
+									$children = true;
475
+				} else {
476
+									 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
477
+				}
462 478
 				
463 479
 				//if(in_array($file['path'], $this->xcloner_file_system->get_excluded_files()))
464 480
 				//echo $file['path']."--".$this->xcloner_file_system->is_excluded($file);
465
-				if($this->xcloner_file_system->is_excluded($file))
466
-					$selected = true;
467
-				else
468
-					$selected = false;
481
+				if($this->xcloner_file_system->is_excluded($file)) {
482
+									$selected = true;
483
+				} else {
484
+									$selected = false;
485
+				}
469 486
 					
470 487
 				$data[] = array(
471 488
 							'id' => $file['path'],
@@ -503,22 +520,24 @@  discard block
 block discarded – undo
503 520
 		{
504 521
 			try{
505 522
 				$return = $this->xcloner_database->get_all_databases();
506
-			}catch(Exception $e){
523
+			} catch(Exception $e){
507 524
 				$this->logger->error($e->getMessage());
508 525
 			}
509 526
 			
510 527
 			foreach($return as $database)
511 528
 			{
512
-				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
513
-					continue;
529
+				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) {
530
+									continue;
531
+				}
514 532
 					
515 533
 				$state = array();
516 534
 				
517 535
 				if($database['name'] == $this->xcloner_settings->get_db_database())
518 536
 				{
519 537
 					$state['selected'] = true;
520
-					if($database['num_tables'] < 25)
521
-						$state['opened'] = false;
538
+					if($database['num_tables'] < 25) {
539
+											$state['opened'] = false;
540
+					}
522 541
 				}
523 542
 					
524 543
 				$data[] = array(
@@ -531,13 +550,11 @@  discard block
 block discarded – undo
531 550
 						);
532 551
 			}
533 552
 			
534
-		}
535
-		
536
-		else{
553
+		} else{
537 554
 			
538 555
 			try{
539 556
 				$return = $this->xcloner_database->list_tables($database, "", 1);
540
-			}catch(Exception $e){
557
+			} catch(Exception $e){
541 558
 				$this->logger->error($e->getMessage());
542 559
 			}
543 560
 			
@@ -545,11 +562,13 @@  discard block
 block discarded – undo
545 562
 			{
546 563
 				$state = array();
547 564
 				
548
-				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
549
-					continue;
565
+				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix())) {
566
+									continue;
567
+				}
550 568
 				
551
-				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
552
-					$state = array('selected' => true);
569
+				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) {
570
+									$state = array('selected' => true);
571
+				}
553 572
 					
554 573
 				$data[] = array(
555 574
 						'id' => $table['name'],
@@ -602,10 +621,11 @@  discard block
 block discarded – undo
602 621
 		{
603 622
 			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> 
604 623
 					<a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
605
-			if($res->status)
606
-				$status = '<i class="material-icons active status">timer</i>';
607
-			else
608
-				$status = '<i class="material-icons status inactive">timer_off</i>';
624
+			if($res->status) {
625
+							$status = '<i class="material-icons active status">timer</i>';
626
+			} else {
627
+							$status = '<i class="material-icons status inactive">timer_off</i>';
628
+			}
609 629
 				
610 630
 			$next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id));
611 631
 				
@@ -613,17 +633,19 @@  discard block
 block discarded – undo
613 633
 			
614 634
 			$remote_storage = $res->remote_storage;
615 635
 			
616
-			if(!$next_run_time >= time())
617
-				$next_run = " ";
636
+			if(!$next_run_time >= time()) {
637
+							$next_run = " ";
638
+			}
618 639
 			
619 640
 			if(trim($next_run))
620 641
 			{
621 642
 				$date_text = $next_run;
622 643
 				
623
-				if($next_run_time >= time())
624
-					$next_run = "in ".human_time_diff($next_run_time, time());
625
-				else
626
-					$next_run = __("executed", 'xcloner-backup-and-restore');
644
+				if($next_run_time >= time()) {
645
+									$next_run = "in ".human_time_diff($next_run_time, time());
646
+				} else {
647
+									$next_run = __("executed", 'xcloner-backup-and-restore');
648
+				}
627 649
 				
628 650
 				$next_run = "<a href='#' title='".$date_text."'>".$next_run."</a>";
629 651
 				//$next_run .=" ($date_text)";	
@@ -712,7 +734,7 @@  discard block
 block discarded – undo
712 734
 			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
713 735
 		
714 736
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
715
-		}catch(Exception $e)
737
+		} catch(Exception $e)
716 738
 		{
717 739
 			$return['error'] = true;
718 740
 			$return['message'] = $e->getMessage();
@@ -740,15 +762,16 @@  discard block
 block discarded – undo
740 762
 		{
741 763
 			$return['start'] = $data['start'];
742 764
 			$return['finished'] = 0;	
743
-		}else{
765
+		} else{
744 766
 			if($this->xcloner_file_system->is_multipart($source_backup_file))
745 767
 			{
746 768
 				$return['start'] = 0;
747 769
 				
748 770
 				++$return['part'];
749 771
 			
750
-				if($return['part'] < sizeof($backup_parts))	
751
-					$return['finished'] = 0;
772
+				if($return['part'] < sizeof($backup_parts)) {
773
+									$return['finished'] = 0;
774
+				}
752 775
 				
753 776
 			}
754 777
 		}	
@@ -780,7 +803,7 @@  discard block
 block discarded – undo
780 803
 			{
781 804
 				$return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type));
782 805
 			}
783
-		}catch(Exception $e){
806
+		} catch(Exception $e){
784 807
 		
785 808
 			$return['error'] = 1;
786 809
 			$return['message'] = $e->getMessage();
@@ -925,11 +948,13 @@  discard block
 block discarded – undo
925 948
 		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
926 949
 		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
927 950
 		
928
-		if(isset($_POST['part']))
929
-			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
951
+		if(isset($_POST['part'])) {
952
+					$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
953
+		}
930 954
 		
931
-		if(isset($_POST['uploaded_size']))
932
-			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
955
+		if(isset($_POST['uploaded_size'])) {
956
+					$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
957
+		}
933 958
 		
934 959
 		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
935 960
 		$target_url = $this->xcloner_sanitization->sanitize_input_as_string($_POST['target_url']);
@@ -956,7 +981,7 @@  discard block
 block discarded – undo
956 981
 			$xcloner_file_transfer->set_target($target_url);
957 982
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
958 983
 		
959
-		}catch(Exception $e){
984
+		} catch(Exception $e){
960 985
 		
961 986
 			$return = array();
962 987
 			$return['error'] = true;
@@ -990,8 +1015,9 @@  discard block
 block discarded – undo
990 1015
 			$data['hash'] = $this->xcloner_settings->get_hash();
991 1016
 		}
992 1017
 			
993
-		if( ob_get_length() )
994
-			ob_clean();
1018
+		if( ob_get_length() ) {
1019
+					ob_clean();
1020
+		}
995 1021
 		wp_send_json($data);
996 1022
 		
997 1023
 		die();
Please login to merge, or discard this patch.