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 ( 51d0da...ea440c )
by Liuta
04:02 queued 45s
created
includes/class-xcloner-file-system.php 1 patch
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -4,12 +4,12 @@  discard block
 block discarded – undo
4 4
 use League\Flysystem\Util;
5 5
 use League\Flysystem\Adapter\Local;
6 6
 
7
-class Xcloner_File_System{
7
+class Xcloner_File_System {
8 8
 	
9
-	private $excluded_files 			= "";
10
-	private $excluded_files_by_default	= array("administrator/backups", "wp-content/backups");
11
-	private $included_files_handler 	= "backup_files.csv";
12
-	private $temp_dir_handler 			= ".dir";
9
+	private $excluded_files = "";
10
+	private $excluded_files_by_default = array("administrator/backups", "wp-content/backups");
11
+	private $included_files_handler = "backup_files.csv";
12
+	private $temp_dir_handler = ".dir";
13 13
 	public  $filesystem;
14 14
 	public  $tmp_filesystem;
15 15
 	public  $storage_filesystem;
@@ -34,39 +34,39 @@  discard block
 block discarded – undo
34 34
 		$this->logger = new XCloner_Logger('xcloner_file_system', $hash);
35 35
 		$this->xcloner_requirements = new Xcloner_Requirements();
36 36
 
37
-		$this->xcloner_settings 		= new Xcloner_Settings($hash);
37
+		$this->xcloner_settings = new Xcloner_Settings($hash);
38 38
 
39
-		try{
39
+		try {
40 40
 			
41
-			$this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(),LOCK_EX, 'SKIP_LINKS');
41
+			$this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(), LOCK_EX, 'SKIP_LINKS');
42 42
 			$this->start_filesystem = new Filesystem($this->start_adapter, new Config([
43 43
 					'disable_asserts' => true,
44 44
 				]));
45 45
 			
46
-			$this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX, 'SKIP_LINKS');
46
+			$this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX, 'SKIP_LINKS');
47 47
 			$this->tmp_filesystem = new Filesystem($this->tmp_adapter, new Config([
48 48
 					'disable_asserts' => true,
49 49
 				]));
50
-			$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX|FILE_APPEND, 'SKIP_LINKS');
50
+			$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
51 51
 			$this->tmp_filesystem_append = new Filesystem($adapter, new Config([
52 52
 					'disable_asserts' => true,
53 53
 				]));
54 54
 
55
-			$adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),LOCK_EX, 'SKIP_LINKS');
55
+			$adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), LOCK_EX, 'SKIP_LINKS');
56 56
 			$this->storage_filesystem = new Filesystem($adapter, new Config([
57 57
 					'disable_asserts' => true,
58 58
 				]));	
59 59
 			
60
-			$this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),FILE_APPEND, 'SKIP_LINKS');
60
+			$this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), FILE_APPEND, 'SKIP_LINKS');
61 61
 			$this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
62 62
 					'disable_asserts' => true,
63 63
 				]));
64
-		}catch(Exception $e){
64
+		}catch (Exception $e) {
65 65
 			return false;
66 66
 		}
67 67
 		
68 68
 		
69
-		if($value = get_option('xcloner_directories_to_scan_per_request'))
69
+		if ($value = get_option('xcloner_directories_to_scan_per_request'))
70 70
 			$this->folders_to_process_per_session = $value;
71 71
 
72 72
 	}
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		return $this->getMetadataFull('storage_adapter', $file);
128 128
 	}
129 129
 	
