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 ( e65d67...dc9fa8 )
by Liuta
03:08
created
includes/class-xcloner-archive.php 1 patch
Braces   +79 added lines, -61 removed lines patch added patch discarded remove patch
@@ -26,17 +26,22 @@  discard block
 block discarded – undo
26 26
 		$this->logger 			= $xcloner_container->get_xcloner_logger()->withName("xcloner_archive");
27 27
 		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
28 28
 		
29
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
30
-			$this->file_size_per_request_limit = $value*1024*1024; //MB
29
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request')) {
30
+					$this->file_size_per_request_limit = $value*1024*1024;
31
+		}
32
+		//MB
31 33
 			
32
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
33
-			$this->files_to_process_per_request = $value;
34
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request')) {
35
+					$this->files_to_process_per_request = $value;
36
+		}
34 37
 		
35
-		if($value = get_option('xcloner_backup_compression_level'))
36
-			$this->compression_level = $value;
38
+		if($value = get_option('xcloner_backup_compression_level')) {
39
+					$this->compression_level = $value;
40
+		}
37 41
 		
38
-		if($value = get_option('xcloner_split_backup_limit'))
39
-			$this->xcloner_split_backup_limit = $value;
42
+		if($value = get_option('xcloner_split_backup_limit')) {
43
+					$this->xcloner_split_backup_limit = $value;
44
+		}
40 45
 		
41 46
 		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024*1024; //transform to bytes
42 47
 			
@@ -73,8 +78,9 @@  discard block
 block discarded – undo
73 78
 			//$this->archive_name = $this->archive_name."-diff-".date("Y-m-d_H-i",$diff_timestamp_start);
74 79
 			$new_name = $this->archive_name;
75 80
 			
76
-			if(!stristr($new_name, "-diff"))
77
-				$new_name = $this->archive_name . "-diff".date("Y-m-d_H-i",$diff_timestamp_start);
81
+			if(!stristr($new_name, "-diff")) {
82
+							$new_name = $this->archive_name . "-diff".date("Y-m-d_H-i",$diff_timestamp_start);
83
+			}
78 84
 			
79 85
 			$this->archive_name = $new_name;
80 86
 			
@@ -83,8 +89,9 @@  discard block
 block discarded – undo
83 89
 		if(isset($part) and $part)
84 90
 		{
85 91
 			$new_name =  preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
86
-			if(!stristr($new_name, "-part"))
87
-				$new_name = $this->archive_name . "-part".$part;
92
+			if(!stristr($new_name, "-part")) {
93
+							$new_name = $this->archive_name . "-part".$part;
94
+			}
88 95
 			
89 96
 			$this->archive_name = $new_name;	
90 97
 		}
@@ -139,8 +146,9 @@  discard block
 block discarded – undo
139 146
 		
140 147
 		$headers = array('Content-Type: text/html; charset=UTF-8');
141 148
 		
142
-		if($admin_email and $from )
143
-			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
149
+		if($admin_email and $from ) {
150
+					$headers[] = 'From: '.$from.' <'.$admin_email.'>';
151
+		}
144 152
 
145 153
 		$return = wp_mail( $to, $subject, $body, $headers );
146 154
 		
@@ -182,8 +190,9 @@  discard block
 block discarded – undo
182 190
 		
183 191
 		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
184 192
 		
185
-		if(!$backups_counter = sizeof($backup_parts))
186
-			$backups_counter = 1;
193
+		if(!$backups_counter = sizeof($backup_parts)) {
194
+					$backups_counter = 1;
195
+		}
187 196
 		
188 197
 		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
189 198
 		$body .= "<br />";
@@ -202,8 +211,9 @@  discard block
 block discarded – undo
202 211
 			$body .= "<br /><br />";
203 212
 		}
204 213
 		
205
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
206
-			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
214
+		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
215
+					$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
216
+		}
207 217
 		
208 218
 		$attachments = $this->filesystem->get_backup_attachments();
209 219
 		
@@ -238,18 +248,21 @@  discard block
 block discarded – undo
238 248
 	{
239 249
 		$return = array();
240 250
 		
241
-		if(!isset($extra_params['backup_part']))
242
-			$extra_params['backup_part'] = 0;
251
+		if(!isset($extra_params['backup_part'])) {
252
+					$extra_params['backup_part'] = 0;
253
+		}
243 254
 		
244 255
 		$return['extra']['backup_part'] = $extra_params['backup_part'];
245 256
 					
246
-		if(isset( $extra_params['backup_archive_name']))
247
-			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
248
-		else
249
-			$this->set_archive_name($backup_params['backup_name']);
257
+		if(isset( $extra_params['backup_archive_name'])) {
258
+					$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
259
+		} else {
260
+					$this->set_archive_name($backup_params['backup_name']);
261
+		}
250 262
 			
251
-		if(!$this->get_archive_name())
252
-			$this->set_archive_name();
263
+		if(!$this->get_archive_name()) {
264
+					$this->set_archive_name();
265
+		}
253 266
 		
254 267
 		$this->backup_archive = new Tar();
255 268
 		$this->backup_archive->setCompression($this->compression_level);
@@ -264,7 +277,7 @@  discard block
 block discarded – undo
264 277
 			
265 278
 			$return['extra']['backup_init'] = 1;
266 279
 			
267
-		}else{
280
+		} else{
268 281
 			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
269 282
 			
270 283
 			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
@@ -276,11 +289,13 @@  discard block
 block discarded – undo
276 289
 		$return['extra']['backup_archive_name'] = $this->get_archive_name();
277 290
 		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
278 291
 		
279
-		if(!isset($extra_params['start_at_line']))
280
-			$extra_params['start_at_line'] = 0;
292
+		if(!isset($extra_params['start_at_line'])) {
293
+					$extra_params['start_at_line'] = 0;
294
+		}
281 295
 		
282
-		if(!isset($extra_params['start_at_byte']))
283
-			$extra_params['start_at_byte'] = 0;
296
+		if(!isset($extra_params['start_at_byte'])) {
297
+					$extra_params['start_at_byte'] = 0;
298
+		}
284 299
 		
285 300
 		if(!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
286 301
 		{
@@ -302,7 +317,7 @@  discard block
 block discarded – undo
302 317
 		if(!$extra_params['start_at_line'])
303 318
 		{
304 319
 			$file->seek(1);
305
-		}else{
320
+		} else{
306 321
 			$file->seek($extra_params['start_at_line']+1);
307 322
 		}
308 323
 		
@@ -344,8 +359,9 @@  discard block
 block discarded – undo
344 359
 			
345 360
 			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
346 361
 			
347
-			if(!isset($file_info['size']))
348
-				$file_info['size'] = 0;
362
+			if(!isset($file_info['size'])) {
363
+							$file_info['size'] = 0;
364
+			}
349 365
 			
350 366
 			if($start_filesystem == "tmp_filesystem")
351 367
 			{	
@@ -356,11 +372,13 @@  discard block
 block discarded – undo
356 372
 			
357 373
 			$append = 0;
358 374
 			
359
-			if($file_info['size'] > $byte_limit*512 or $start_byte)
360
-				$append = 1;
375
+			if($file_info['size'] > $byte_limit*512 or $start_byte) {
376
+							$append = 1;
377
+			}
361 378
 						
362
-			if(!isset($return['extra']['backup_size']))
363
-				$return['extra']['backup_size'] =0;
379
+			if(!isset($return['extra']['backup_size'])) {
380
+							$return['extra']['backup_size'] =0;
381
+			}
364 382
 			
365 383
 			$return['extra']['backup_size'] = $archive_info->getSize();
366 384
 			
@@ -396,8 +414,7 @@  discard block
 block discarded – undo
396 414
 			
397 415
 			if($last_position>0){	
398 416
 				$start_byte = $last_position;
399
-			}
400
-			else{	
417
+			} else{	
401 418
 				$extra_params['start_at_line']++;
402 419
 				$file->next();
403 420
 				$start_byte = 0;
@@ -434,8 +451,9 @@  discard block
 block discarded – undo
434 451
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
435 452
 		$this->backup_archive->close();
436 453
 				
437
-		if($return['extra']['backup_part'])
438
-			$this->write_multipart_file($this->get_archive_name_with_extension());
454
+		if($return['extra']['backup_part']) {
455
+					$this->write_multipart_file($this->get_archive_name_with_extension());
456
+		}
439 457
 		
440 458
 		$return['extra']['start_at_line'] = $extra_params['start_at_line']-1;
441 459
 		
@@ -487,12 +505,13 @@  discard block
 block discarded – undo
487 505
 			$this->set_archive_name($this->get_archive_name(), ++$part);
488 506
 			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
489 507
 			
490
-			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
491
-				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
508
+			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
509
+							$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
510
+			}
492 511
 				
493 512
 			$this->write_multipart_file($this->get_archive_name_with_extension());
494 513
 			
495
-		}else
514
+		} else
496 515
 		{
497 516
 			$this->logger->info(sprintf("Creating new multipart info file %s",$this->get_archive_name_with_extension()));
498 517
 			$this->write_multipart_file($this->get_archive_name_with_extension());
@@ -522,13 +541,15 @@  discard block
 block discarded – undo
522 541
 		$start_adapter = $this->filesystem->get_adapter($filesystem);
523 542
 		$start_filesystem = $this->filesystem->get_adapter($filesystem);
524 543
 		
525
-		if(!$file_info['path'])
526
-			return;
544
+		if(!$file_info['path']) {
545
+					return;
546
+		}
527 547
 		
528
-		if(isset($file_info['archive_prefix_path']))	
529
-			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
530
-		else
531
-			$file_info['target_path'] = $file_info['path'];
548
+		if(isset($file_info['archive_prefix_path'])) {
549
+					$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
550
+		} else {
551
+					$file_info['target_path'] = $file_info['path'];
552
+		}
532 553
 			
533 554
 		$last_position = $start_at_byte;
534 555
 		
@@ -538,8 +559,7 @@  discard block
 block discarded – undo
538 559
 			$bytes_wrote = $file_info['size'];
539 560
 			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote, $file_info['target_path'], $this->get_archive_name_with_extension()));
540 561
 			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path']);
541
-		}
542
-		else{	
562
+		} else{	
543 563
 			$tmp_file = md5($file_info['path']);
544 564
 			
545 565
 			//we isolate file to tmp if we are at byte 0, the starting point of file reading
@@ -548,16 +568,16 @@  discard block
 block discarded – undo
548 568
 				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes", $file_info['path'], $tmp_file));
549 569
 				$file_stream = $start_filesystem->readStream($file_info['path']);
550 570
 				
551
-				if(is_resource($file_stream['stream']))
552
-					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
571
+				if(is_resource($file_stream['stream'])) {
572
+									$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
573
+				}
553 574
 			}
