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 ( 67f878...5fe6bb )
by Liuta
07:51
created
restore/xcloner_restore.php 1 patch
Braces   +113 added lines, -87 removed lines patch added patch discarded remove patch
@@ -45,11 +45,10 @@  discard block
 block discarded – undo
45 45
 {
46 46
 	
47 47
 	require_once($file);
48
-}
49
-elseif(file_exists("vendor.phar") and extension_loaded('phar'))
48
+} elseif(file_exists("vendor.phar") and extension_loaded('phar'))
50 49
 {
51 50
 	require_once(__DIR__.DS."vendor.phar");
52
-}else{	
51
+} else{	
53 52
 	
54 53
 	$file = dirname( __FILE__ )  . DS.'vendor'.DS.'autoload.php';
55 54
 	
@@ -87,7 +86,7 @@  discard block
 block discarded – undo
87 86
 try{
88 87
 	$return = $xcloner_restore->init();
89 88
 	$xcloner_restore->send_response(200, $return);
90
-}catch(Exception $e){
89
+} catch(Exception $e){
91 90
 	$xcloner_restore->send_response(417, $e->getMessage());
92 91
 }
93 92
 
@@ -191,7 +190,7 @@  discard block
 block discarded – undo
191 190
 				$this->logger->debug(sprintf('Starting action %s', $method));
192 191
 				return call_user_func(array($this, $method));
193 192
 				
194
-			}else{
193
+			} else{
195 194
 				throw new Exception($method ." does not exists");
196 195
 				}
197 196
 		}
@@ -205,13 +204,15 @@  discard block
 block discarded – undo
205 204
 		{
206 205
 			$target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
207 206
 			
208
-			if(!$_POST['start'])
209
-				$fp = fopen($target_file, "wb+");
210
-			else
211
-				$fp = fopen($target_file, "ab+");	
207
+			if(!$_POST['start']) {
208
+							$fp = fopen($target_file, "wb+");
209
+			} else {
210
+							$fp = fopen($target_file, "ab+");
211
+			}
212 212
 			
213
-			if(!$fp)
214
-				throw new Exception("Unable to open $target_file file for writing");
213
+			if(!$fp) {
214
+							throw new Exception("Unable to open $target_file file for writing");
215
+			}
215 216
 			
216 217
 			fseek($fp, $_POST['start']);
217 218
 			
@@ -221,18 +222,20 @@  discard block
 block discarded – undo
221 222
 				
222 223
 				$blob = file_get_contents($_FILES['blob']['tmp_name']);
223 224
 				
224
-				if(!$bytes_written = fwrite($fp, $blob))
225
-					throw new Exception("Unable to write data to file $target_file");
225
+				if(!$bytes_written = fwrite($fp, $blob)) {
226
+									throw new Exception("Unable to write data to file $target_file");
227
+				}
226 228
 				
227 229
 				@unlink($_FILES['blob']['tmp_name']);
228
-			}elseif(isset($_POST['blob'])){
230
+			} elseif(isset($_POST['blob'])){
229 231
 				$this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start']));
230 232
 				
231 233
 				$blob = $_POST['blob'];
232 234
 
233
-				if(!$bytes_written = fwrite($fp, $blob))
234
-					throw new Exception("Unable to write data to file $target_file");
235
-			}else{
235
+				if(!$bytes_written = fwrite($fp, $blob)) {
236
+									throw new Exception("Unable to write data to file $target_file");
237
+				}
238
+			} else{
236 239
 				throw new Exception("Upload failed, did not receive any binary data");
237 240
 			}
238 241
 			
@@ -256,10 +259,11 @@  discard block
 block discarded – undo
256 259
 		
257 260
 		$mysqli->query("SET sql_mode='';");
258 261
 		$mysqli->query("SET foreign_key_checks = 0;");
259
-		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file'])
260
-			$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
261
-		else
262
-			$mysqli->query("SET NAMES utf8;");
262
+		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) {
263
+					$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
264
+		} else {
265
+					$mysqli->query("SET NAMES utf8;");
266
+		}
263 267
 			
264 268
 		return $mysqli;	
265 269
 	}
@@ -284,8 +288,9 @@  discard block
 block discarded – undo
284 288
 		
285 289
 		$mysql_backup_file = $remote_path.DS.$mysqldump_file;
