@@ -27,12 +27,16 @@ discard block |
||
27 | 27 | |
28 | 28 | <?php if($storage_selection):?> |
29 | 29 | <option value="" selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option> |
30 | - <?php else: ?> |
|
30 | + <?php else { |
|
31 | + : ?> |
|
31 | 32 | <option value="" selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option> |
32 | - <?php endif;?> |
|
33 | + <?php endif; |
|
34 | +} |
|
35 | +?> |
|
33 | 36 | |
34 | 37 | <?php foreach($available_storages as $storage=>$text):?> |
35 | - <option value="<?php echo $storage?>"<?php if($storage == $storage_selection) echo "selected"?>><?php echo $text?></option> |
|
38 | + <option value="<?php echo $storage?>"<?php if($storage == $storage_selection) { |
|
39 | + echo "selected"?>><?php echo $text?></option> |
|
36 | 40 | <?php endforeach?> |
37 | 41 | </select> |
38 | 42 | <?php endif?> |
@@ -60,16 +64,19 @@ discard block |
||
60 | 64 | |
61 | 65 | <?php |
62 | 66 | $i = 0; |
67 | +} |
|
63 | 68 | foreach($backup_list as $file_info):?> |
64 | 69 | <?php |
65 | - if($storage_selection == "gdrive") |
|
66 | - $file_info['path'] = $file_info['filename'].".".$file_info['extension']; |
|
70 | + if($storage_selection == "gdrive") { |
|
71 | + $file_info['path'] = $file_info['filename'].".".$file_info['extension']; |
|
72 | + } |
|
67 | 73 | $file_exists_on_local_storage = true; |
68 | 74 | |
69 | 75 | if($storage_selection) |
70 | 76 | { |
71 | - if(!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) |
|
72 | - $file_exists_on_local_storage = false; |
|
77 | + if(!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) { |
|
78 | + $file_exists_on_local_storage = false; |
|
79 | + } |
|
73 | 80 | } |
74 | 81 | |
75 | 82 | ?> |
@@ -100,8 +107,9 @@ discard block |
||
100 | 107 | $child_exists_on_local_storage = true; |
101 | 108 | if($storage_selection) |
102 | 109 | { |
103 | - if(!$xcloner_file_system->get_storage_filesystem()->has($child[0])) |
|
104 | - $child_exists_on_local_storage = false; |
|
110 | + if(!$xcloner_file_system->get_storage_filesystem()->has($child[0])) { |
|
111 | + $child_exists_on_local_storage = false; |
|
112 | + } |
|
105 | 113 | } |
106 | 114 | ?> |
107 | 115 | <?php if(!$child_exists_on_local_storage): ?> |
@@ -118,11 +126,14 @@ discard block |
||
118 | 126 | </ul> |
119 | 127 | <?php endif;?> |
120 | 128 | </td> |
121 | - <td><?php if(isset($file_info['timestamp'])) echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
129 | + <td><?php if(isset($file_info['timestamp'])) { |
|
130 | + echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
122 | 131 | <td><?php echo size_format($file_info['size'])?></td> |
123 | 132 | <td> |
124 | 133 | <?php if(!$storage_selection):?> |
125 | - <a href="#<?php echo $file_info['basename'];?>" class="download" title="<?php echo __('Download Backup','xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
134 | + <a href="#<?php echo $file_info['basename']; |
|
135 | +} |
|
136 | +?>" class="download" title="<?php echo __('Download Backup','xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
126 | 137 | |
127 | 138 | <?php if(sizeof($available_storages)):?> |
128 | 139 | <a href="#<?php echo $file_info['basename']?>" class="cloud-upload" title="<?php echo __('Send Backup To Remote Storage','xcloner-backup-and-restore')?>"><i class="material-icons">cloud_upload</i></a> |
@@ -65,13 +65,14 @@ discard block |
||
65 | 65 | $this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([ |
66 | 66 | 'disable_asserts' => true, |
67 | 67 | ])); |
68 | - }catch(Exception $e){ |
|
68 | + } catch(Exception $e){ |
|
69 | 69 | $this->logger->error("Filesystem Initialization Error: ".$e->getMessage()); |
70 | 70 | } |
71 | 71 | |
72 | 72 | |
73 | - if($value = get_option('xcloner_directories_to_scan_per_request')) |
|
74 | - $this->folders_to_process_per_session = $value; |
|
73 | + if($value = get_option('xcloner_directories_to_scan_per_request')) { |
|
74 | + $this->folders_to_process_per_session = $value; |
|
75 | + } |
|
75 | 76 | |
76 | 77 | } |
77 | 78 | |
@@ -103,8 +104,9 @@ discard block |
||
103 | 104 | $remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
104 | 105 | $method = "get_".$remote_storage_selection."_filesystem"; |
105 | 106 | |
106 | - if(!method_exists($remote_storage, $method)) |
|
107 | - return false; |
|
107 | + if(!method_exists($remote_storage, $method)) { |
|
108 | + return false; |
|
109 | + } |
|
108 | 110 | |
109 | 111 | list($adapter, $filesystem) = $remote_storage->$method(); |
110 | 112 | |
@@ -153,8 +155,9 @@ discard block |
||
153 | 155 | public function get_included_files_handler($metadata = 0) |
154 | 156 | { |
155 | 157 | $path = $this->included_files_handler; |
156 | - if(!$metadata) |
|
157 | - return $path; |
|
158 | + if(!$metadata) { |
|
159 | + return $path; |
|
160 | + } |
|
158 | 161 | |
159 | 162 | $spl_info = $this->getMetadataFull('tmp_adapter', $path); |
160 | 163 | return $spl_info; |
@@ -170,31 +173,36 @@ discard block |
||
170 | 173 | { |
171 | 174 | $files = $this->get_backup_archives_list(); |
172 | 175 | |
173 | - if(is_array($files)) |
|
174 | - $this->sort_by($files, "timestamp","desc"); |
|
176 | + if(is_array($files)) { |
|
177 | + $this->sort_by($files, "timestamp","desc"); |
|
178 | + } |
|
175 | 179 | |
176 | 180 | $new_list = array(); |
177 | 181 | |
178 | - foreach($files as $key=>$file) |
|
179 | - if(!isset($file['parent'])) |
|
182 | + foreach($files as $key=>$file) { |
|
183 | + if(!isset($file['parent'])) |
|
180 | 184 | $new_list[] = ($files[$key]); |
185 | + } |
|
181 | 186 | |
182 | - if(isset($new_list[0])) |
|
183 | - return $new_list[0]; |
|
187 | + if(isset($new_list[0])) { |
|
188 | + return $new_list[0]; |
|
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | public function get_latest_backups() |
187 | 193 | { |
188 | 194 | $files = $this->get_backup_archives_list(); |
189 | 195 | |
190 | - if(is_array($files)) |
|
191 | - $this->sort_by($files, "timestamp","desc"); |
|
196 | + if(is_array($files)) { |
|
197 | + $this->sort_by($files, "timestamp","desc"); |
|
198 | + } |
|
192 | 199 | |
193 | 200 | $new_list = array(); |
194 | 201 | |
195 | - foreach($files as $key=>$file) |
|
196 | - if(!isset($file['parent'])) |
|
202 | + foreach($files as $key=>$file) { |
|
203 | + if(!isset($file['parent'])) |
|
197 | 204 | $new_list[] = ($files[$key]); |
205 | + } |
|
198 | 206 | |
199 | 207 | return $new_list; |
200 | 208 | } |
@@ -204,25 +212,28 @@ discard block |
||
204 | 212 | $files = $this->get_backup_archives_list(); |
205 | 213 | $total = 0; |
206 | 214 | |
207 | - if(is_array($files)) |
|
208 | - foreach($files as $file) |
|
215 | + if(is_array($files)) { |
|
216 | + foreach($files as $file) |
|
209 | 217 | $total += $file['size']; |
218 | + } |
|
210 | 219 | |
211 | 220 | return $total; |
212 | 221 | } |
213 | 222 | |
214 | 223 | public function is_part($backup_name) |
215 | 224 | { |
216 | - if(stristr($backup_name, "-part")) |
|
217 | - return true; |
|
225 | + if(stristr($backup_name, "-part")) { |
|
226 | + return true; |
|
227 | + } |
|
218 | 228 | |
219 | 229 | return false; |
220 | 230 | } |
221 | 231 | |
222 | 232 | public function is_multipart($backup_name) |
223 | 233 | { |
224 | - if(stristr($backup_name, "-multipart")) |
|
225 | - return true; |
|
234 | + if(stristr($backup_name, "-multipart")) { |
|
235 | + return true; |
|
236 | + } |
|
226 | 237 | |
227 | 238 | return false; |
228 | 239 | } |
@@ -233,8 +244,9 @@ discard block |
||
233 | 244 | if($this->is_multipart($backup_name)) |
234 | 245 | { |
235 | 246 | $backup_parts = $this->get_multipart_files($backup_name); |
236 | - foreach($backup_parts as $part_file) |
|
237 | - $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
|
247 | + foreach($backup_parts as $part_file) { |
|
248 | + $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
|
249 | + } |
|
238 | 250 | } |
239 | 251 | |
240 | 252 | return $backup_size; |
@@ -275,10 +287,11 @@ discard block |
||
275 | 287 | } |
276 | 288 | } |
277 | 289 | |
278 | - if($this->get_storage_filesystem($storage_selection)->delete($backup_name)) |
|
279 | - $return = true; |
|
280 | - else |
|
281 | - $return = false; |
|
290 | + if($this->get_storage_filesystem($storage_selection)->delete($backup_name)) { |
|
291 | + $return = true; |
|
292 | + } else { |
|
293 | + $return = false; |
|
294 | + } |
|
282 | 295 | |
283 | 296 | return $return; |
284 | 297 | } |
@@ -297,8 +310,9 @@ discard block |
||
297 | 310 | $list = array(); |
298 | 311 | |
299 | 312 | |
300 | - if(method_exists($this->get_storage_filesystem($storage_selection), "listContents")) |
|
301 | - $list = $this->get_storage_filesystem($storage_selection)->listContents(); |
|
313 | + if(method_exists($this->get_storage_filesystem($storage_selection), "listContents")) { |
|
314 | + $list = $this->get_storage_filesystem($storage_selection)->listContents(); |
|
315 | + } |
|
302 | 316 | |
303 | 317 | |
304 | 318 | $backup_files = array(); |
@@ -311,10 +325,11 @@ discard block |
||
311 | 325 | $data = array(); |
312 | 326 | |
313 | 327 | $lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($file_info['path'])); |
314 | - foreach($lines as $line) |
|
315 | - if($line) |
|
328 | + foreach($lines as $line) { |
|
329 | + if($line) |
|
316 | 330 | { |
317 | 331 | $data = str_getcsv($line); |
332 | + } |
|
318 | 333 | if(is_array($data)){ |
319 | 334 | $parents[$data[0]] = $file_info['basename']; |
320 | 335 | $file_info['childs'][] = $data; |
@@ -324,8 +339,9 @@ discard block |
||
324 | 339 | |
325 | 340 | } |
326 | 341 | |
327 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
328 | - $backup_files[$file_info['path']] = $file_info; |
|
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; |
|
344 | + } |
|
329 | 345 | } |
330 | 346 | |
331 | 347 | foreach($backup_files as $key=>$file_info) |
@@ -335,8 +351,9 @@ discard block |
||
335 | 351 | //$backup_files[$key]['timestamp'] = $this->get_storage_filesystem($storage_selection)->getTimestamp($file_info['path']); |
336 | 352 | } |
337 | 353 | |
338 | - if(isset($parents[$file_info['basename']])) |
|
339 | - $backup_files[$key]['parent'] = $parents[$file_info['basename']]; |
|
354 | + if(isset($parents[$file_info['basename']])) { |
|
355 | + $backup_files[$key]['parent'] = $parents[$file_info['basename']]; |
|
356 | + } |
|
340 | 357 | } |
341 | 358 | |
342 | 359 | return $backup_files; |
@@ -362,11 +379,11 @@ discard block |
||
362 | 379 | if($counter < $this->folders_to_process_per_session){ |
363 | 380 | $this->build_files_list($file); |
364 | 381 | $counter++; |
365 | - }else{ |
|
382 | + } else{ |
|
366 | 383 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n"); |
367 | 384 | } |
368 | 385 | } |
369 | - }else{ |
|
386 | + } else{ |
|
370 | 387 | $this->build_files_list(); |
371 | 388 | } |
372 | 389 | |
@@ -408,8 +425,9 @@ discard block |
||
408 | 425 | { |
409 | 426 | $return = array(); |
410 | 427 | $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler(); |
411 | - if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
412 | - $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
|
428 | + if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) { |
|
429 | + $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
|
430 | + } |
|
413 | 431 | |
414 | 432 | return $return; |
415 | 433 | } |
@@ -421,9 +439,10 @@ discard block |
||
421 | 439 | |
422 | 440 | $contents = $this->get_tmp_filesystem()->listContents(); |
423 | 441 | |
424 | - if(is_array($contents)) |
|
425 | - foreach($contents as $file_info) |
|
442 | + if(is_array($contents)) { |
|
443 | + foreach($contents as $file_info) |
|
426 | 444 | $this->get_tmp_filesystem()->delete($file_info['path']); |
445 | + } |
|
427 | 446 | |
428 | 447 | @rmdir($this->xcloner_settings->get_xcloner_tmp_path()); |
429 | 448 | |
@@ -434,17 +453,21 @@ discard block |
||
434 | 453 | { |
435 | 454 | $this->files_counter = 0; |
436 | 455 | |
437 | - if(!$this->storage_filesystem->has("index.html")) |
|
438 | - $this->storage_filesystem->write("index.html",""); |
|
456 | + if(!$this->storage_filesystem->has("index.html")) { |
|
457 | + $this->storage_filesystem->write("index.html",""); |
|
458 | + } |
|
439 | 459 | |
440 | - if(!$this->tmp_filesystem->has("index.html")) |
|
441 | - $this->tmp_filesystem->write("index.html",""); |
|
460 | + if(!$this->tmp_filesystem->has("index.html")) { |
|
461 | + $this->tmp_filesystem->write("index.html",""); |
|
462 | + } |
|
442 | 463 | |
443 | - if($this->tmp_filesystem->has($this->get_included_files_handler())) |
|
444 | - $this->tmp_filesystem->delete($this->get_included_files_handler()); |
|
464 | + if($this->tmp_filesystem->has($this->get_included_files_handler())) { |
|
465 | + $this->tmp_filesystem->delete($this->get_included_files_handler()); |
|
466 | + } |
|
445 | 467 | |
446 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
447 | - $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
468 | + if($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
469 | + $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
470 | + } |
|
448 | 471 | } |
449 | 472 | |
450 | 473 | public function get_scanned_files_num() |
@@ -464,8 +487,9 @@ discard block |
||
464 | 487 | |
465 | 488 | public function set_excluded_files($excluded_files = array()) |
466 | 489 | { |
467 | - if(!is_array($excluded_files)) |
|
468 | - $excluded_files = array(); |
|
490 | + if(!is_array($excluded_files)) { |
|
491 | + $excluded_files = array(); |
|
492 | + } |
|
469 | 493 | |
470 | 494 | $this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default); |
471 | 495 | |
@@ -499,21 +523,21 @@ discard block |
||
499 | 523 | if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path'])) |
500 | 524 | { |
501 | 525 | $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE")); |
502 | - } |
|
503 | - elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
526 | + } elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
504 | 527 | $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE")); |
505 | 528 | $file['visibility'] = $this->start_filesystem->getVisibility($file['path']); |
506 | 529 | $this->store_file($file); |
507 | 530 | $this->files_counter++; |
508 | - if(isset($file['size'])) |
|
509 | - $this->files_size += $file['size']; |
|
531 | + if(isset($file['size'])) { |
|
532 | + $this->files_size += $file['size']; |
|
533 | + } |
|
510 | 534 | |
511 | - }else{ |
|
535 | + } else{ |
|
512 | 536 | $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE")); |
513 | 537 | } |
514 | 538 | } |
515 | 539 | |
516 | - }catch(Exception $e){ |
|
540 | + } catch(Exception $e){ |
|
517 | 541 | |
518 | 542 | $this->logger->error($e->getMessage()); |
519 | 543 | |
@@ -540,7 +564,7 @@ discard block |
||
540 | 564 | |
541 | 565 | $this->tmp_filesystem->delete($tmp_file); |
542 | 566 | |
543 | - }catch(Exception $e){ |
|
567 | + } catch(Exception $e){ |
|
544 | 568 | |
545 | 569 | $this->logger->error($e->getMessage()); |
546 | 570 | |
@@ -561,12 +585,14 @@ discard block |
||
561 | 585 | |
562 | 586 | $files = $this->storage_filesystem->listContents(); |
563 | 587 | |
564 | - if(is_array($files)) |
|
565 | - foreach($files as $file) |
|
588 | + if(is_array($files)) { |
|
589 | + foreach($files as $file) |
|
566 | 590 | { |
567 | 591 | if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) |
568 | 592 | { |
569 | - $_storage_size += $file['size']; //bytes |
|
593 | + $_storage_size += $file['size']; |
|
594 | + } |
|
595 | + //bytes |
|
570 | 596 | $_backup_files_list[] = $file; |
571 | 597 | } |
572 | 598 | } |
@@ -580,9 +606,11 @@ discard block |
||
580 | 606 | { |
581 | 607 | //processing rule folder capacity |
582 | 608 | if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
583 | - $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
609 | + $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) { |
|
610 | + //bytes |
|
584 | 611 | { |
585 | 612 | $this->storage_filesystem->delete($file['path']); |
613 | + } |
|
586 | 614 | $_storage_size -= $file['size']; |
587 | 615 | $this->logger->info("Deleting backup ".$file['path']." matching rule", array("STORAGE SIZE LIMIT", $_storage_size." >= ".$set_storage_limit)); |
588 | 616 | } |
@@ -623,34 +651,37 @@ discard block |
||
623 | 651 | |
624 | 652 | public function process_backup_name($name = "", $max_length=100) |
625 | 653 | { |
626 | - if(!$name) |
|
627 | - $name = $this->xcloner_settings->get_default_backup_name(); |
|
654 | + if(!$name) { |
|
655 | + $name = $this->xcloner_settings->get_default_backup_name(); |
|
656 | + } |
|
628 | 657 | |
629 | 658 | foreach($this->backup_name_tags as $tag) |
630 | 659 | { |
631 | - if($tag == '[time]') |
|
632 | - $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
633 | - elseif($tag == '[hostname]') |
|
634 | - $name = str_replace($tag, gethostname() ,$name); |
|
635 | - elseif($tag == '[domain]') |
|
660 | + if($tag == '[time]') { |
|
661 | + $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
662 | + } elseif($tag == '[hostname]') { |
|
663 | + $name = str_replace($tag, gethostname() ,$name); |
|
664 | + } elseif($tag == '[domain]') |
|
636 | 665 | { |
637 | 666 | $domain = parse_url(admin_url(), PHP_URL_HOST); |
638 | 667 | $name = str_replace($tag, $domain ,$name); |
639 | 668 | } |
640 | 669 | } |
641 | 670 | |
642 | - if($max_length) |
|
643 | - $name = substr($name, 0, $max_length); |
|
671 | + if($max_length) { |
|
672 | + $name = substr($name, 0, $max_length); |
|
673 | + } |
|
644 | 674 | |
645 | 675 | return $name; |
646 | 676 | } |
647 | 677 | |
648 | 678 | public function sort_by( &$array, $field, $direction = 'asc') |
649 | 679 | { |
650 | - if(strtolower($direction) == "desc" || $direction == SORT_DESC) |
|
651 | - $direction = SORT_DESC; |
|
652 | - else |
|
653 | - $direction = SORT_ASC; |
|
680 | + if(strtolower($direction) == "desc" || $direction == SORT_DESC) { |
|
681 | + $direction = SORT_DESC; |
|
682 | + } else { |
|
683 | + $direction = SORT_ASC; |
|
684 | + } |
|
654 | 685 | |
655 | 686 | $array = $this->array_orderby($array, $field, $direction); |
656 | 687 | |
@@ -667,10 +698,11 @@ discard block |
||
667 | 698 | $tmp = array(); |
668 | 699 | foreach ($data as $key => $row) |
669 | 700 | { |
670 | - if(is_array($row)) |
|
671 | - $tmp[$key] = $row[$field]; |
|
672 | - else |
|
673 | - $tmp[$key] = $row->$field; |
|
701 | + if(is_array($row)) { |
|
702 | + $tmp[$key] = $row[$field]; |
|
703 | + } else { |
|
704 | + $tmp[$key] = $row->$field; |
|
705 | + } |
|
674 | 706 | } |
675 | 707 | $args[$n] = $tmp; |
676 | 708 | } |
@@ -688,28 +720,32 @@ discard block |
||
688 | 720 | |
689 | 721 | if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) |
690 | 722 | { |
691 | - if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) |
|
692 | - return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
|
723 | + if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) { |
|
724 | + return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
|
725 | + } |
|
693 | 726 | } |
694 | 727 | |
695 | - if(!sizeof($this->excluded_files)) |
|
696 | - $this->set_excluded_files(); |
|
728 | + if(!sizeof($this->excluded_files)) { |
|
729 | + $this->set_excluded_files(); |
|
730 | + } |
|
697 | 731 | |
698 | - if(is_array($this->excluded_files)) |
|
699 | - foreach($this->excluded_files as $excluded_file_pattern) |
|
732 | + if(is_array($this->excluded_files)) { |
|
733 | + foreach($this->excluded_files as $excluded_file_pattern) |
|
700 | 734 | { |
701 | 735 | if($excluded_file_pattern == "/") |
702 | 736 | $needle = "$"; |
703 | - else |
|
704 | - $needle = "$".$excluded_file_pattern; |
|
737 | + } else { |
|
738 | + $needle = "$".$excluded_file_pattern; |
|
739 | + } |
|
705 | 740 | |
706 | 741 | if(strstr("$".$file['path'], $needle)){ |
707 | 742 | return $excluded_file_pattern; |
708 | 743 | } |
709 | 744 | } |
710 | 745 | |
711 | - if( $regex = $this->is_excluded_regex($file)) |
|
712 | - return $regex; |
|
746 | + if( $regex = $this->is_excluded_regex($file)) { |
|
747 | + return $regex; |
|
748 | + } |
|
713 | 749 | |
714 | 750 | return false; |
715 | 751 | } |
@@ -763,13 +799,15 @@ discard block |
||
763 | 799 | foreach($regex_patterns as $excluded_file_pattern) |
764 | 800 | { |
765 | 801 | |
766 | - if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") |
|
767 | - $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
802 | + if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") { |
|
803 | + $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
804 | + } |
|
768 | 805 | |
769 | - if($file['path'] == "/") |
|
770 | - $needle = "/"; |
|
771 | - else |
|
772 | - $needle = "/".$file['path']; |
|
806 | + if($file['path'] == "/") { |
|
807 | + $needle = "/"; |
|
808 | + } else { |
|
809 | + $needle = "/".$file['path']; |
|
810 | + } |
|
773 | 811 | //echo $needle."---".$excluded_file_pattern."---\n"; |
774 | 812 | |
775 | 813 | if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){ |
@@ -785,10 +823,12 @@ discard block |
||
785 | 823 | { |
786 | 824 | $this->logger->debug(sprintf("Storing %s in the backup list", $file['path'])); |
787 | 825 | |
788 | - if(!isset($file['size'])) |
|
789 | - $file['size'] = 0; |
|
790 | - if(!isset($file['visibility'])) |
|
791 | - $file['visibility'] = "private"; |
|
826 | + if(!isset($file['size'])) { |
|
827 | + $file['size'] = 0; |
|
828 | + } |
|
829 | + if(!isset($file['visibility'])) { |
|
830 | + $file['visibility'] = "private"; |
|
831 | + } |
|
792 | 832 | |
793 | 833 | $csv_filename = str_replace('"','""', $file['path']); |
794 | 834 | |
@@ -806,7 +846,7 @@ discard block |
||
806 | 846 | |
807 | 847 | $this->tmp_filesystem_append->write($this->get_included_files_handler(), $line); |
808 | 848 | |
809 | - }catch(Exception $e){ |
|
849 | + } catch(Exception $e){ |
|
810 | 850 | |
811 | 851 | $this->logger->error($e->getMessage()); |
812 | 852 | } |
@@ -814,7 +854,7 @@ discard block |
||
814 | 854 | if($file['type'] == "dir"){ |
815 | 855 | try{ |
816 | 856 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n"); |
817 | - }catch(Exception $e){ |
|
857 | + } catch(Exception $e){ |
|
818 | 858 | $this->logger->error($e->getMessage()); |
819 | 859 | } |
820 | 860 | } |
@@ -827,35 +867,39 @@ discard block |
||
827 | 867 | |
828 | 868 | public function get_filesystem($system = "") |
829 | 869 | { |
830 | - if($system == "storage_filesystem_append") |
|
831 | - return $this->storage_filesystem_append; |
|
832 | - elseif($system == "tmp_filesystem_append") |
|
833 | - return $this->tmp_filesystem_append; |
|
834 | - elseif($system == "tmp_filesystem") |
|
835 | - return $this->tmp_filesystem; |
|
836 | - elseif($system == "storage_filesystem") |
|
837 | - return $this->storage_filesystem; |
|
838 | - else |
|
839 | - return $this->start_filesystem; |
|
870 | + if($system == "storage_filesystem_append") { |
|
871 | + return $this->storage_filesystem_append; |
|
872 | + } elseif($system == "tmp_filesystem_append") { |
|
873 | + return $this->tmp_filesystem_append; |
|
874 | + } elseif($system == "tmp_filesystem") { |
|
875 | + return $this->tmp_filesystem; |
|
876 | + } elseif($system == "storage_filesystem") { |
|
877 | + return $this->storage_filesystem; |
|
878 | + } else { |
|
879 | + return $this->start_filesystem; |
|
880 | + } |
|
840 | 881 | } |
841 | 882 | |
842 | 883 | public function get_adapter($system) |
843 | 884 | { |
844 | - if($system == "tmp_filesystem") |
|
845 | - return $this->tmp_adapter; |
|
846 | - elseif($system == "storage_filesystem") |
|
847 | - return $this->storage_adapter; |
|
848 | - else |
|
849 | - return $this->start_adapter; |
|
885 | + if($system == "tmp_filesystem") { |
|
886 | + return $this->tmp_adapter; |
|
887 | + } elseif($system == "storage_filesystem") { |
|
888 | + return $this->storage_adapter; |
|
889 | + } else { |
|
890 | + return $this->start_adapter; |
|
891 | + } |
|
850 | 892 | } |
851 | 893 | |
852 | 894 | private function scan_finished() |
853 | 895 | { |
854 | - if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) |
|
855 | - return false; |
|
896 | + if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) { |
|
897 | + return false; |
|
898 | + } |
|
856 | 899 | |
857 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
858 | - $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
900 | + if($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
901 | + $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
902 | + } |
|
859 | 903 | |
860 | 904 | $this->logger->debug(sprintf(("File scan finished"))); |
861 | 905 |