554 575
 			
555 576
 			if($this->filesystem->get_tmp_filesystem()->has($tmp_file))
556 577
 			{
557 578
 				$is_tmp = 1;
558 579
 				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_file), $file_info['target_path'], $start_at_byte, $byte_limit);
559
-			}
560
-			else{
580
+			} else{
561 581
 				$is_tmp = 0;
562 582
 				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path'], $start_at_byte, $byte_limit);
563 583
 			}
@@ -566,8 +586,7 @@  discard block
 block discarded – undo
566 586
 			if($last_position == -1)
567 587
 			{
568 588
 				$bytes_wrote = $file_info['size'] - $start_at_byte;
569
-			}
570
-			else
589
+			} else
571 590
 			{
572 591
 				$bytes_wrote = $last_position - $start_at_byte;
573 592
 			}
@@ -576,8 +595,7 @@  discard block
 block discarded – undo
576 595
 			if($is_tmp)
577 596
 			{
578 597
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ", $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
579
-			}
580
-			else{
598
+			} else{
581 599
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ", $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
582 600
 			}
583 601
 			
Please login to merge, or discard this patch.
includes/class-xcloner-settings.php 1 patch
Braces   +77 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
 	public function __construct(Xcloner $xcloner_container, $hash = "")
12 12
 	{
13 13
 		$this->xcloner_container = $xcloner_container;
14
-		if(isset($hash))
15
-			$this->set_hash($hash);
14
+		if(isset($hash)) {
15
+					$this->set_hash($hash);
16
+		}
16 17
 	}
17 18
 	
18 19
 	private function get_xcloner_container()
@@ -22,20 +23,22 @@  discard block
 block discarded – undo
22 23
 	
23 24
 	public function get_logger_filename($include_hash = 0)
24 25
 	{
25
-		if($include_hash)
26
-			$filename = sprintf($this->logger_file_hash, $this->get_hash()); 
27
-		else
28
-			$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
26
+		if($include_hash) {
27
+					$filename = sprintf($this->logger_file_hash, $this->get_hash());
28
+		} else {
29
+					$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
30
+		}
29 31
 		
30 32
 		return $filename;
31 33
 	}
32 34
 	
33 35
 	public function get_xcloner_start_path()
34 36
 	{
35
-		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
36
-			$path = realpath(ABSPATH);
37
-		else
38
-			$path = get_option('xcloner_start_path');
37
+		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) {
38
+					$path = realpath(ABSPATH);
39
+		} else {
40
+					$path = get_option('xcloner_start_path');
41
+		}
39 42
 		
40 43
 		return $path;
41 44
 	}
@@ -49,10 +52,11 @@  discard block
 block discarded – undo
49 52
 	
50 53
 	public function get_xcloner_store_path()
51 54
 	{
52
-		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path')))
53
-			$path = realpath(XCLONER_STORAGE_PATH);
54
-		else
55
-			$path = get_option('xcloner_store_path');
55
+		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path'))) {
56
+					$path = realpath(XCLONER_STORAGE_PATH);
57
+		} else {
58
+					$path = get_option('xcloner_store_path');
59
+		}
56 60
 		
57 61
 		return $path;
58 62
 	}
@@ -87,8 +91,9 @@  discard block
 block discarded – undo
87 91
 	
88 92
 	public function get_enable_mysql_backup()
89 93
 	{
90
-		if(get_option('xcloner_enable_mysql_backup'))
91
-			return true;
94
+		if(get_option('xcloner_enable_mysql_backup')) {
95
+					return true;
96
+		}
92 97
 		
93 98
 		return false;	
94 99
 	}
@@ -97,10 +102,11 @@  discard block
 block discarded – undo
97 102
 	{
98 103
 		if(!$ext)
99 104
 		{
100
-			if(get_option('xcloner_backup_compression_level'))
101
-				$ext = ".tgz";
102
-			else
103
-				$ext = ".tar";
105
+			if(get_option('xcloner_backup_compression_level')) {
106
+							$ext = ".tgz";
107
+			} else {
108
+							$ext = ".tar";
109
+			}
104 110
 		}	
105 111
 		return ($this->get_hash()).$ext;	
106 112
 	}
@@ -126,8 +132,9 @@  discard block
 block discarded – undo
126 132
 	
127 133
 	public function set_hash($hash = "")