130
-	public function get_included_files_handler($metadata  = 0)
130
+	public function get_included_files_handler($metadata = 0)
131 131
 	{
132 132
 		$path = $this->included_files_handler;
133
-		if(!$metadata)
133
+		if (!$metadata)
134 134
 			return $path;
135 135
 		
136 136
 		$spl_info = $this->getMetadataFull('tmp_adapter', $path);
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
 	{
148 148
 		$files = $this->get_backup_archives_list();
149 149
 		
150
-		if(is_array($files))
151
-			$this->sort_by($files, "timestamp","desc");
150
+		if (is_array($files))
151
+			$this->sort_by($files, "timestamp", "desc");
152 152
 		
153 153
 		$new_list = array();
154 154
 		
155
-		foreach($files as $key=>$file)
156
-			if(!isset($file['parent']))
155
+		foreach ($files as $key=>$file)
156
+			if (!isset($file['parent']))
157 157
 				$new_list[] = ($files[$key]);
158 158
 
159
-		if(isset($new_list[0]))
159
+		if (isset($new_list[0]))
160 160
 			return $new_list[0];
161 161
 	}
162 162
 	
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 	{
165 165
 		$files = $this->get_backup_archives_list();
166 166
 
167
-		if(is_array($files))
168
-			$this->sort_by($files, "timestamp","desc");
167
+		if (is_array($files))
168
+			$this->sort_by($files, "timestamp", "desc");
169 169
 		
170 170
 		$new_list = array();
171 171
 		
172
-		foreach($files as $key=>$file)
173
-			if(!isset($file['parent']))
172
+		foreach ($files as $key=>$file)
173
+			if (!isset($file['parent']))
174 174
 				$new_list[] = ($files[$key]);
175 175
 
176 176
 		return $new_list;
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 		$files = $this->get_backup_archives_list();
182 182
 		$total = 0;
183 183
 		
184
-		if(is_array($files))
185
-			foreach($files as $file)
184
+		if (is_array($files))
185
+			foreach ($files as $file)
186 186
 				$total += $file['size'];
187 187
 				
188 188
 		return $total;		
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	
191 191
 	public function is_part($backup_name)
192 192
 	{
193
-		if(stristr($backup_name, "-part"))
193
+		if (stristr($backup_name, "-part"))
194 194
 			return true;
195 195
 		
196 196
 		return false;	
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	
199 199
 	public function is_multipart($backup_name)
200 200
 	{
201
-		if(stristr($backup_name, "-multipart"))
201
+		if (stristr($backup_name, "-multipart"))
202 202
 			return true;
203 203
 		
204 204
 		return false;	
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	public function get_backup_size($backup_name)
208 208
 	{
209 209
 		$backup_size = $this->get_storage_filesystem()->getSize($backup_name);
210
-		if($this->is_multipart($backup_name))
210
+		if ($this->is_multipart($backup_name))
211 211
 		{
212 212
 			$backup_parts = $this->get_multipart_files($backup_name);
213
-			foreach($backup_parts as $part_file)
213
+			foreach ($backup_parts as $part_file)
214 214
 				$backup_size += $this->get_storage_filesystem()->getSize($part_file);
215 215
 		}
216 216
 		
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 	{
222 222
 		$files = array();
223 223
 		
224
-		if($this->is_multipart($backup_name))
224
+		if ($this->is_multipart($backup_name))
225 225
 		{
226 226
 			$lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($backup_name));
227
-			foreach($lines as $line)
227
+			foreach ($lines as $line)
228 228
 			{
229
-				if($line)
229
+				if ($line)
230 230
 				{
231 231
 					$data = str_getcsv($line);
232 232
 					$files[] = $data[0];
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
 	
240 240
 	public function delete_backup_by_name($backup_name)
241 241
 	{
242
-		if($this->is_multipart($backup_name))
242
+		if ($this->is_multipart($backup_name))
243 243
 		{
244 244
 			$lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($backup_name));
245
-			foreach($lines as $line)
245
+			foreach ($lines as $line)
246 246
 			{
247
-				if($line)
247
+				if ($line)
248 248
 				{
249 249
 					$data = str_getcsv($line);
250 250
 					$this->get_storage_filesystem()->delete($data[0]);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			}
253 253
 		}
254 254
 		
255
-		if($this->get_storage_filesystem()->delete($backup_name))
255
+		if ($this->get_storage_filesystem()->delete($backup_name))
256 256
 			$return = true;
257 257
 		else
258 258
 			$return = false;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 		return $return;	
261 261
 	}
262 262
 	
263
-	public function getMetadataFull($adapter = "storage_adapter" , $path)
263
+	public function getMetadataFull($adapter = "storage_adapter", $path)
264 264
     {
265 265
         $location = $this->$adapter->applyPathPrefix($path);
266 266
         $spl_info = new SplFileInfo($location);
@@ -273,25 +273,25 @@  discard block
 block discarded – undo
273 273
 	{
274 274
 		$list = array();
275 275
 		
276
-		if(method_exists($this->get_storage_filesystem(), "listContents"))
276
+		if (method_exists($this->get_storage_filesystem(), "listContents"))
277 277
 			$list = $this->get_storage_filesystem()->listContents();
278 278
 
279 279
 		
280 280
 		$backup_files = array();
281 281
 		$parents = array();
282 282
 		
283
-		foreach($list as $file_info)
283
+		foreach ($list as $file_info)
284 284
 		{
285 285
 			$data = array();
286 286
 			
287
-			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
287
+			if (isset($file_info['extension']) and $file_info['extension'] == "csv")
288 288
 			{
289 289
 				$lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($file_info['path']));
290
-				foreach($lines as $line)
291
-					if($line)
290
+				foreach ($lines as $line)
291
+					if ($line)
292 292
 					{
293 293
 						$data = str_getcsv($line);
294
-						if(is_array($data)){
294
+						if (is_array($data)) {
295 295
 							$parents[$data[0]] = $file_info['path'];
296 296
 							$file_info['childs'][] = $data;
297 297
 							$file_info['size'] += $data[2];
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 						
301 301
 			}
302 302
 			
303
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
303
+			if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
304 304
 				$backup_files[$file_info['path']] = $file_info;
305 305
 		}
306 306
 		
307
-		foreach($backup_files as $key=>$file_info)
307
+		foreach ($backup_files as $key=>$file_info)
308 308
 		{
309
-			if(isset($parents[$file_info['path']]))
309
+			if (isset($parents[$file_info['path']]))
310 310
 				$backup_files[$key]['parent'] = $parents[$file_info['path']];
311 311
 		}
312 312
 		
@@ -315,40 +315,40 @@  discard block
 block discarded – undo
315 315
 	
316 316
 	public function start_file_recursion($init = 0)
317 317
 	{
318
-		if($init)
318
+		if ($init)
319 319
 		{
320 320
 			$this->logger->info(sprintf(__("Starting the filesystem scanner on root folder %s"), $this->xcloner_settings->get_xcloner_start_path()));
321 321
 			$this->do_system_init();
322 322
 		}
323 323
 		
324
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler())){
324
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
325 325
 		//.dir exists, we presume we have files to iterate	
326 326
 			$content = $this->tmp_filesystem->read($this->get_temp_dir_handler());
327 327
 			$files = array_filter(explode("\n", $content));
328 328
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
329 329
 			
330 330
 			$counter = 0;
331
-			foreach($files as $file)
331
+			foreach ($files as $file)
332 332
 			{
333
-				if($counter < $this->folders_to_process_per_session){
333
+				if ($counter < $this->folders_to_process_per_session) {
334 334
 					$this->build_files_list($file);
335 335
 					$counter++;
336
-				}else{
336
+				} else {
337 337
 					$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n");
338 338
 				}
339 339
 			}
340
-		}else{
340
+		} else {
341 341
 			$this->build_files_list();
342 342
 		}
343 343
 		
344
-		if($this->scan_finished())
344
+		if ($this->scan_finished())
345 345
 		{
346 346
 			$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata("index.html");
347 347
 			$this->store_file($metadata_dumpfile, 'tmp_filesystem');
348 348
 			$this->files_counter++;
349 349
 		
350 350
 			//adding included dump file to the included files list
351
-			if($this->get_tmp_filesystem()->has($this->get_included_files_handler()))
351
+			if ($this->get_tmp_filesystem()->has($this->get_included_files_handler()))
352 352
 			{
353 353
 				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->get_included_files_handler());
354 354
 				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
 			}
357 357
 		
358 358
 			//adding a default index.html to the temp xcloner folder
359
-			if(!$this->get_tmp_filesystem()->has("index.html"))
359
+			if (!$this->get_tmp_filesystem()->has("index.html"))
360 360
 			{
361
-				$this->get_tmp_filesystem()->write("index.html","");
361
+				$this->get_tmp_filesystem()->write("index.html", "");
362 362
 			}
363 363
 			
364 364
 			//adding the default log file
365
-			if($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1)))
365
+			if ($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1)))
366 366
 			{
367 367
 				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->xcloner_settings->get_logger_filename(1));
368 368
 				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	{
380 380
 		$return = array();
381 381
 		$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler();
382
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
382
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
383 383
 			$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
384 384
 		
385 385
 		return $return;
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 		
393 393
 		$contents = $this->get_tmp_filesystem()->listContents();
394 394
 	
395
-		if(is_array($contents))
396
-		foreach($contents as $file_info)
395
+		if (is_array($contents))
396
+		foreach ($contents as $file_info)
397 397
 			$this->get_tmp_filesystem()->delete($file_info['path']);
398 398
 			
399 399
 		@rmdir($this->xcloner_settings->get_xcloner_tmp_path());
@@ -405,16 +405,16 @@  discard block
 block discarded – undo
405 405
 	{
406 406
 		$this->files_counter = 0;
407 407
 		
408
-		if(!$this->storage_filesystem->has("index.html"))	
409
-			$this->storage_filesystem->write("index.html","");
408
+		if (!$this->storage_filesystem->has("index.html"))	
409
+			$this->storage_filesystem->write("index.html", "");
410 410
 		
411
-		if(!$this->tmp_filesystem->has("index.html"))	
412
-			$this->tmp_filesystem->write("index.html","");
411
+		if (!$this->tmp_filesystem->has("index.html"))	
412
+			$this->tmp_filesystem->write("index.html", "");
413 413
 			
414
-		if($this->tmp_filesystem->has($this->get_included_files_handler()))
414
+		if ($this->tmp_filesystem->has($this->get_included_files_handler()))
415 415
 			$this->tmp_filesystem->delete($this->get_included_files_handler());
416 416
 		
417
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
417
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
418 418
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
419 419
 	}
420 420
 	
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	
436 436
 	public function set_excluded_files($excluded_files = array())
437 437
 	{
438
-		if(!is_array($excluded_files))
438
+		if (!is_array($excluded_files))
439 439
 			$excluded_files = array();
440 440
 			
441 441
 		$this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
@@ -458,33 +458,33 @@  discard block
 block discarded – undo
458 458
 		$this->logger->debug(sprintf(("Building the files system list")));
459 459
 		
460 460
 		//if we start with the root folder(empty value), we initializa the file system
461
-		if(!$folder){
461
+		if (!$folder) {
462 462
 			
463 463
 		}
464 464
 			
465
-		try{
465
+		try {
466 466
 			
467 467
 			$files = $this->start_filesystem->listContents($folder);
468
-			foreach($files as $file)
468
+			foreach ($files as $file)
469 469
 			{
470
-				if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
470
+				if (!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
471 471
 				{
472
-					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE"));
472
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN", "NOT READABLE"));
473 473
 				}
474
-				elseif(!$matching_pattern = $this->is_excluded($file) ){
475
-					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE"));
474
+				elseif (!$matching_pattern = $this->is_excluded($file)) {
475
+					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN", "INCLUDE"));
476 476
 					$file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
477 477
 					$this->store_file($file);
478 478
 					$this->files_counter++;
479
-					if(isset($file['size']))
479
+					if (isset($file['size']))
480 480
 						$this->files_size += $file['size'];
481 481
 					
482
-				}else{
483
-					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE"));
482
+				} else {
483
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN", "EXCLUDE"));
484 484
 					}
485 485
 			}
486 486
 			
487
-		}catch(Exception $e){
487
+		}catch (Exception $e) {
488 488
 			
489 489
 			$this->logger->error($e->getMessage());
490 490
 		
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 				
499 499
 		$start_time = microtime();
500 500
 		
501
-		$data = str_repeat(rand(0,9), 1024*1024); //write 1MB data
501
+		$data = str_repeat(rand(0, 9), 1024 * 1024); //write 1MB data
502 502
 		
503
-		try{
503
+		try {
504 504
 			$this->tmp_filesystem->write($tmp_file, $data);
505 505
 			
506 506
 			$end_time = microtime() - $start_time;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 		
512 512
 			$this->tmp_filesystem->delete($tmp_file);
513 513
 		
514
-		}catch(Exception $e){
514
+		}catch (Exception $e) {
515 515
 			
516 516
 			$this->logger->error($e->getMessage());
517 517
 			
@@ -532,10 +532,10 @@  discard block
 block discarded – undo
532 532
 		
533 533
 		$files = $this->storage_filesystem->listContents();
534 534
 		
535
-		if(is_array($files))
536
-			foreach($files as $file)
535
+		if (is_array($files))
536
+			foreach ($files as $file)
537 537
 			{
538
-				if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
538
+				if (isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
539 539
 				{
540 540
 					$_storage_size += $file['size']; //bytes
541 541
 					$_backup_files_list[] = $file;
@@ -543,15 +543,15 @@  discard block
 block discarded – undo
543 543
 			}
544 544
 		
545 545
 		
546
-		$this->sort_by($_backup_files_list, "timestamp","asc");
546
+		$this->sort_by($_backup_files_list, "timestamp", "asc");
547 547
 		
548 548
 		$_backups_counter = sizeof($_backup_files_list);
549 549
 				
550
-		foreach($_backup_files_list as $file)
550
+		foreach ($_backup_files_list as $file)
551 551
 		{
552 552
 			//processing rule folder capacity
553
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
554
-			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
553
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
554
+			$_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
555 555
 			{
556 556
 				$this->storage_filesystem->delete($file['path']);
557 557
 				$_storage_size -= $file['size'];
@@ -559,14 +559,14 @@  discard block
 block discarded – undo
559 559
 			}
560 560
 			
561 561
 			//processing rule days limit
562
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp'])
562
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp'])
563 563
 			{
564 564
 				$this->storage_filesystem->delete($file['path']);
565 565
 				$this->logger->info("Deleting backup ".$file['path']." matching rule", array("RETENTION LIMIT TIMESTAMP", $file['timestamp']." =< ".$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days')));
566 566
 			}
567 567
 			
568 568
 			//processing backup countert limit
569
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives'))
569
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives'))
570 570
 			{
571 571
 				$this->storage_filesystem->delete($file['path']);
572 572
 				$_backups_counter--;
@@ -592,33 +592,33 @@  discard block
 block discarded – undo
592 592
 	
593 593
 	}
594 594
 	
595
-	public function process_backup_name($name = "", $max_length=100)
595
+	public function process_backup_name($name = "", $max_length = 100)
596 596
 	{
597
-		if(!$name)
597
+		if (!$name)
598 598
 			$name = $this->xcloner_settings->get_default_backup_name();
599 599
 		
600
-		foreach($this->backup_name_tags as $tag)
600
+		foreach ($this->backup_name_tags as $tag)
601 601
 		{
602
-			if($tag == '[time]')
603
-				$name = str_replace($tag, date("Y-m-d_H-i"),$name);
604
-			elseif($tag == '[hostname]')
605
-				$name = str_replace($tag, gethostname() ,$name);	
606
-			elseif($tag == '[domain]')
602
+			if ($tag == '[time]')
603
+				$name = str_replace($tag, date("Y-m-d_H-i"), $name);
604
+			elseif ($tag == '[hostname]')
605
+				$name = str_replace($tag, gethostname(), $name);	
606
+			elseif ($tag == '[domain]')
607 607
 			{
608 608
 				$domain = parse_url(admin_url(), PHP_URL_HOST);
609
-				$name = str_replace($tag, $domain ,$name);	
609
+				$name = str_replace($tag, $domain, $name);	
610 610
 			}
611 611
 		}
612 612
 		
613
-		if($max_length)
613
+		if ($max_length)
614 614
 			$name = substr($name, 0, $max_length);
615 615
 			
616 616
 		return $name;	
617 617
 	}
618 618
 	
619
-	public function sort_by( &$array, $field, $direction = 'asc')
619
+	public function sort_by(&$array, $field, $direction = 'asc')
620 620
 	{
621
-		if(strtolower($direction) == "desc" || $direction == SORT_DESC)
621
+		if (strtolower($direction) == "desc" || $direction == SORT_DESC)
622 622
 			$direction = SORT_DESC;
623 623
 		else
624 624
 			$direction = SORT_ASC;
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 	            $tmp = array();
639 639
 	            foreach ($data as $key => $row)
640 640
 	            {
641
-					if(is_array($row))
641
+					if (is_array($row))
642 642
 						$tmp[$key] = $row[$field];
643 643
 					else
644 644
 						$tmp[$key] = $row->$field;
@@ -657,29 +657,29 @@  discard block
 block discarded – undo
657 657
 	{
658 658
 		$this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path']));
659 659
 		
660
-		if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
660
+		if ($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
661 661
 		{
662
-			if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
662
+			if (isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
663 663
 				return "> ".$xcloner_exclude_files_larger_than_mb."MB";
664 664
 		}
665 665
 		
666
-		if(!sizeof($this->excluded_files))
666
+		if (!sizeof($this->excluded_files))
667 667
 			$this->set_excluded_files();
668 668
 				
669
-		if(is_array($this->excluded_files))
670
-		foreach($this->excluded_files as $excluded_file_pattern)
669
+		if (is_array($this->excluded_files))
670
+		foreach ($this->excluded_files as $excluded_file_pattern)
671 671
 		{
672
-			if($excluded_file_pattern == "/")
672
+			if ($excluded_file_pattern == "/")
673 673
 				$needle = "$";
674 674
 			else
675 675
 				$needle = "$".$excluded_file_pattern;
676 676
 				
677
-			if(strstr("$".$file['path'], $needle)){
677
+			if (strstr("$".$file['path'], $needle)) {
678 678
 				return $excluded_file_pattern;
679 679
 			}
680 680
 		}
681 681
 		
682
-		if( $regex = $this->is_excluded_regex($file))
682
+		if ($regex = $this->is_excluded_regex($file))
683 683
 			return $regex;
684 684
 		
685 685
 		return false;
@@ -725,25 +725,25 @@  discard block
 block discarded – undo
725 725
 		
726 726
 		//print_r($regex_patterns);exit;
727 727
 		
728
-		if(is_array($regex_patterns))
728
+		if (is_array($regex_patterns))
729 729
 		{
730 730
 			//$this->excluded_files = array();
731 731
 			//$this->excluded_files[] ="(.*)\.(git)(.*)$";
732 732
 			//$this->excluded_files[] ="wp-content\/backups(.*)$";
733 733
 			
734
-			foreach($regex_patterns as $excluded_file_pattern)
734
+			foreach ($regex_patterns as $excluded_file_pattern)
735 735
 			{
736 736
 				
737
-				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r")
738
-					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
737
+				if (substr($excluded_file_pattern, strlen($excluded_file_pattern) - 1, strlen($excluded_file_pattern)) == "\r")
738
+					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern) - 1);
739 739
 					
740
-				if($file['path'] == "/")
740
+				if ($file['path'] == "/")
741 741
 					$needle = "/";
742 742
 				else
743 743
 					$needle = "/".$file['path'];
744 744
 				//echo $needle."---".$excluded_file_pattern."---\n";
745 745
 				
746
-				if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){
746
+				if (@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)) {
747 747
 					return $excluded_file_pattern;
748 748
 				}
749 749
 			}
@@ -756,27 +756,27 @@  discard block
 block discarded – undo
756 756
 	{
757 757
 		$this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
758 758
 		
759
-		if(!isset($file['size']))
759
+		if (!isset($file['size']))
760 760
 			$file['size'] = 0;
761
-		if(!isset($file['visibility']))	
761
+		if (!isset($file['visibility']))	
762 762
 			$file['visibility'] = "private";
763 763
 		
764 764
 		$line = '"'.addslashes($file['path']).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL;
765 765
 		
766 766
 		$this->last_logged_file = $file['path'];
767 767
 		
768
-		try{
768
+		try {
769 769
 			$this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
770 770
 		
771
-		}catch(Exception $e){
771
+		}catch (Exception $e) {
772 772
 		
773 773
 			$this->logger->error($e->getMessage());	
774 774
 		}
775 775
 		
776
-		if($file['type'] == "dir"){
777
-			try{
776
+		if ($file['type'] == "dir") {
777
+			try {
778 778
 				$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n");
779
-			}catch(Exception $e){
779
+			}catch (Exception $e) {
780 780
 				$this->logger->error($e->getMessage());	
781 781
 			}
782 782
 		}
@@ -789,13 +789,13 @@  discard block
 block discarded – undo
789 789
 	
790 790
 	public function get_filesystem($system = "")
791 791
 	{
792
-		if($system == "storage_filesystem_append")
792
+		if ($system == "storage_filesystem_append")
793 793
 			return $this->storage_filesystem_append;
794
-		elseif($system == "tmp_filesystem_append")
794
+		elseif ($system == "tmp_filesystem_append")
795 795
 			return $this->tmp_filesystem_append;
796
-		elseif($system == "tmp_filesystem")
796
+		elseif ($system == "tmp_filesystem")
797 797
 			return $this->tmp_filesystem;
798
-		elseif($system == "storage_filesystem")
798
+		elseif ($system == "storage_filesystem")
799 799
 			return $this->storage_filesystem;
800 800
 		else
801 801
 			return $this->start_filesystem;	
@@ -803,9 +803,9 @@  discard block
 block discarded – undo
803 803
 	
804 804
 	public function get_adapter($system)
805 805
 	{
806
-		if($system == "tmp_filesystem")
806
+		if ($system == "tmp_filesystem")
807 807
 			return $this->tmp_adapter;
808
-		elseif($system == "storage_filesystem")
808
+		elseif ($system == "storage_filesystem")
809 809
 			return $this->storage_adapter;
810 810
 		else
811 811
 			return $this->start_adapter;	
@@ -813,10 +813,10 @@  discard block
 block discarded – undo
813 813
 	
814 814
 	private function scan_finished()
815 815
 	{
816
-		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
816
+		if ($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
817 817
 			return false;
818 818
 		
819
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))
819
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler()))
820 820
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
821 821
 		
822 822
 		$this->logger->debug(sprintf(("File scan finished")));
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 	
827 827
 	private function calc_to_bytes($mb_size)
828 828
 	{
829
-		return $mb_size*(1024*1024);
829
+		return $mb_size * (1024 * 1024);
830 830
 	}
831 831
 	
832 832
 }
Please login to merge, or discard this patch.