286 290
 		
287
-		if(!file_exists($mysql_backup_file))
288
-			throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
291
+		if(!file_exists($mysql_backup_file)) {
292
+					throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
293
+		}
289 294
 		
290 295
 		
291 296
 		/*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
@@ -317,16 +322,18 @@  discard block
 block discarded – undo
317 322
 			// process the line read.
318 323
 									
319 324
 				//check if line is comment
320
-				if(substr($line, 0, 1) == "#")
321
-					continue;
325
+				if(substr($line, 0, 1) == "#") {
326
+									continue;
327
+				}
322 328
 				
323 329
 				//check if line is empty	
324
-				if($line == "\n" or trim($line) == "")
325
-					continue;
330
+				if($line == "\n" or trim($line) == "") {
331
+									continue;
332
+				}
326 333
 					
327
-				if(substr($line, strlen($line)-2, strlen($line)) == ";\n")
328
-					$query .= $line;
329
-				else{
334
+				if(substr($line, strlen($line)-2, strlen($line)) == ";\n") {
335
+									$query .= $line;
336
+				} else{
330 337
 					$query .= $line;
331 338
 					continue;
332 339
 				}
@@ -385,7 +392,7 @@  discard block
 block discarded – undo
385 392
 		if(!feof($fp))
386 393
 		{
387 394
 			$return['finished'] = 0;
388
-		}else{
395
+		} else{
389 396
 			$this->logger->info(sprintf("Mysql Import Done."));
390 397
 		}
391 398
 		
@@ -437,7 +444,7 @@  discard block
 block discarded – undo
437 444
 			$tar->open($this->backup_storage_dir.DS.$backup_file, $start);
438 445
 		
439 446
 			$data = $tar->contents($this->process_files_limit_list);
440
-		}catch(Exception $e)
447
+		} catch(Exception $e)
441 448
 		{
442 449
 			$return['error'] = true;
443 450
 			$return['message'] = $e->getMessage();
@@ -465,15 +472,16 @@  discard block
 block discarded – undo
465 472
 		{
466 473
 			$return['start'] = $data['start'];
467 474
 			$return['finished'] = 0;	
468
-		}else{
475
+		} else{
469 476
 			if($this->is_multipart($source_backup_file))
470 477
 			{
471 478
 				$return['start'] = 0;
472 479
 				
473 480
 				++$return['part'];
474 481
 			
475
-				if($return['part'] < sizeof($backup_parts))	
476
-					$return['finished'] = 0;
482
+				if($return['part'] < sizeof($backup_parts)) {
483
+									$return['finished'] = 0;
484
+				}
477 485
 				
478 486
 			}
479 487
 		}	
@@ -590,19 +598,22 @@  discard block
 block discarded – undo
590 598
 		{
591 599
 			$config = file_get_contents($wp_config);
592 600
 			preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches);
593
-			if(isset($matches[1]))
594
-				$table_prefix = $matches[1];
595
-			else
596
-				throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
601
+			if(isset($matches[1])) {
602
+							$table_prefix = $matches[1];
603
+			} else {
604
+							throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
605
+			}
606
+		} else {
607
+					throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
597 608
 		}
598
-		else
599
-			throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
600 609
 			
601
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'"))
602
-			throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
610
+		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) {
611
+					throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
612
+		}
603 613
 		
604
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'"))
605
-			throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
614
+		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) {
615
+					throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
616
+		}
606 617
 		
607 618
 		return true;
608 619
 	}
@@ -629,8 +640,9 @@  discard block
 block discarded – undo
629 640
 		
630 641
 		$this->logger->info(sprintf('Updating wp-config.php file with the new mysql details'));
631 642
 		
632
-		if(!file_put_contents($wp_config, $content))
633
-			throw new Exception("Could not write updated config data to ".$wp_config);
643
+		if(!file_put_contents($wp_config, $content)) {
644
+					throw new Exception("Could not write updated config data to ".$wp_config);
645
+		}
634 646
 		
635 647
 		chmod($wp_config, $file_perms);
636 648
 		
@@ -671,10 +683,11 @@  discard block
 block discarded – undo
671 683
 							$mysqldump_list[$file['path']]['size'] = $file['size'];
672 684
 							$mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']);
673 685
 							
674
-							if($hash and $hash == $matches[1])
675
-								$mysqldump_list[$file['path']]['selected'] = "selected";
676
-							else
677
-								$mysqldump_list[$file['path']]['selected'] = "";	
686
+							if($hash and $hash == $matches[1]) {
687
+															$mysqldump_list[$file['path']]['selected'] = "selected";
688
+							} else {
689
+															$mysqldump_list[$file['path']]['selected'] = "";
690
+							}
678 691
 						}
679 692
 					}
680 693
 				}
@@ -689,13 +702,15 @@  discard block
 block discarded – undo
689 702
 	
690 703
 	private function get_hash_from_backup($backup_file)
691 704
 	{
692
-		if(!$backup_file)
693
-			return false;
705
+		if(!$backup_file) {
706
+					return false;
707
+		}
694 708
 			
695 709
 		$result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches)	;
696 710
 		
697
-		if($result and isset($matches[1]))
698
-			return ($matches[1]);
711
+		if($result and isset($matches[1])) {
712
+					return ($matches[1]);
713
+		}
699 714
 		
700 715
 		return false;
701 716
 	}
@@ -715,10 +730,11 @@  discard block
 block discarded – undo
715 730
 			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
716 731
 			{
717 732
 				$lines = explode(PHP_EOL, $this->filesystem->read($file_info['path']));
718
-				foreach($lines as $line)
719
-					if($line)
733
+				foreach($lines as $line) {
734
+									if($line)
720 735
 					{
721 736
 						$data = str_getcsv($line);
737
+				}
722 738
 						if(is_array($data)){
723 739
 							$parents[$data[0]] = $file_info['path'];
724 740
 							$file_info['childs'][] = $data;
@@ -728,20 +744,22 @@  discard block
 block discarded – undo
728 744
 						
729 745
 			}
730 746
 			
731
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
732
-				$backup_files[$file_info['path']] = $file_info;
747
+			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) {
748
+							$backup_files[$file_info['path']] = $file_info;
749
+			}
733 750
 		}
734 751
 		
735 752
 		$new_list = array();
736 753
 		
737 754
 		foreach($backup_files as $key=>$file_info)
738 755
 		{
739
-			if(isset($parents[$file_info['path']]))
740
-				$backup_files[$key]['parent'] = $parents[$file_info['path']];
741
-			else{
756
+			if(isset($parents[$file_info['path']])) {
757
+							$backup_files[$key]['parent'] = $parents[$file_info['path']];
758
+			} else{
742 759
 				
743
-				if($local_backup_file and ($file_info['basename'] == $local_backup_file))
744
-					$file_info['selected'] = 'selected';
760
+				if($local_backup_file and ($file_info['basename'] == $local_backup_file)) {
761
+									$file_info['selected'] = 'selected';
762
+				}
745 763
 				
746 764
 				$this->logger->info(sprintf('Found %s backup file', $file_info['path']));
747 765
 					
@@ -782,8 +800,9 @@  discard block
 block discarded – undo
782 800
 		$backup_archive = new Tar();
783 801
 		if($this->is_multipart($backup_file))
784 802
 		{
785
-			if(!$return['part'])
786
-				$return['processed'] += $this->filesystem->getSize($backup_file);
803
+			if(!$return['part']) {
804
+							$return['processed'] += $this->filesystem->getSize($backup_file);
805
+			}
787 806
 				
788 807
 			$backup_parts = $this->get_multipart_files($backup_file);
789 808
 			$backup_file = $backup_parts[$return['part']];	
@@ -803,12 +822,13 @@  discard block
 block discarded – undo
803 822
 			}
804 823
 		}
805 824
 		
806
-		if(isset($data['start']))
807
-		//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
825
+		if(isset($data['start'])) {
826
+				//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
808 827
 		{
809 828
 			$return['finished'] = 0;
829
+		}
810 830
 			$return['start'] = $data['start'];
811
-		}else{
831
+		} else{
812 832
 			
813 833
 			$return['processed'] += $start;
814 834
 			
@@ -818,14 +838,16 @@  discard block
 block discarded – undo
818 838
 				
819 839
 				++$return['part'];
820 840
 			
821
-				if($return['part'] < sizeof($backup_parts))	
822
-					$return['finished'] = 0;
841
+				if($return['part'] < sizeof($backup_parts)) {
842
+									$return['finished'] = 0;
843
+				}
823 844
 				
824 845
 			}
825 846
 		}
826 847
 		
827
-		if($return['finished'])
828
-			$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
848
+		if($return['finished']) {
849
+					$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
850
+		}
829 851
 		
830 852
 		$return['backup_file'] = $backup_file;
831 853
 		
@@ -854,8 +876,7 @@  discard block
 block discarded – undo
854 876
 			$return['remote_mysql_user'] 	= $wpdb->dbuser;
855 877
 			$return['remote_mysql_pass'] 	= $wpdb->dbpassword;
856 878
 			$return['remote_mysql_db'] 		= $wpdb->dbname;
857
-		}
858
-		else{
879
+		} else{
859 880
 			$return['dir'] = ($pathinfo['dirname']).DS.$suffix;
860 881
 			$return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix;
861 882
 		}	
@@ -869,11 +890,13 @@  discard block
 block discarded – undo
869 890
 	{
870 891
 		//check if i can write
871 892
 		$tmp_file = md5(time());
872
-		if(!file_put_contents($tmp_file, "++"))
873
-			throw new Exception("Could not write to new host");
893
+		if(!file_put_contents($tmp_file, "++")) {
894
+					throw new Exception("Could not write to new host");
895
+		}
874 896
 		
875
-		if(!unlink($tmp_file))
876
-			throw new Exception("Could not delete temporary file from new host");
897
+		if(!unlink($tmp_file)) {
898
+					throw new Exception("Could not delete temporary file from new host");
899
+		}
877 900
 		
878 901
 		$max_upload      = $this->return_bytes((ini_get('upload_max_filesize')));
879 902
 		$max_post        = $this->return_bytes((ini_get('post_max_size')));
@@ -904,8 +927,9 @@  discard block
 block discarded – undo
904 927
 	
905 928
 	public function is_multipart($backup_name)
906 929
 	{
907
-		if(stristr($backup_name, "-multipart"))
908
-			return true;
930
+		if(stristr($backup_name, "-multipart")) {
931
+					return true;
932
+		}
909 933
 		
910 934
 		return false;	
911 935
 	}
@@ -916,8 +940,9 @@  discard block
 block discarded – undo
916 940
 		if($this->is_multipart($backup_name))
917 941
 		{
918 942
 			$backup_parts = $this->get_multipart_files($backup_name);
919
-			foreach($backup_parts as $part_file)
920
-				$backup_size += $this->filesystem->getSize($part_file);
943
+			foreach($backup_parts as $part_file) {
944
+							$backup_size += $this->filesystem->getSize($part_file);
945
+			}
921 946
 		}
922 947
 		
923 948
 		return $backup_size;
@@ -974,7 +999,7 @@  discard block
 block discarded – undo
974 999
 		{
975 1000
 			$return['statusText'] = $response['message'];
976 1001
 			$return['error'] = true;
977
-		}elseif($status != 200 and $status != 418)
1002
+		} elseif($status != 200 and $status != 418)
978 1003
 		{
979 1004
 			$return['error'] = true;
980 1005
 			$return['message'] = $response;
@@ -995,8 +1020,9 @@  discard block
 block discarded – undo
995 1020
 		return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) {
996 1021
 				  $data = "";
997 1022
 				  	
998
-				  if(!isset($m[3]))
999
-					$m[3] = "";
1023
+				  if(!isset($m[3])) {
1024
+				  					$m[3] = "";
1025
+				  }
1000 1026
 					
1001 1027
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
1002 1028
 	              //return $this->unescape_quotes($data);
@@ -1025,7 +1051,7 @@  discard block
 block discarded – undo
1025 1051
 		    stristr($s, ':' ) != false
1026 1052
 		    ){
1027 1053
 		    return true;
1028
-		}else{
1054
+		} else{
1029 1055
 		    return false;
1030 1056
 		}
1031 1057
 
Please login to merge, or discard this patch.
includes/class-xcloner.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 			
351 351
 			if(defined('DOING_CRON') || $_POST['hash'] == "generate_hash"){
352 352
 				$this->xcloner_settings->generate_new_hash();
353
-			}else{
353
+			} else{
354 354
 				$this->xcloner_settings->set_hash($_POST['hash']);
355 355
 			}
356 356
 		}
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		
453 453
 		try{
454 454
 			$this->xcloner_scheduler->xcloner_scheduler_callback(0, $schedule);
455
-		}catch(Exception $e){
455
+		} catch(Exception $e){
456 456
 			$this->get_xcloner_logger()->error($e->getMessage());
457 457
 		}
458 458
 	
Please login to merge, or discard this patch.
includes/class-xcloner-database.php 1 patch
Braces   +75 added lines, -52 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
 		
@@ -150,11 +158,13 @@  discard block
 block discarded – undo
150 158
 		
151 159
 		if($message){
152 160
 			$this->logger->info( $message, array(""));
153
-		}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(""));
161
+		} else{	
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
 			
@@ -385,14 +401,16 @@  discard block
 block discarded – undo
385 401
 						$startAtLine++;
386 402
 						$return['new_dump'] = 1;
387 403
 						//break;
388
-				}else{
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,16 +426,19 @@  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
-						}else{
441
+						} else{
421 442
 								$startAtRecord = $startAtRecord + $this->recordsPerSession;
422 443
 							}
423 444
 
@@ -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
 		
@@ -479,8 +501,9 @@  discard block
 block discarded – undo
479 501
 		
480 502
 		$records = 0;
481 503
 		
482
-		if($start == 0)
483
-			$this->dump_structure($databaseName, $tableName, $dumpfile);
504
+		if($start == 0) {
505
+					$this->dump_structure($databaseName, $tableName, $dumpfile);
506
+		}
484 507
 
485 508
 		$start = intval($start);
486 509
 		$limit = intval($limit);
@@ -492,7 +515,7 @@  discard block
 block discarded – undo
492 515
 			$result = mysqli_query($this->dbh, $query);
493 516
 			$mysql_fetch_function = "mysqli_fetch_array";
494 517
 		
495
-		}else{
518
+		} else{
496 519
 			$result = mysql_query($query, $this->dbh);
497 520
 			$mysql_fetch_function = "mysqli_fetch_array";
498 521
 		}
Please login to merge, or discard this patch.
admin/partials/xcloner_manage_backups_page.php 1 patch
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,13 +27,16 @@  discard block
 block discarded – undo
27 27
             <?php if ($storage_selection): ?>
28 28
                 <option value=""
29 29
                         selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option>
30
-            <?php else: ?>
30
+            <?php else {
31
+	: ?>
31 32
                 <option value=""
32 33
                         selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option>
33
-            <?php endif; ?>
34
+            <?php endif;
35
+}
36
+?>
34 37
 
35 38
             <?php foreach ($available_storages as $storage => $text): ?>
36
-                <option value="<?php echo $storage ?>"<?php if ($storage == $storage_selection)
39
+                <option value="<?php echo $storage ?>"<?php if ($storage == $storage_selection) {
37 40
                     echo "selected" ?>><?php echo $text ?></option>
38 41
             <?php endforeach ?>
39 42
         </select>
@@ -62,6 +65,7 @@  discard block
 block discarded – undo
62 65
 
63 66
         <?php
64 67
         $i = 0;
68
+}
65 69
         foreach ($backup_list as $file_info):?>
66 70
             <?php
67 71
             if ($storage_selection == "gdrive") {
@@ -136,12 +140,14 @@  discard block
 block discarded – undo
136 140
                             </ul>
137 141
                         <?php endif; ?>
138 142
                     </td>
139
-                    <td><?php if (isset($file_info['timestamp']))
143
+                    <td><?php if (isset($file_info['timestamp'])) {
140 144
                             echo date("Y-m-d H:i", $file_info['timestamp']) ?></td>
141 145
                     <td><?php echo size_format($file_info['size']) ?></td>
142 146
                     <td>
143 147
                         <?php if (!$storage_selection): ?>
144
-                            <a href="#<?php echo $file_info['basename']; ?>" class="download"
148
+                            <a href="#<?php echo $file_info['basename'];
149
+}
150
+?>" class="download"
145 151
                                title="<?php echo __('Download Backup', 'xcloner-backup-and-restore') ?>"><i
146 152
                                         class="material-icons">file_download</i></a>
147 153
 
Please login to merge, or discard this patch.
admin/partials/xcloner_init_page.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -110,7 +110,8 @@  discard block
 block discarded – undo
110 110
 											echo date( $date_format . " " . $time_format, $latest_backup['timestamp'] + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) )
111 111
 											?>
112 112
                                         </div>
113
-									<?php else: ?>
113
+									<?php else {
114
+	: ?>
114 115
                                         <div class="item">
115 116
                                             <div class="title"><?php echo __( "No Backup Yet", 'xcloner-backup-and-restore' ) ?></div>
116 117
                                         </div>
@@ -123,7 +124,9 @@  discard block
 block discarded – undo
123 124
                                             <div class="title"><?php echo __( "Total Size", 'xcloner-backup-and-restore' ) ?>
124 125
                                                 :
125 126
                                             </div>
126
-											<?php echo size_format( $xcloner_file_system->get_storage_usage() ); ?>
127
+											<?php echo size_format( $xcloner_file_system->get_storage_usage() );
128
+}
129
+?>
127 130
                                         </div>
128 131
                                     </blockquote>
129 132
                                     <h5><?php echo __( "Next Scheduled Backup", 'xcloner-backup-and-restore' ) ?></h5>
Please login to merge, or discard this patch.
admin/partials/xcloner_remote_storage_page.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                             <label>
27 27
                                 Off
28 28
                                 <input type="checkbox" name="xcloner_ftp_enable" class="status"
29
-                                       value="1" <?php if ( get_option( "xcloner_ftp_enable" ) )
29
+                                       value="1" <?php if ( get_option( "xcloner_ftp_enable" ) ) {
30 30
 									echo "checked" ?> \>
31 31
                                 <span class="lever"></span>
32 32
                                 On
@@ -340,6 +340,7 @@  discard block
 block discarded – undo
340 340
                                             value=""><?php echo __( "Please Select AWS S3 Region or Leave Unselected for Custom Endpoint" ) ?></option>
341 341
 									<?php
342 342
 									$aws_regions = $remote_storage->get_aws_regions();
343
+}
343 344
 
344 345
 									foreach ( $aws_regions as $key => $region ) {
345 346
 										?>
@@ -423,7 +424,7 @@  discard block
 block discarded – undo
423 424
                             <label>
424 425
                                 Off
425 426
                                 <input type="checkbox" name="xcloner_dropbox_enable" class="status"
426
-                                       value="1" <?php if ( get_option( "xcloner_dropbox_enable" ) )
427
+                                       value="1" <?php if ( get_option( "xcloner_dropbox_enable" ) ) {
427 428
 									echo "checked" ?> \>
428 429
                                 <span class="lever"></span>
429 430
                                 On
@@ -957,6 +958,7 @@  discard block
 block discarded – undo
957 958
                                     <div class="center">
958 959
 										<?php
959 960
 										$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=xcloner-google-drive' ), 'install-plugin_xcloner-google-drive' );
961
+}
960 962
 										?>
961 963
                                         <h6><?php echo __( "This storage option requires the XCloner-Google-Drive Wordpress Plugin to be installed and activated." ) ?></h6>
962 964
                                         <h6><?php echo __( "PHP 5.5 minimum version is required." ) ?></h6>
Please login to merge, or discard this patch.
includes/class-xcloner-remote-storage.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@
 block discarded – undo
213 213
 
214 214
         if( $action == 'e' && function_exists('openssl_encrypt')) {
215 215
             $output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
216
-        }
217
-        else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
216
+        } else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
218 217
             $decrypt = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
219 218
             if($decrypt) {
220 219
                 //we check if decrypt was succesful
Please login to merge, or discard this patch.
includes/class-xcloner-file-system.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -707,9 +707,11 @@
 block discarded – undo
707 707
         foreach ($_backup_files_list as $file) {
708 708
             //processing rule folder capacity
709 709
             if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
710
-                $_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))    //bytes
710
+                $_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) {
711
+            	//bytes
711 712
             {
712 713
                 $this->storage_filesystem->delete($file['path']);
714
+            }
713 715
                 $_storage_size -= $file['size'];
714 716
                 $this->logger->info("Deleting backup " . $file['path'] . " matching rule", array(
715 717
                     "STORAGE SIZE LIMIT",
Please login to merge, or discard this patch.