128 134
 	{
129
-		if(substr($hash, 0, 1) != "-" and strlen($hash))
130
-			$hash = "-".$hash;
135
+		if(substr($hash, 0, 1) != "-" and strlen($hash)) {
136
+					$hash = "-".$hash;
137
+		}
131 138
 			
132 139
 		$this->hash = substr( $hash, 0, 6);
133 140
 		
@@ -147,8 +154,9 @@  discard block
 block discarded – undo
147 154
 	{
148 155
 		global $wpdb;
149 156
 		
150
-		if(!$data = get_option('xcloner_mysql_hostname'))
151
-			$data = $wpdb->dbhost;
157
+		if(!$data = get_option('xcloner_mysql_hostname')) {
158
+					$data = $wpdb->dbhost;
159
+		}
152 160
 		
153 161
 		return $data;
154 162
 	}
@@ -157,8 +165,9 @@  discard block
 block discarded – undo
157 165
 	{
158 166
 		global $wpdb;
159 167
 		
160
-		if(!$data = get_option('xcloner_mysql_username'))
161
-			$data = $wpdb->dbuser;
168
+		if(!$data = get_option('xcloner_mysql_username')) {
169
+					$data = $wpdb->dbuser;
170
+		}
162 171
 		
163 172
 		return $data;
164 173
 	}
@@ -167,8 +176,9 @@  discard block
 block discarded – undo
167 176
 	{
168 177
 		global $wpdb;
169 178
 		
170
-		if(!$data = get_option('xcloner_mysql_password'))
171
-			$data = $wpdb->dbpassword;
179
+		if(!$data = get_option('xcloner_mysql_password')) {
180
+					$data = $wpdb->dbpassword;
181
+		}
172 182
 		
173 183
 		return $data;
174 184
 	}
@@ -177,8 +187,9 @@  discard block
 block discarded – undo
177 187
 	{
178 188
 		global $wpdb;
179 189
 		
180
-		if(!$data = get_option('xcloner_mysql_database'))
181
-			$data = $wpdb->dbname;
190
+		if(!$data = get_option('xcloner_mysql_database')) {
191
+					$data = $wpdb->dbname;
192
+		}
182 193
 		
183 194
 		return $data;
184 195
 	}
@@ -201,8 +212,9 @@  discard block
 block discarded – undo
201 212
 	{
202 213
 		$hash = md5(get_home_url().__DIR__);
203 214
 		
204
-		if($strlen)
205
-			$hash = substr($hash, 0, $strlen);
215
+		if($strlen) {
216
+					$hash = substr($hash, 0, $strlen);
217
+		}
206 218
 			
207 219
 		return $hash;
208 220
 	}
@@ -581,15 +593,18 @@  discard block
 block discarded – undo
581 593
 	// text field content cb
582 594
 	public function do_form_text_field($params)
583 595
 	{
584
-		if(!isset($params['3']))
585
-			$params[3] = 0;
586
-		if(!isset($params['2']))
587
-			$params[2] = 0;	
596
+		if(!isset($params['3'])) {
597
+					$params[3] = 0;
598
+		}
599
+		if(!isset($params['2'])) {
600
+					$params[2] = 0;
601
+		}
588 602
 			
589 603
 		list($fieldname, $label, $value, $disabled) = $params;
590 604
 		
591
-		if(!$value)
592
-			$value = get_option($fieldname);
605
+		if(!$value) {
606
+					$value = get_option($fieldname);
607
+		}
593 608
 	    // output the field
594 609
 	    ?>
595 610
 	    <div class="row">
@@ -608,15 +623,18 @@  discard block
 block discarded – undo
608 623
 	// textarea field content cb
609 624
 	public function do_form_textarea_field($params)
610 625
 	{
611
-		if(!isset($params['3']))
612
-			$params[3] = 0;
613
-		if(!isset($params['2']))
614
-			$params[2] = 0;	
626
+		if(!isset($params['3'])) {
627
+					$params[3] = 0;
628
+		}
629
+		if(!isset($params['2'])) {
630
+					$params[2] = 0;
631
+		}
615 632
 			
616 633
 		list($fieldname, $label, $value, $disabled) = $params;
617 634
 		
618
-		if(!$value)
619
-			$value = get_option($fieldname);
635
+		if(!$value) {
636
+					$value = get_option($fieldname);
637
+		}
620 638
 	    // output the field
621 639
 	    ?>
622 640
 	    <div class="row">
@@ -652,15 +670,18 @@  discard block
 block discarded – undo
652 670
 	// number field content cb
653 671
 	public function do_form_number_field($params)
654 672
 	{
655
-		if(!isset($params['3']))
656
-			$params[3] = 0;
657
-		if(!isset($params['2']))
658
-			$params[2] = 0;	
673
+		if(!isset($params['3'])) {
674
+					$params[3] = 0;
675
+		}
676
+		if(!isset($params['2'])) {
677
+					$params[2] = 0;
678
+		}
659 679
 			
660 680
 		list($fieldname, $label, $value, $disabled) = $params;
661 681
 		
662
-		if(!$value)
663
-			$value = get_option($fieldname);
682
+		if(!$value) {
683
+					$value = get_option($fieldname);
684
+		}
664 685
 	    // output the field
665 686
 	    ?>
666 687
 	    <div class="row">
@@ -678,8 +699,9 @@  discard block
 block discarded – undo
678 699
 	
679 700
 	public function do_form_range_field($params)
680 701
 	{
681
-		if(!isset($params['4']))
682
-			$params[4] = 0;
702
+		if(!isset($params['4'])) {
703
+					$params[4] = 0;
704
+		}
683 705
 			
684 706
 		list($fieldname, $label, $range_start, $range_end, $disabled) = $params;
685 707
 		$value = get_option($fieldname);
@@ -700,8 +722,9 @@  discard block
 block discarded – undo
700 722
 	
701 723
 	public function do_form_switch_field($params)
702 724
 	{
703
-		if(!isset($params['2']))
704
-			$params[2] = 0;
725
+		if(!isset($params['2'])) {
726
+					$params[2] = 0;
727
+		}
705 728
 		list($fieldname, $label, $disabled) = $params;
706 729
 		$value = get_option($fieldname);
707 730
 	?>
Please login to merge, or discard this patch.
includes/class-xcloner-api.php 1 patch
Braces   +103 added lines, -80 removed lines patch added patch discarded remove patch
@@ -32,8 +32,9 @@  discard block
 block discarded – undo
32 32
 			error_reporting(0);
33 33
 		}
34 34
 		
35
-		if( ob_get_length() )
36
-			ob_end_clean();
35
+		if( ob_get_length() ) {
36
+					ob_end_clean();
37
+		}
37 38
 		ob_start();
38 39
 		
39 40
 		$wpdb->show_errors			= false;
@@ -86,7 +87,7 @@  discard block
 block discarded – undo
86 87
 		{
87 88
 			$this->xcloner_database->init($data);
88 89
 
89
-		}catch(Exception $e){
90
+		} catch(Exception $e){
90 91
 			
91 92
 			$this->send_response($e->getMessage());
92 93
 			$this->logger->error($e->getMessage());
@@ -113,8 +114,9 @@  discard block
 block discarded – undo
113 114
 		$schedule = array();
114 115
 		$response = array();
115 116
 		
116
-		if(isset($_POST['data']))
117
-			$params = json_decode(stripslashes($_POST['data']));
117
+		if(isset($_POST['data'])) {
118
+					$params = json_decode(stripslashes($_POST['data']));
119
+		}
118 120
 		
119 121
 		$this->process_params($params);
120 122
 		
@@ -125,7 +127,7 @@  discard block
 block discarded – undo
125 127
 			$this->form_params['backup_params']['email_notification'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['email_notification']);
126 128
 			if($_POST['diff_start_date']){
127 129
 				$this->form_params['backup_params']['diff_start_date'] = strtotime($this->xcloner_sanitization->sanitize_input_as_string($_POST['diff_start_date']));
128
-			}else{
130
+			} else{
129 131
 				$this->form_params['backup_params']['diff_start_date'] = "";
130 132
 				}
131 133
 			$this->form_params['backup_params']['schedule_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_name']);
@@ -144,8 +146,9 @@  discard block
 block discarded – undo
144 146
 			{
145 147
 					$table = str_replace("\r","", $table);
146 148
 					$data = explode(".", $table);
147
-					if(isset($data[1]))
148
-						$return[$data[0]][] = $data[1];
149
+					if(isset($data[1])) {
150
+											$return[$data[0]][] = $data[1];
151
+					}
149 152
 			}
150 153
 			
151 154
 			$this->form_params['database'] = ($return);
@@ -156,19 +159,21 @@  discard block
 block discarded – undo
156 159
 			foreach($excluded_files as $file)
157 160
 			{
158 161
 				$file = str_replace("\r","", $file);
159
-				if($file)
160
-					$return[] = $file;
162
+				if($file) {
163
+									$return[] = $file;
164
+				}
161 165
 			}
162 166
 			
163 167
 			$this->form_params['excluded_files'] = ($return);
164 168
 			
165 169
 			$schedule['start_at'] = $this->form_params['backup_params']['start_at'];
166 170
 			
167
-			if(!isset($_POST['status']))
168
-				$schedule['status'] = 0;
169
-			else	
170
-				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
171
-		}else{
171
+			if(!isset($_POST['status'])) {
172
+							$schedule['status'] = 0;
173
+			} else {
174
+							$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
175
+			}
176
+		} else{
172 177
 		
173 178
 			$schedule['status'] = 1;
174 179
 			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
@@ -183,7 +188,7 @@  discard block
 block discarded – undo
183 188
 		if(!$schedule['start_at'])						
184 189
 		{
185 190
 			$schedule['start_at'] = date('Y-m-d H:i:s', time());
186
-		}else{
191
+		} else{
187 192
 			$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at'] - (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS) );	
188 193
 		}
189 194
 		
@@ -203,7 +208,7 @@  discard block
 block discarded – undo
203 208
 					'%s' 
204 209
 				) 
205 210
 			);
206
-		}else		{
211
+		} else		{
207 212
 			$wpdb->update( 
208 213
 				$wpdb->prefix.'xcloner_scheduler', 
209 214
 				$schedule, 
@@ -244,8 +249,9 @@  discard block
 block discarded – undo
244 249
 		
245 250
 		$init 	= (int)$_POST['init'];
246 251
 		
247
-		if($params === NULL)
248
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
252
+		if($params === NULL) {
253
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
254
+		}
249 255
 			 
250 256
 		$this->process_params($params);
251 257
 		
@@ -254,7 +260,7 @@  discard block
 block discarded – undo
254 260
 		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
255 261
 		try{
256 262
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
257
-		}catch(Exception $e)
263
+		} catch(Exception $e)
258 264
 		{
259 265
 			$return = array();
260 266
 			$return['error'] = true;
@@ -266,8 +272,9 @@  discard block
 block discarded – undo
266 272
 		if($return['finished'])
267 273
 		{
268 274
 			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
269
-			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
270
-				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
275
+			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
276
+							$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
277
+			}
271 278
 		}
272 279
 		
273 280
 		$data = $return;
@@ -282,7 +289,7 @@  discard block
 block discarded – undo
282 289
 					$subject = "";
283 290
 					$additional['lines_total'] = $return['extra']['lines_total'];
284 291
 					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params,"", $additional);
285
-				}catch(Exception $e)
292
+				} catch(Exception $e)
286 293
 				{
287 294
 					$this->logger->error($e->getMessage());
288 295
 				}
@@ -306,18 +313,20 @@  discard block
 block discarded – undo
306 313
 		
307 314
 		$init 	= (int)$_POST['init'];
308 315
 		
309
-		if($params === NULL)
310
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
316
+		if($params === NULL) {
317
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
318
+		}
311 319
 		
312 320
 		$this->process_params($params);
313 321
 			
314 322
 		//$xcloner_database = $this->init_db();	
315 323
 		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init);
316 324
 		
317
-		if(isset($return['error']) and $return['error'])
318
-			$data['finished'] = 1;
319
-		else	
320
-			$data['finished'] = $return['finished'];
325
+		if(isset($return['error']) and $return['error']) {
326
+					$data['finished'] = 1;
327
+		} else {
328
+					$data['finished'] = $return['finished'];
329
+		}
321 330
 			
322 331
 		$data['extra'] = $return;
323 332
 		
@@ -336,8 +345,9 @@  discard block
 block discarded – undo
336 345
 		$params = json_decode(stripslashes($_POST['data']));
337 346
 		$init 	= (int)$_POST['init'];
338 347
 		
339
-		if($params === NULL)
340
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
348
+		if($params === NULL) {
349
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
350
+		}
341 351
 			 
342 352
 		$hash = $this->process_params($params);
343 353
 		
@@ -360,8 +370,9 @@  discard block
 block discarded – undo
360 370
 	 */ 
361 371
 	private function process_params($params)
362 372
 	{
363
-		if(isset($params->hash))
364
-			$this->xcloner_settings->set_hash($params->hash);
373
+		if(isset($params->hash)) {
374
+					$this->xcloner_settings->set_hash($params->hash);
375
+		}
365 376
 			
366 377
 		$this->form_params['extra'] = array();
367 378
 		$this->form_params['backup_params'] = array();
@@ -414,8 +425,9 @@  discard block
 block discarded – undo
414 425
 		
415 426
 		if(isset($params->extra))
416 427
 		{
417
-			foreach($params->extra as $key=>$value)
418
-				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
428
+			foreach($params->extra as $key=>$value) {
429
+							$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
430
+			}
419 431
 		}
420 432
 		
421 433
 		if(isset($this->form_params['backup_params']['diff_start_date']) and $this->form_params['backup_params']['diff_start_date'])
@@ -455,7 +467,7 @@  discard block
 block discarded – undo
455 467
 			
456 468
 			try{
457 469
 				$files = $this->xcloner_file_system->list_directory($folder);
458
-			}catch(Exception $e){
470
+			} catch(Exception $e){
459 471
 				
460 472
 				print $e->getMessage();
461 473
 				$this->logger->error($e->getMessage());
@@ -475,15 +487,17 @@  discard block
 block discarded – undo
475 487
 				$children = false;
476 488
 				$text = $file['basename'];
477 489
 				
478
-				if($file['type'] == "dir")
479
-					$children = true;
480
-				else
481
-					 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
490
+				if($file['type'] == "dir") {
491
+									$children = true;
492
+				} else {
493
+									 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
494
+				}
482 495
 				
483
-				if($this->xcloner_file_system->is_excluded($file))
484
-					$selected = true;
485
-				else
486
-					$selected = false;
496
+				if($this->xcloner_file_system->is_excluded($file)) {
497
+									$selected = true;
498
+				} else {
499
+									$selected = false;
500
+				}
487 501
 					
488 502
 				$data[] = array(
489 503
 							'id' => $file['path'],
@@ -519,22 +533,24 @@  discard block
 block discarded – undo
519 533
 		{
520 534
 			try{
521 535
 				$return = $this->xcloner_database->get_all_databases();
522
-			}catch(Exception $e){
536
+			} catch(Exception $e){
523 537
 				$this->logger->error($e->getMessage());
524 538
 			}
525 539
 			
526 540
 			foreach($return as $database)
527 541
 			{
528
-				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
529
-					continue;
542
+				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) {
543
+									continue;
544
+				}
530 545
 					
531 546
 				$state = array();
532 547
 				
533 548
 				if($database['name'] == $this->xcloner_settings->get_db_database())
534 549
 				{
535 550
 					$state['selected'] = true;
536
-					if($database['num_tables'] < 25)
537
-						$state['opened'] = false;
551
+					if($database['num_tables'] < 25) {
552
+											$state['opened'] = false;
553
+					}
538 554
 				}
539 555
 					
540 556
 				$data[] = array(
@@ -547,13 +563,11 @@  discard block
 block discarded – undo
547 563
 						);
548 564
 			}
549 565
 			
550
-		}
551
-		
552
-		else{
566
+		} else{
553 567
 			
554 568
 			try{
555 569
 				$return = $this->xcloner_database->list_tables($database, "", 1);
556
-			}catch(Exception $e){
570
+			} catch(Exception $e){
557 571
 				$this->logger->error($e->getMessage());
558 572
 			}
559 573
 			
@@ -561,11 +575,13 @@  discard block
 block discarded – undo
561 575
 			{
562 576
 				$state = array();
563 577
 				
564
-				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
565
-					continue;
578
+				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix())) {
579
+									continue;
580
+				}
566 581
 				
567
-				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
568
-					$state = array('selected' => true);
582
+				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) {
583
+									$state = array('selected' => true);
584
+				}
569 585
 					
570 586
 				$data[] = array(
571 587
 						'id' => $table['name'],
@@ -620,10 +636,11 @@  discard block
 block discarded – undo
620 636
 		{
621 637
 			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> 
622 638
 					<a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
623
-			if($res->status)
624
-				$status = '<i class="material-icons active status">timer</i>';
625
-			else
626
-				$status = '<i class="material-icons status inactive">timer_off</i>';
639
+			if($res->status) {
640
+							$status = '<i class="material-icons active status">timer</i>';
641
+			} else {
642
+							$status = '<i class="material-icons status inactive">timer_off</i>';
643
+			}
627 644
 				
628 645
 			$next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id));
629 646
 				
@@ -631,17 +648,19 @@  discard block
 block discarded – undo
631 648
 			
632 649
 			$remote_storage = $res->remote_storage;
633 650
 			
634
-			if(!$next_run_time >= time())
635
-				$next_run = " ";
651
+			if(!$next_run_time >= time()) {
652
+							$next_run = " ";
653
+			}
636 654
 			
637 655
 			if(trim($next_run))
638 656
 			{
639 657
 				$date_text = date(get_option('date_format')." ".get_option('time_format'), $next_run_time + (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS));
640 658
 				
641
-				if($next_run_time >= time())
642
-					$next_run = "in ".human_time_diff($next_run_time, time());
643
-				else
644
-					$next_run = __("executed", 'xcloner-backup-and-restore');
659
+				if($next_run_time >= time()) {
660
+									$next_run = "in ".human_time_diff($next_run_time, time());
661
+				} else {
662
+									$next_run = __("executed", 'xcloner-backup-and-restore');
663
+				}
645 664
 				
646 665
 				$next_run = "<a href='#' title='".$date_text."'>".$next_run."</a>";
647 666
 				//$next_run .=" ($date_text)";	
@@ -732,7 +751,7 @@  discard block
 block discarded – undo
732 751
 			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
733 752
 		
734 753
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
735
-		}catch(Exception $e)
754
+		} catch(Exception $e)
736 755
 		{
737 756
 			$return['error'] = true;
738 757
 			$return['message'] = $e->getMessage();
@@ -760,15 +779,16 @@  discard block
 block discarded – undo
760 779
 		{
761 780
 			$return['start'] = $data['start'];
762 781
 			$return['finished'] = 0;	
763
-		}else{
782
+		} else{
764 783
 			if($this->xcloner_file_system->is_multipart($source_backup_file))
765 784
 			{
766 785
 				$return['start'] = 0;
767 786
 				
768 787
 				++$return['part'];
769 788
 			
770
-				if($return['part'] < sizeof($backup_parts))	
771
-					$return['finished'] = 0;
789
+				if($return['part'] < sizeof($backup_parts)) {
790
+									$return['finished'] = 0;
791
+				}
772 792
 				
773 793
 			}
774 794
 		}	
@@ -794,7 +814,7 @@  discard block
 block discarded – undo
794 814
 			{
795 815
 				$return = call_user_func_array(array($xcloner_remote_storage, "copy_backup_remote_to_local"), array($backup_file, $storage_type));
796 816
 			}
797
-		}catch(Exception $e){
817
+		} catch(Exception $e){
798 818
 		
799 819
 			$return['error'] = 1;
800 820
 			$return['message'] = $e->getMessage();
@@ -833,7 +853,7 @@  discard block
 block discarded – undo
833 853
 			{
834 854
 				$return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type));
835 855
 			}
836
-		}catch(Exception $e){
856
+		} catch(Exception $e){
837 857
 		
838 858
 			$return['error'] = 1;
839 859
 			$return['message'] = $e->getMessage();
@@ -984,11 +1004,13 @@  discard block
 block discarded – undo
984 1004
 		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
985 1005
 		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
986 1006
 		
987
-		if(isset($_POST['part']))
988
-			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1007
+		if(isset($_POST['part'])) {
1008
+					$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1009
+		}
989 1010
 		
990
-		if(isset($_POST['uploaded_size']))
991
-			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
1011
+		if(isset($_POST['uploaded_size'])) {
1012
+					$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
1013
+		}
992 1014
 		
993 1015
 		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
994 1016
 		$target_url = $this->xcloner_sanitization->sanitize_input_as_string($_POST['target_url']);
@@ -1015,7 +1037,7 @@  discard block
 block discarded – undo
1015 1037
 			$xcloner_file_transfer->set_target($target_url);
1016 1038
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
1017 1039
 		
1018
-		}catch(Exception $e){
1040
+		} catch(Exception $e){
1019 1041
 		
1020 1042
 			$return = array();
1021 1043
 			$return['error'] = true;
@@ -1059,8 +1081,9 @@  discard block
 block discarded – undo
1059 1081
 			$data['hash'] = $this->xcloner_settings->get_hash();
1060 1082
 		}
1061 1083
 			
1062
-		if( ob_get_length() )
1063
-			ob_clean();
1084
+		if( ob_get_length() ) {
1085
+					ob_clean();
1086
+		}
1064 1087
 		wp_send_json($data);
1065 1088
 		
1066 1089
 		die();
Please login to merge, or discard this patch.
includes/class-xcloner-activator.php 1 patch
Braces   +39 added lines, -26 removed lines patch added patch discarded remove patch
@@ -70,48 +70,61 @@
 block discarded – undo
70 70
 			update_option( "xcloner_db_version", $xcloner_db_version );
71 71
 		}
72 72
 		
73
-		if(get_option('xcloner_backup_compression_level') === false)
74
-			update_option('xcloner_backup_compression_level', 0);
73
+		if(get_option('xcloner_backup_compression_level') === false) {
74
+					update_option('xcloner_backup_compression_level', 0);
75
+		}
75 76
 		
76
-		if(get_option('xcloner_enable_log') === false)
77
-			update_option('xcloner_enable_log', 1);
77
+		if(get_option('xcloner_enable_log') === false) {
78
+					update_option('xcloner_enable_log', 1);
79
+		}
78 80
 			
79
-		if(get_option('xcloner_enable_mysql_backup') === false)
80
-			update_option('xcloner_enable_mysql_backup', 1);
81
+		if(get_option('xcloner_enable_mysql_backup') === false) {
82
+					update_option('xcloner_enable_mysql_backup', 1);
83
+		}
81 84
 		
82
-		if(get_option('xcloner_system_settings_page') === false)
83
-			update_option('xcloner_system_settings_page', 100);
85
+		if(get_option('xcloner_system_settings_page') === false) {
86
+					update_option('xcloner_system_settings_page', 100);
87
+		}
84 88
 			
85
-		if(get_option('xcloner_files_to_process_per_request') === false)
86
-			update_option('xcloner_files_to_process_per_request', 250);
89
+		if(get_option('xcloner_files_to_process_per_request') === false) {
90
+					update_option('xcloner_files_to_process_per_request', 250);
91
+		}
87 92
 
88
-		if(get_option('xcloner_database_records_per_request') === false)
89
-			update_option('xcloner_database_records_per_request', 10000);
93
+		if(get_option('xcloner_database_records_per_request') === false) {
94
+					update_option('xcloner_database_records_per_request', 10000);
95
+		}
90 96
 
91
-		if(get_option('xcloner_exclude_files_larger_than_mb') === false)
92
-			update_option('xcloner_exclude_files_larger_than_mb', 0);
97
+		if(get_option('xcloner_exclude_files_larger_than_mb') === false) {
98
+					update_option('xcloner_exclude_files_larger_than_mb', 0);
99
+		}
93 100
 		
94
-		if(get_option('xcloner_split_backup_limit') === false)
95
-			update_option('xcloner_split_backup_limit', 2048);
101
+		if(get_option('xcloner_split_backup_limit') === false) {
102
+					update_option('xcloner_split_backup_limit', 2048);
103
+		}
96 104
 			
97
-		if(get_option('xcloner_size_limit_per_request') === false)
98
-			update_option('xcloner_size_limit_per_request', 50);
105
+		if(get_option('xcloner_size_limit_per_request') === false) {
106
+					update_option('xcloner_size_limit_per_request', 50);
107
+		}
99 108
 			
100
-		if(get_option('xcloner_cleanup_retention_limit_days') === false)
101
-			update_option('xcloner_cleanup_retention_limit_days', 60);
109
+		if(get_option('xcloner_cleanup_retention_limit_days') === false) {
110
+					update_option('xcloner_cleanup_retention_limit_days', 60);
111
+		}
102 112
 			
103
-		if(get_option('xcloner_cleanup_retention_limit_archives') === false)
104
-			update_option('xcloner_cleanup_retention_limit_archives', 100);
113
+		if(get_option('xcloner_cleanup_retention_limit_archives') === false) {
114
+					update_option('xcloner_cleanup_retention_limit_archives', 100);
115
+		}
105 116
 			
106
-		if(get_option('xcloner_directories_to_scan_per_request') === false)
107
-			update_option('xcloner_directories_to_scan_per_request', 25);
117
+		if(get_option('xcloner_directories_to_scan_per_request') === false) {
118
+					update_option('xcloner_directories_to_scan_per_request', 25);
119
+		}
108 120
 			
109 121
 		/*if(!get_option('xcloner_diff_backup_recreate_period'))
110 122
 			update_option('xcloner_diff_backup_recreate_period', 10);
111 123
 			* */
112 124
 			
113
-		if(!get_option('xcloner_regex_exclude'))
114
-			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$");
125
+		if(!get_option('xcloner_regex_exclude')) {
126
+					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$");
127
+		}
115 128
 
116 129
 	}
117 130
 	
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 = "mysql_fetch_array";
498 521
 		}
Please login to merge, or discard this patch.
includes/class-xcloner-file-system.php 1 patch
Braces   +167 added lines, -123 removed lines patch added patch discarded remove patch
@@ -66,13 +66,14 @@  discard block
 block discarded – undo
66 66
 			$this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
67 67
 					'disable_asserts' => true,
68 68
 				]));
69
-		}catch(Exception $e){
69
+		} catch(Exception $e){
70 70
 			$this->logger->error("Filesystem Initialization Error: ".$e->getMessage());
71 71
 		}
72 72
 		
73 73
 		
74
-		if($value = get_option('xcloner_directories_to_scan_per_request'))
75
-			$this->folders_to_process_per_session = $value;
74
+		if($value = get_option('xcloner_directories_to_scan_per_request')) {
75
+					$this->folders_to_process_per_session = $value;
76
+		}
76 77
 
77 78
 	}
78 79
 	
@@ -118,8 +119,9 @@  discard block
 block discarded – undo
118 119
 			$remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
119 120
 			$method = "get_".$remote_storage_selection."_filesystem";
120 121
 			
121
-			if(!method_exists($remote_storage, $method))
122
-				return false;
122
+			if(!method_exists($remote_storage, $method)) {
123
+							return false;
124
+			}
123 125
 				
124 126
 			list($adapter, $filesystem) = $remote_storage->$method();	
125 127
 			
@@ -168,8 +170,9 @@  discard block
 block discarded – undo
168 170
 	public function get_included_files_handler($metadata  = 0)
169 171
 	{
170 172
 		$path = $this->included_files_handler;
171
-		if(!$metadata)
172
-			return $path;
173
+		if(!$metadata) {
174
+					return $path;
175
+		}
173 176
 		
174 177
 		$spl_info = $this->getMetadataFull('tmp_adapter', $path);
175 178
 		return $spl_info;
@@ -185,31 +188,36 @@  discard block
 block discarded – undo
185 188
 	{
186 189
 		$files = $this->get_backup_archives_list();
187 190
 		
188
-		if(is_array($files))
189
-			$this->sort_by($files, "timestamp","desc");
191
+		if(is_array($files)) {
192
+					$this->sort_by($files, "timestamp","desc");
193
+		}
190 194
 		
191 195
 		$new_list = array();
192 196
 		
193
-		foreach($files as $key=>$file)
194
-			if(!isset($file['parent']))
197
+		foreach($files as $key=>$file) {
198
+					if(!isset($file['parent']))
195 199
 				$new_list[] = ($files[$key]);
200
+		}
196 201
 
197
-		if(isset($new_list[0]))
198
-			return $new_list[0];
202
+		if(isset($new_list[0])) {
203
+					return $new_list[0];
204
+		}
199 205
 	}
200 206
 	
201 207
 	public function get_latest_backups()
202 208
 	{
203 209
 		$files = $this->get_backup_archives_list();
204 210
 
205
-		if(is_array($files))
206
-			$this->sort_by($files, "timestamp","desc");
211
+		if(is_array($files)) {
212
+					$this->sort_by($files, "timestamp","desc");
213
+		}
207 214
 		
208 215
 		$new_list = array();
209 216
 		
210
-		foreach($files as $key=>$file)
211
-			if(!isset($file['parent']))
217
+		foreach($files as $key=>$file) {
218
+					if(!isset($file['parent']))
212 219
 				$new_list[] = ($files[$key]);
220
+		}
213 221
 
214 222
 		return $new_list;
215 223
 	}
@@ -219,25 +227,28 @@  discard block
 block discarded – undo
219 227
 		$files = $this->get_backup_archives_list();
220 228
 		$total = 0;
221 229
 		
222
-		if(is_array($files))
223
-			foreach($files as $file)
230
+		if(is_array($files)) {
231
+					foreach($files as $file)
224 232
 				$total += $file['size'];
233
+		}
225 234
 				
226 235
 		return $total;		
227 236
 	}
228 237
 	
229 238
 	public function is_part($backup_name)
230 239
 	{
231
-		if(stristr($backup_name, "-part"))
232
-			return true;
240
+		if(stristr($backup_name, "-part")) {
241
+					return true;
242
+		}
233 243
 		
234 244
 		return false;	
235 245
 	}
236 246
 	
237 247
 	public function is_multipart($backup_name)
238 248
 	{
239
-		if(stristr($backup_name, "-multipart"))
240
-			return true;
249
+		if(stristr($backup_name, "-multipart")) {
250
+					return true;
251
+		}
241 252
 		
242 253
 		return false;	
243 254
 	}
@@ -248,8 +259,9 @@  discard block
 block discarded – undo
248 259
 		if($this->is_multipart($backup_name))
249 260
 		{
250 261
 			$backup_parts = $this->get_multipart_files($backup_name);
251
-			foreach($backup_parts as $part_file)
252
-				$backup_size += $this->get_storage_filesystem()->getSize($part_file);
262
+			foreach($backup_parts as $part_file) {
263
+							$backup_size += $this->get_storage_filesystem()->getSize($part_file);
264
+			}
253 265
 		}
254 266
 		
255 267
 		return $backup_size;
@@ -290,10 +302,11 @@  discard block
 block discarded – undo
290 302
 			}
291 303
 		}
292 304
 		
293
-		if($this->get_storage_filesystem($storage_selection)->delete($backup_name))
294
-			$return = true;
295
-		else
296
-			$return = false;
305
+		if($this->get_storage_filesystem($storage_selection)->delete($backup_name)) {
306
+					$return = true;
307
+		} else {
308
+					$return = false;
309
+		}
297 310
 			
298 311
 		return $return;	
299 312
 	}
@@ -312,8 +325,9 @@  discard block
 block discarded – undo
312 325
 		$list = array();
313 326
 		
314 327
 
315
-		if(method_exists($this->get_storage_filesystem($storage_selection), "listContents"))
316
-			$list = $this->get_storage_filesystem($storage_selection)->listContents();
328
+		if(method_exists($this->get_storage_filesystem($storage_selection), "listContents")) {
329
+					$list = $this->get_storage_filesystem($storage_selection)->listContents();
330
+		}
317 331
 
318 332
 		
319 333
 		$backup_files = array();
@@ -326,10 +340,11 @@  discard block
 block discarded – undo
326 340
 				$data = array();
327 341
 				
328 342
 				$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($file_info['path']));
329
-				foreach($lines as $line)
330
-					if($line)
343
+				foreach($lines as $line) {
344
+									if($line)
331 345
 					{
332 346
 						$data = str_getcsv($line);
347
+				}
333 348
 						if(is_array($data)){
334 349
 							$parents[$data[0]] = $file_info['basename'];
335 350
 							$file_info['childs'][] = $data;
@@ -339,8 +354,9 @@  discard block
 block discarded – undo
339 354
 						
340 355
 			}
341 356
 			
342
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
343
-				$backup_files[$file_info['path']] = $file_info;
357
+			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) {
358
+							$backup_files[$file_info['path']] = $file_info;
359
+			}
344 360
 		}
345 361
 		
346 362
 		foreach($backup_files as $key=>$file_info)
@@ -350,8 +366,9 @@  discard block
 block discarded – undo
350 366
 				//$backup_files[$key]['timestamp'] = $this->get_storage_filesystem($storage_selection)->getTimestamp($file_info['path']);
351 367
 			}
352 368
 			
353
-			if(isset($parents[$file_info['basename']]))
354
-				$backup_files[$key]['parent'] = $parents[$file_info['basename']];
369
+			if(isset($parents[$file_info['basename']])) {
370
+							$backup_files[$key]['parent'] = $parents[$file_info['basename']];
371
+			}
355 372
 		}
356 373
 		
357 374
 		return $backup_files;
@@ -377,11 +394,11 @@  discard block
 block discarded – undo
377 394
 				if($counter < $this->folders_to_process_per_session){
378 395
 					$this->build_files_list($file);
379 396
 					$counter++;
380
-				}else{
397
+				} else{
381 398
 					$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n");
382 399
 				}
383 400
 			}
384
-		}else{
401
+		} else{
385 402
 			$this->build_files_list();
386 403
 		}
387 404
 		
@@ -423,8 +440,9 @@  discard block
 block discarded – undo
423 440
 	{
424 441
 		$return = array();
425 442
 		$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler();
426
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
427
-			$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
443
+		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
444
+					$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
445
+		}
428 446
 		
429 447
 		return $return;
430 448
 	}
@@ -436,9 +454,10 @@  discard block
 block discarded – undo
436 454
 		
437 455
 		$contents = $this->get_tmp_filesystem()->listContents();
438 456
 	
439
-		if(is_array($contents))
440
-		foreach($contents as $file_info)
457
+		if(is_array($contents)) {
458
+				foreach($contents as $file_info)
441 459
 			$this->get_tmp_filesystem()->delete($file_info['path']);
460
+		}
442 461
 			
443 462
 		@rmdir($this->xcloner_settings->get_xcloner_tmp_path());
444 463
 		
@@ -470,17 +489,21 @@  discard block
 block discarded – undo
470 489
 	{
471 490
 		$this->files_counter = 0;
472 491
 		
473
-		if(!$this->storage_filesystem->has("index.html"))	
474
-			$this->storage_filesystem->write("index.html","");
492
+		if(!$this->storage_filesystem->has("index.html")) {
493
+					$this->storage_filesystem->write("index.html","");
494
+		}
475 495
 		
476
-		if(!$this->tmp_filesystem->has("index.html"))	
477
-			$this->tmp_filesystem->write("index.html","");
496
+		if(!$this->tmp_filesystem->has("index.html")) {
497
+					$this->tmp_filesystem->write("index.html","");
498
+		}
478 499
 			
479
-		if($this->tmp_filesystem->has($this->get_included_files_handler()))
480
-			$this->tmp_filesystem->delete($this->get_included_files_handler());
500
+		if($this->tmp_filesystem->has($this->get_included_files_handler())) {
501
+					$this->tmp_filesystem->delete($this->get_included_files_handler());
502
+		}
481 503
 		
482
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
483
-			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
504
+		if($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
505
+					$this->tmp_filesystem->delete($this->get_temp_dir_handler());
506
+		}
484 507
 	}
485 508
 	
486 509
 	public function get_scanned_files_num()
@@ -500,8 +523,9 @@  discard block
 block discarded – undo
500 523
 	
501 524
 	public function set_excluded_files($excluded_files = array())
502 525
 	{
503
-		if(!is_array($excluded_files))
504
-			$excluded_files = array();
526
+		if(!is_array($excluded_files)) {
527
+					$excluded_files = array();
528
+		}
505 529
 			
506 530
 		$this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
507 531
 		
@@ -535,23 +559,23 @@  discard block
 block discarded – undo
535 559
 				if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
536 560
 				{
537 561
 					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE"));
538
-				}
539
-				elseif(!$matching_pattern = $this->is_excluded($file) ){
562
+				} elseif(!$matching_pattern = $this->is_excluded($file) ){
540 563
 					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE"));
541 564
 					$file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
542 565
 					if($this->store_file($file))
543 566
 					{
544 567
 						$this->files_counter++;
545 568
 					}
546
-					if(isset($file['size']))
547
-						$this->files_size += $file['size'];
569
+					if(isset($file['size'])) {
570
+											$this->files_size += $file['size'];
571
+					}
548 572
 					
549
-				}else{
573
+				} else{
550 574
 					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE"));
551 575
 					}
552 576
 			}
553 577
 			
554
-		}catch(Exception $e){
578
+		} catch(Exception $e){
555 579
 			
556 580
 			$this->logger->error($e->getMessage());
557 581
 		
@@ -578,7 +602,7 @@  discard block
 block discarded – undo
578 602
 		
579 603
 			$this->tmp_filesystem->delete($tmp_file);
580 604
 		
581
-		}catch(Exception $e){
605
+		} catch(Exception $e){
582 606
 			
583 607
 			$this->logger->error($e->getMessage());
584 608
 			
@@ -599,12 +623,14 @@  discard block
 block discarded – undo
599 623
 		
600 624
 		$files = $this->storage_filesystem->listContents();
601 625
 		
602
-		if(is_array($files))
603
-			foreach($files as $file)
626
+		if(is_array($files)) {
627
+					foreach($files as $file)
604 628
 			{
605 629
 				if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
606 630
 				{
607
-					$_storage_size += $file['size']; //bytes
631
+					$_storage_size += $file['size'];
632
+		}
633
+		//bytes
608 634
 					$_backup_files_list[] = $file;
609 635
 				}
610 636
 			}
@@ -618,9 +644,11 @@  discard block
 block discarded – undo
618 644
 		{
619 645
 			//processing rule folder capacity
620 646
 			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
621
-			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
647
+			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) {
648
+				//bytes	
622 649
 			{
623 650
 				$this->storage_filesystem->delete($file['path']);
651
+			}
624 652
 				$_storage_size -= $file['size'];
625 653
 				$this->logger->info("Deleting backup ".$file['path']." matching rule", array("STORAGE SIZE LIMIT", $_storage_size." >= ".$set_storage_limit));
626 654
 			}
@@ -661,34 +689,37 @@  discard block
 block discarded – undo
661 689
 	
662 690
 	public function process_backup_name($name = "", $max_length=100)
663 691
 	{
664
-		if(!$name)
665
-			$name = $this->xcloner_settings->get_default_backup_name();
692
+		if(!$name) {
693
+					$name = $this->xcloner_settings->get_default_backup_name();
694
+		}
666 695
 		
667 696
 		foreach($this->backup_name_tags as $tag)
668 697
 		{
669
-			if($tag == '[time]')
670
-				$name = str_replace($tag, date("Y-m-d_H-i"),$name);
671
-			elseif($tag == '[hostname]')
672
-				$name = str_replace($tag, gethostname() ,$name);	
673
-			elseif($tag == '[domain]')
698
+			if($tag == '[time]') {
699
+							$name = str_replace($tag, date("Y-m-d_H-i"),$name);
700
+			} elseif($tag == '[hostname]') {
701
+							$name = str_replace($tag, gethostname() ,$name);
702
+			} elseif($tag == '[domain]')
674 703
 			{
675 704
 				$domain = parse_url(admin_url(), PHP_URL_HOST);
676 705
 				$name = str_replace($tag, $domain ,$name);	
677 706
 			}
678 707
 		}
679 708
 		
680
-		if($max_length)
681
-			$name = substr($name, 0, $max_length);
709
+		if($max_length) {
710
+					$name = substr($name, 0, $max_length);
711
+		}
682 712
 			
683 713
 		return $name;	
684 714
 	}
685 715
 	
686 716
 	public function sort_by( &$array, $field, $direction = 'asc')
687 717
 	{
688
-		if(strtolower($direction) == "desc" || $direction == SORT_DESC)
689
-			$direction = SORT_DESC;
690
-		else
691
-			$direction = SORT_ASC;
718
+		if(strtolower($direction) == "desc" || $direction == SORT_DESC) {
719
+					$direction = SORT_DESC;
720
+		} else {
721
+					$direction = SORT_ASC;
722
+		}
692 723
 					
693 724
 	   $array = $this->array_orderby($array, $field, $direction);
694 725
 	    
@@ -705,10 +736,11 @@  discard block
 block discarded – undo
705 736
 	            $tmp = array();
706 737
 	            foreach ($data as $key => $row)
707 738
 	            {
708
-					if(is_array($row))
709
-						$tmp[$key] = $row[$field];
710
-					else
711
-						$tmp[$key] = $row->$field;
739
+					if(is_array($row)) {
740
+											$tmp[$key] = $row[$field];
741
+					} else {
742
+											$tmp[$key] = $row->$field;
743
+					}
712 744
 				}
713 745
 	            $args[$n] = $tmp;
714 746
 	            }
@@ -746,28 +778,32 @@  discard block
 block discarded – undo
746 778
 		
747 779
 		if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
748 780
 		{
749
-			if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
750
-				return "> ".$xcloner_exclude_files_larger_than_mb."MB";
781
+			if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) {
782
+							return "> ".$xcloner_exclude_files_larger_than_mb."MB";
783
+			}
751 784
 		}
752 785
 		
753
-		if(!sizeof($this->excluded_files))
754
-			$this->set_excluded_files();
786
+		if(!sizeof($this->excluded_files)) {
787
+					$this->set_excluded_files();
788
+		}
755 789
 				
756
-		if(is_array($this->excluded_files))
757
-		foreach($this->excluded_files as $excluded_file_pattern)
790
+		if(is_array($this->excluded_files)) {
791
+				foreach($this->excluded_files as $excluded_file_pattern)
758 792
 		{
759 793
 			if($excluded_file_pattern == "/")
760 794
 				$needle = "$";
761
-			else
762
-				$needle = "$".$excluded_file_pattern;
795
+		} else {
796
+							$needle = "$".$excluded_file_pattern;
797
+			}
763 798
 				
764 799
 			if(strstr("$".$file['path'], $needle)){
765 800
 				return $excluded_file_pattern;
766 801
 			}
767 802
 		}
768 803
 		
769
-		if( $regex = $this->is_excluded_regex($file))
770
-			return $regex;
804
+		if( $regex = $this->is_excluded_regex($file)) {
805
+					return $regex;
806
+		}
771 807
 		
772 808
 		if($file['type'] == "file")
773 809
 		{
@@ -830,13 +866,15 @@  discard block
 block discarded – undo
830 866
 			foreach($regex_patterns as $excluded_file_pattern)
831 867
 			{
832 868
 				
833
-				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r")
834
-					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
869
+				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") {
870
+									$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
871
+				}
835 872
 					
836
-				if($file['path'] == "/")
837
-					$needle = "/";
838
-				else
839
-					$needle = "/".$file['path'];
873
+				if($file['path'] == "/") {
874
+									$needle = "/";
875
+				} else {
876
+									$needle = "/".$file['path'];
877
+				}
840 878
 				//echo $needle."---".$excluded_file_pattern."---\n";
841 879
 				
842 880
 				if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){
@@ -852,10 +890,12 @@  discard block
 block discarded – undo
852 890
 	{
853 891
 		$this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
854 892
 		
855
-		if(!isset($file['size']))
856
-			$file['size'] = 0;
857
-		if(!isset($file['visibility']))	
858
-			$file['visibility'] = "private";
893
+		if(!isset($file['size'])) {
894
+					$file['size'] = 0;
895
+		}
896
+		if(!isset($file['visibility'])) {
897
+					$file['visibility'] = "private";
898
+		}
859 899
 		
860 900
 		$csv_filename = str_replace('"','""', $file['path']);
861 901
 		
@@ -866,7 +906,7 @@  discard block
 block discarded – undo
866 906
 		if($file['type'] == "dir"){
867 907
 			try{
868 908
 				$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n");
869
-			}catch(Exception $e){
909
+			} catch(Exception $e){
870 910
 				$this->logger->error($e->getMessage());	
871 911
 			}
872 912
 		}
@@ -890,7 +930,7 @@  discard block
 block discarded – undo
890 930
 			
891 931
 			$this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
892 932
 		
893
-		}catch(Exception $e){
933
+		} catch(Exception $e){
894 934
 		
895 935
 			$this->logger->error($e->getMessage());	
896 936
 		}
@@ -905,35 +945,39 @@  discard block
 block discarded – undo
905 945
 	
906 946
 	public function get_filesystem($system = "")
907 947
 	{
908
-		if($system == "storage_filesystem_append")
909
-			return $this->storage_filesystem_append;
910
-		elseif($system == "tmp_filesystem_append")
911
-			return $this->tmp_filesystem_append;
912
-		elseif($system == "tmp_filesystem")
913
-			return $this->tmp_filesystem;
914
-		elseif($system == "storage_filesystem")
915
-			return $this->storage_filesystem;
916
-		else
917
-			return $this->start_filesystem;	
948
+		if($system == "storage_filesystem_append") {
949
+					return $this->storage_filesystem_append;
950
+		} elseif($system == "tmp_filesystem_append") {
951
+					return $this->tmp_filesystem_append;
952
+		} elseif($system == "tmp_filesystem") {
953
+					return $this->tmp_filesystem;
954
+		} elseif($system == "storage_filesystem") {
955
+					return $this->storage_filesystem;
956
+		} else {
957
+					return $this->start_filesystem;
958
+		}
918 959
 	}
919 960
 	
920 961
 	public function get_adapter($system)
921 962
 	{
922
-		if($system == "tmp_filesystem")
923
-			return $this->tmp_adapter;
924
-		elseif($system == "storage_filesystem")
925
-			return $this->storage_adapter;
926
-		else
927
-			return $this->start_adapter;	
963
+		if($system == "tmp_filesystem") {
964
+					return $this->tmp_adapter;
965
+		} elseif($system == "storage_filesystem") {
966
+					return $this->storage_adapter;
967
+		} else {
968
+					return $this->start_adapter;
969
+		}
928 970
 	}
929 971
 	
930 972
 	private function scan_finished()
931 973
 	{
932
-		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
933
-			return false;
974
+		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) {
975
+					return false;
976
+		}
934 977
 		
935
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))
936
-			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
978
+		if($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
979
+					$this->tmp_filesystem->delete($this->get_temp_dir_handler());
980
+		}
937 981
 		
938 982
 		$this->logger->debug(sprintf(("File scan finished")));
939 983
 			
Please login to merge, or discard this patch.
includes/class-xcloner-scheduler.php 1 patch
Braces   +17 added lines, -13 removed lines patch added patch discarded remove patch
@@ -48,10 +48,11 @@  discard block
 block discarded – undo
48 48
 		{
49 49
 			$new_list= array();
50 50
 			
51
-			foreach($list as $res)
52
-				if($res->status)
51
+			foreach($list as $res) {
52
+							if($res->status)
53 53
 				{
54 54
 					$res->next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id))+(get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
55
+			}
55 56
 					$new_list[] = $res;
56 57
 				}
57 58
 			$list = $new_list;	
@@ -77,8 +78,9 @@  discard block
 block discarded – undo
77 78
 	{
78 79
 		$data = $this->db->get_row("SELECT * FROM ".$this->scheduler_table." WHERE id=".$id, ARRAY_A);
79 80
 		
80
-		if(!$data)
81
-			return false;
81
+		if(!$data) {
82
+					return false;
83
+		}
82 84
 		
83 85
 		$params = json_decode($data['params']);
84 86
 		
@@ -131,11 +133,11 @@  discard block
 block discarded – undo
131 133
 				if($schedule->recurrence == "single")
132 134
 				{
133 135
 					wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id));
134
-				}else{	
136
+				} else{	
135 137
 					wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) );
136 138
 				}
137 139
 					
138
-			}elseif(!$schedule->status)
140
+			} elseif(!$schedule->status)
139 141
 			{
140 142
 				$timestamp = wp_next_scheduled( $hook , array($schedule->id) );
141 143
 				wp_unschedule_event( $timestamp, $hook, array($schedule->id) );
@@ -157,7 +159,7 @@  discard block
 block discarded – undo
157 159
 			if($schedule->recurrence == "single")
158 160
 			{
159 161
 				wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id));
160
-			}else{	
162
+			} else{	
161 163
 				wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) );
162 164
 			}
163 165
 				
@@ -294,8 +296,9 @@  discard block
 block discarded – undo
294 296
 		
295 297
 		//getting the last backup archive file
296 298
 		$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
297
-		if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
298
-				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
299
+		if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
300
+						$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
301
+		}
299 302
 		
300 303
 		$this->update_last_backup($schedule['id'], $return['extra']['backup_parent']);
301 304
 		
@@ -305,8 +308,9 @@  discard block
 block discarded – undo
305 308
 			
306 309
 			$this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON"));
307 310
 			
308
-			if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage"))
309
-				call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage']));
311
+			if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) {
312
+							call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage']));
313
+			}
310 314
 		}
311 315
 		
312 316
 		
@@ -318,7 +322,7 @@  discard block
 block discarded – undo
318 322
 				$subject = sprintf(__("%s - new backup generated %s") , $schedule['name'], $return['extra']['backup_parent']);
319 323
 				
320 324
 				$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional);
321
-			}catch(Exception $e)
325
+			} catch(Exception $e)
322 326
 			{
323 327
 				$this->logger->error($e->getMessage());
324 328
 			}
@@ -337,7 +341,7 @@  discard block
 block discarded – undo
337 341
 
338 342
 			$this->__xcloner_scheduler_callback($id, $schedule);
339 343
 			
340
-		}catch(Exception $e){
344
+		} catch(Exception $e){
341 345
 			
342 346
 			//send email to site admin if email notification is not set in the scheduler
343 347
 			if(!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification)
Please login to merge, or discard this patch.
xcloner.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 }
32 32
 
33 33
 //i will not load the plugin outside admin or cron
34
-if(!is_admin() and !defined('DOING_CRON'))
34
+if(!is_admin() and !defined('DOING_CRON')) {
35 35
 	return;
36
+}
36 37
 
37 38
 if(!defined("DS"))
38 39
 {
@@ -126,7 +127,7 @@  discard block
 block discarded – undo
126 127
 	
127 128
 	$xcloner_plugin = run_xcloner();
128 129
 	
129
-}catch(Exception $e){
130
+} catch(Exception $e){
130 131
 	
131 132
 	echo $e->getMessage();
132 133
 	
Please login to merge, or discard this patch.
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.