@@ -64,13 +64,14 @@ discard block |
||
| 64 | 64 | $this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([ |
| 65 | 65 | 'disable_asserts' => true, |
| 66 | 66 | ])); |
| 67 | - }catch(Exception $e){ |
|
| 67 | + } catch(Exception $e){ |
|
| 68 | 68 | return false; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | - if($value = get_option('xcloner_directories_to_scan_per_request')) |
|
| 73 | - $this->folders_to_process_per_session = $value; |
|
| 72 | + if($value = get_option('xcloner_directories_to_scan_per_request')) { |
|
| 73 | + $this->folders_to_process_per_session = $value; |
|
| 74 | + } |
|
| 74 | 75 | |
| 75 | 76 | } |
| 76 | 77 | |
@@ -133,8 +134,9 @@ discard block |
||
| 133 | 134 | public function get_included_files_handler($metadata = 0) |
| 134 | 135 | { |
| 135 | 136 | $path = $this->included_files_handler; |
| 136 | - if(!$metadata) |
|
| 137 | - return $path; |
|
| 137 | + if(!$metadata) { |
|
| 138 | + return $path; |
|
| 139 | + } |
|
| 138 | 140 | |
| 139 | 141 | $spl_info = $this->getMetadataFull('tmp_adapter', $path); |
| 140 | 142 | return $spl_info; |
@@ -150,31 +152,36 @@ discard block |
||
| 150 | 152 | { |
| 151 | 153 | $files = $this->get_backup_archives_list(); |
| 152 | 154 | |
| 153 | - if(is_array($files)) |
|
| 154 | - $this->sort_by($files, "timestamp","desc"); |
|
| 155 | + if(is_array($files)) { |
|
| 156 | + $this->sort_by($files, "timestamp","desc"); |
|
| 157 | + } |
|
| 155 | 158 | |
| 156 | 159 | $new_list = array(); |
| 157 | 160 | |
| 158 | - foreach($files as $key=>$file) |
|
| 159 | - if(!isset($file['parent'])) |
|
| 161 | + foreach($files as $key=>$file) { |
|
| 162 | + if(!isset($file['parent'])) |
|
| 160 | 163 | $new_list[] = ($files[$key]); |
| 164 | + } |
|
| 161 | 165 | |
| 162 | - if(isset($new_list[0])) |
|
| 163 | - return $new_list[0]; |
|
| 166 | + if(isset($new_list[0])) { |
|
| 167 | + return $new_list[0]; |
|
| 168 | + } |
|
| 164 | 169 | } |
| 165 | 170 | |
| 166 | 171 | public function get_latest_backups() |
| 167 | 172 | { |
| 168 | 173 | $files = $this->get_backup_archives_list(); |
| 169 | 174 | |
| 170 | - if(is_array($files)) |
|
| 171 | - $this->sort_by($files, "timestamp","desc"); |
|
| 175 | + if(is_array($files)) { |
|
| 176 | + $this->sort_by($files, "timestamp","desc"); |
|
| 177 | + } |
|
| 172 | 178 | |
| 173 | 179 | $new_list = array(); |
| 174 | 180 | |
| 175 | - foreach($files as $key=>$file) |
|
| 176 | - if(!isset($file['parent'])) |
|
| 181 | + foreach($files as $key=>$file) { |
|
| 182 | + if(!isset($file['parent'])) |
|
| 177 | 183 | $new_list[] = ($files[$key]); |
| 184 | + } |
|
| 178 | 185 | |
| 179 | 186 | return $new_list; |
| 180 | 187 | } |
@@ -184,25 +191,28 @@ discard block |
||
| 184 | 191 | $files = $this->get_backup_archives_list(); |
| 185 | 192 | $total = 0; |
| 186 | 193 | |
| 187 | - if(is_array($files)) |
|
| 188 | - foreach($files as $file) |
|
| 194 | + if(is_array($files)) { |
|
| 195 | + foreach($files as $file) |
|
| 189 | 196 | $total += $file['size']; |
| 197 | + } |
|
| 190 | 198 | |
| 191 | 199 | return $total; |
| 192 | 200 | } |
| 193 | 201 | |
| 194 | 202 | public function is_part($backup_name) |
| 195 | 203 | { |
| 196 | - if(stristr($backup_name, "-part")) |
|
| 197 | - return true; |
|
| 204 | + if(stristr($backup_name, "-part")) { |
|
| 205 | + return true; |
|
| 206 | + } |
|
| 198 | 207 | |
| 199 | 208 | return false; |
| 200 | 209 | } |
| 201 | 210 | |
| 202 | 211 | public function is_multipart($backup_name) |
| 203 | 212 | { |
| 204 | - if(stristr($backup_name, "-multipart")) |
|
| 205 | - return true; |
|
| 213 | + if(stristr($backup_name, "-multipart")) { |
|
| 214 | + return true; |
|
| 215 | + } |
|
| 206 | 216 | |
| 207 | 217 | return false; |
| 208 | 218 | } |
@@ -213,8 +223,9 @@ discard block |
||
| 213 | 223 | if($this->is_multipart($backup_name)) |
| 214 | 224 | { |
| 215 | 225 | $backup_parts = $this->get_multipart_files($backup_name); |
| 216 | - foreach($backup_parts as $part_file) |
|
| 217 | - $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
|
| 226 | + foreach($backup_parts as $part_file) { |
|
| 227 | + $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
|
| 228 | + } |
|
| 218 | 229 | } |
| 219 | 230 | |
| 220 | 231 | return $backup_size; |
@@ -255,10 +266,11 @@ discard block |
||
| 255 | 266 | } |
| 256 | 267 | } |
| 257 | 268 | |
| 258 | - if($this->get_storage_filesystem()->delete($backup_name)) |
|
| 259 | - $return = true; |
|
| 260 | - else |
|
| 261 | - $return = false; |
|
| 269 | + if($this->get_storage_filesystem()->delete($backup_name)) { |
|
| 270 | + $return = true; |
|
| 271 | + } else { |
|
| 272 | + $return = false; |
|
| 273 | + } |
|
| 262 | 274 | |
| 263 | 275 | return $return; |
| 264 | 276 | } |
@@ -276,8 +288,9 @@ discard block |
||
| 276 | 288 | { |
| 277 | 289 | $list = array(); |
| 278 | 290 | |
| 279 | - if(method_exists($this->get_storage_filesystem(), "listContents")) |
|
| 280 | - $list = $this->get_storage_filesystem()->listContents(); |
|
| 291 | + if(method_exists($this->get_storage_filesystem(), "listContents")) { |
|
| 292 | + $list = $this->get_storage_filesystem()->listContents(); |
|
| 293 | + } |
|
| 281 | 294 | |
| 282 | 295 | |
| 283 | 296 | $backup_files = array(); |
@@ -290,10 +303,11 @@ discard block |
||
| 290 | 303 | $data = array(); |
| 291 | 304 | |
| 292 | 305 | $lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($file_info['path'])); |
| 293 | - foreach($lines as $line) |
|
| 294 | - if($line) |
|
| 306 | + foreach($lines as $line) { |
|
| 307 | + if($line) |
|
| 295 | 308 | { |
| 296 | 309 | $data = str_getcsv($line); |
| 310 | + } |
|
| 297 | 311 | if(is_array($data)){ |
| 298 | 312 | $parents[$data[0]] = $file_info['path']; |
| 299 | 313 | $file_info['childs'][] = $data; |
@@ -303,14 +317,16 @@ discard block |
||
| 303 | 317 | |
| 304 | 318 | } |
| 305 | 319 | |
| 306 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
| 307 | - $backup_files[$file_info['path']] = $file_info; |
|
| 320 | + if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) { |
|
| 321 | + $backup_files[$file_info['path']] = $file_info; |
|
| 322 | + } |
|
| 308 | 323 | } |
| 309 | 324 | |
| 310 | 325 | foreach($backup_files as $key=>$file_info) |
| 311 | 326 | { |
| 312 | - if(isset($parents[$file_info['path']])) |
|
| 313 | - $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
| 327 | + if(isset($parents[$file_info['path']])) { |
|
| 328 | + $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
| 329 | + } |
|
| 314 | 330 | } |
| 315 | 331 | |
| 316 | 332 | return $backup_files; |
@@ -336,11 +352,11 @@ discard block |
||
| 336 | 352 | if($counter < $this->folders_to_process_per_session){ |
| 337 | 353 | $this->build_files_list($file); |
| 338 | 354 | $counter++; |
| 339 | - }else{ |
|
| 355 | + } else{ |
|
| 340 | 356 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n"); |
| 341 | 357 | } |
| 342 | 358 | } |
| 343 | - }else{ |
|
| 359 | + } else{ |
|
| 344 | 360 | $this->build_files_list(); |
| 345 | 361 | } |
| 346 | 362 | |
@@ -382,8 +398,9 @@ discard block |
||
| 382 | 398 | { |
| 383 | 399 | $return = array(); |
| 384 | 400 | $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler(); |
| 385 | - if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 386 | - $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
|
| 401 | + if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) { |
|
| 402 | + $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
|
| 403 | + } |
|
| 387 | 404 | |
| 388 | 405 | return $return; |
| 389 | 406 | } |
@@ -395,9 +412,10 @@ discard block |
||
| 395 | 412 | |
| 396 | 413 | $contents = $this->get_tmp_filesystem()->listContents(); |
| 397 | 414 | |
| 398 | - if(is_array($contents)) |
|
| 399 | - foreach($contents as $file_info) |
|
| 415 | + if(is_array($contents)) { |
|
| 416 | + foreach($contents as $file_info) |
|
| 400 | 417 | $this->get_tmp_filesystem()->delete($file_info['path']); |
| 418 | + } |
|
| 401 | 419 | |
| 402 | 420 | @rmdir($this->xcloner_settings->get_xcloner_tmp_path()); |
| 403 | 421 | |
@@ -408,17 +426,21 @@ discard block |
||
| 408 | 426 | { |
| 409 | 427 | $this->files_counter = 0; |
| 410 | 428 | |
| 411 | - if(!$this->storage_filesystem->has("index.html")) |
|
| 412 | - $this->storage_filesystem->write("index.html",""); |
|
| 429 | + if(!$this->storage_filesystem->has("index.html")) { |
|
| 430 | + $this->storage_filesystem->write("index.html",""); |
|
| 431 | + } |
|
| 413 | 432 | |
| 414 | - if(!$this->tmp_filesystem->has("index.html")) |
|
| 415 | - $this->tmp_filesystem->write("index.html",""); |
|
| 433 | + if(!$this->tmp_filesystem->has("index.html")) { |
|
| 434 | + $this->tmp_filesystem->write("index.html",""); |
|
| 435 | + } |
|
| 416 | 436 | |
| 417 | - if($this->tmp_filesystem->has($this->get_included_files_handler())) |
|
| 418 | - $this->tmp_filesystem->delete($this->get_included_files_handler()); |
|
| 437 | + if($this->tmp_filesystem->has($this->get_included_files_handler())) { |
|
| 438 | + $this->tmp_filesystem->delete($this->get_included_files_handler()); |
|
| 439 | + } |
|
| 419 | 440 | |
| 420 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 421 | - $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 441 | + if($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
| 442 | + $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 443 | + } |
|
| 422 | 444 | } |
| 423 | 445 | |
| 424 | 446 | public function get_scanned_files_num() |
@@ -438,8 +460,9 @@ discard block |
||
| 438 | 460 | |
| 439 | 461 | public function set_excluded_files($excluded_files = array()) |
| 440 | 462 | { |
| 441 | - if(!is_array($excluded_files)) |
|
| 442 | - $excluded_files = array(); |
|
| 463 | + if(!is_array($excluded_files)) { |
|
| 464 | + $excluded_files = array(); |
|
| 465 | + } |
|
| 443 | 466 | |
| 444 | 467 | $this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default); |
| 445 | 468 | |
@@ -473,21 +496,21 @@ discard block |
||
| 473 | 496 | if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path'])) |
| 474 | 497 | { |
| 475 | 498 | $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE")); |
| 476 | - } |
|
| 477 | - elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
| 499 | + } elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
| 478 | 500 | $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE")); |
| 479 | 501 | $file['visibility'] = $this->start_filesystem->getVisibility($file['path']); |
| 480 | 502 | $this->store_file($file); |
| 481 | 503 | $this->files_counter++; |
| 482 | - if(isset($file['size'])) |
|
| 483 | - $this->files_size += $file['size']; |
|
| 504 | + if(isset($file['size'])) { |
|
| 505 | + $this->files_size += $file['size']; |
|
| 506 | + } |
|
| 484 | 507 | |
| 485 | - }else{ |
|
| 508 | + } else{ |
|
| 486 | 509 | $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE")); |
| 487 | 510 | } |
| 488 | 511 | } |
| 489 | 512 | |
| 490 | - }catch(Exception $e){ |
|
| 513 | + } catch(Exception $e){ |
|
| 491 | 514 | |
| 492 | 515 | $this->logger->error($e->getMessage()); |
| 493 | 516 | |
@@ -514,7 +537,7 @@ discard block |
||
| 514 | 537 | |
| 515 | 538 | $this->tmp_filesystem->delete($tmp_file); |
| 516 | 539 | |
| 517 | - }catch(Exception $e){ |
|
| 540 | + } catch(Exception $e){ |
|
| 518 | 541 | |
| 519 | 542 | $this->logger->error($e->getMessage()); |
| 520 | 543 | |
@@ -535,12 +558,14 @@ discard block |
||
| 535 | 558 | |
| 536 | 559 | $files = $this->storage_filesystem->listContents(); |
| 537 | 560 | |
| 538 | - if(is_array($files)) |
|
| 539 | - foreach($files as $file) |
|
| 561 | + if(is_array($files)) { |
|
| 562 | + foreach($files as $file) |
|
| 540 | 563 | { |
| 541 | 564 | if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) |
| 542 | 565 | { |
| 543 | - $_storage_size += $file['size']; //bytes |
|
| 566 | + $_storage_size += $file['size']; |
|
| 567 | + } |
|
| 568 | + //bytes |
|
| 544 | 569 | $_backup_files_list[] = $file; |
| 545 | 570 | } |
| 546 | 571 | } |
@@ -554,9 +579,11 @@ discard block |
||
| 554 | 579 | { |
| 555 | 580 | //processing rule folder capacity |
| 556 | 581 | if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
| 557 | - $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
| 582 | + $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) { |
|
| 583 | + //bytes |
|
| 558 | 584 | { |
| 559 | 585 | $this->storage_filesystem->delete($file['path']); |
| 586 | + } |
|
| 560 | 587 | $_storage_size -= $file['size']; |
| 561 | 588 | $this->logger->info("Deleting backup ".$file['path']." matching rule", array("STORAGE SIZE LIMIT", $_storage_size." >= ".$set_storage_limit)); |
| 562 | 589 | } |
@@ -597,34 +624,37 @@ discard block |
||
| 597 | 624 | |
| 598 | 625 | public function process_backup_name($name = "", $max_length=100) |
| 599 | 626 | { |
| 600 | - if(!$name) |
|
| 601 | - $name = $this->xcloner_settings->get_default_backup_name(); |
|
| 627 | + if(!$name) { |
|
| 628 | + $name = $this->xcloner_settings->get_default_backup_name(); |
|
| 629 | + } |
|
| 602 | 630 | |
| 603 | 631 | foreach($this->backup_name_tags as $tag) |
| 604 | 632 | { |
| 605 | - if($tag == '[time]') |
|
| 606 | - $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
| 607 | - elseif($tag == '[hostname]') |
|
| 608 | - $name = str_replace($tag, gethostname() ,$name); |
|
| 609 | - elseif($tag == '[domain]') |
|
| 633 | + if($tag == '[time]') { |
|
| 634 | + $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
| 635 | + } elseif($tag == '[hostname]') { |
|
| 636 | + $name = str_replace($tag, gethostname() ,$name); |
|
| 637 | + } elseif($tag == '[domain]') |
|
| 610 | 638 | { |
| 611 | 639 | $domain = parse_url(admin_url(), PHP_URL_HOST); |
| 612 | 640 | $name = str_replace($tag, $domain ,$name); |
| 613 | 641 | } |
| 614 | 642 | } |
| 615 | 643 | |
| 616 | - if($max_length) |
|
| 617 | - $name = substr($name, 0, $max_length); |
|
| 644 | + if($max_length) { |
|
| 645 | + $name = substr($name, 0, $max_length); |
|
| 646 | + } |
|
| 618 | 647 | |
| 619 | 648 | return $name; |
| 620 | 649 | } |
| 621 | 650 | |
| 622 | 651 | public function sort_by( &$array, $field, $direction = 'asc') |
| 623 | 652 | { |
| 624 | - if(strtolower($direction) == "desc" || $direction == SORT_DESC) |
|
| 625 | - $direction = SORT_DESC; |
|
| 626 | - else |
|
| 627 | - $direction = SORT_ASC; |
|
| 653 | + if(strtolower($direction) == "desc" || $direction == SORT_DESC) { |
|
| 654 | + $direction = SORT_DESC; |
|
| 655 | + } else { |
|
| 656 | + $direction = SORT_ASC; |
|
| 657 | + } |
|
| 628 | 658 | |
| 629 | 659 | $array = $this->array_orderby($array, $field, $direction); |
| 630 | 660 | |
@@ -641,10 +671,11 @@ discard block |
||
| 641 | 671 | $tmp = array(); |
| 642 | 672 | foreach ($data as $key => $row) |
| 643 | 673 | { |
| 644 | - if(is_array($row)) |
|
| 645 | - $tmp[$key] = $row[$field]; |
|
| 646 | - else |
|
| 647 | - $tmp[$key] = $row->$field; |
|
| 674 | + if(is_array($row)) { |
|
| 675 | + $tmp[$key] = $row[$field]; |
|
| 676 | + } else { |
|
| 677 | + $tmp[$key] = $row->$field; |
|
| 678 | + } |
|
| 648 | 679 | } |
| 649 | 680 | $args[$n] = $tmp; |
| 650 | 681 | } |
@@ -662,28 +693,32 @@ discard block |
||
| 662 | 693 | |
| 663 | 694 | if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) |
| 664 | 695 | { |
| 665 | - if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) |
|
| 666 | - return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
|
| 696 | + if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) { |
|
| 697 | + return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
|
| 698 | + } |
|
| 667 | 699 | } |
| 668 | 700 | |
| 669 | - if(!sizeof($this->excluded_files)) |
|
| 670 | - $this->set_excluded_files(); |
|
| 701 | + if(!sizeof($this->excluded_files)) { |
|
| 702 | + $this->set_excluded_files(); |
|
| 703 | + } |
|
| 671 | 704 | |
| 672 | - if(is_array($this->excluded_files)) |
|
| 673 | - foreach($this->excluded_files as $excluded_file_pattern) |
|
| 705 | + if(is_array($this->excluded_files)) { |
|
| 706 | + foreach($this->excluded_files as $excluded_file_pattern) |
|
| 674 | 707 | { |
| 675 | 708 | if($excluded_file_pattern == "/") |
| 676 | 709 | $needle = "$"; |
| 677 | - else |
|
| 678 | - $needle = "$".$excluded_file_pattern; |
|
| 710 | + } else { |
|
| 711 | + $needle = "$".$excluded_file_pattern; |
|
| 712 | + } |
|
| 679 | 713 | |
| 680 | 714 | if(strstr("$".$file['path'], $needle)){ |
| 681 | 715 | return $excluded_file_pattern; |
| 682 | 716 | } |
| 683 | 717 | } |
| 684 | 718 | |
| 685 | - if( $regex = $this->is_excluded_regex($file)) |
|
| 686 | - return $regex; |
|
| 719 | + if( $regex = $this->is_excluded_regex($file)) { |
|
| 720 | + return $regex; |
|
| 721 | + } |
|
| 687 | 722 | |
| 688 | 723 | return false; |
| 689 | 724 | } |
@@ -737,13 +772,15 @@ discard block |
||
| 737 | 772 | foreach($regex_patterns as $excluded_file_pattern) |
| 738 | 773 | { |
| 739 | 774 | |
| 740 | - if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") |
|
| 741 | - $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
| 775 | + if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") { |
|
| 776 | + $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
| 777 | + } |
|
| 742 | 778 | |
| 743 | - if($file['path'] == "/") |
|
| 744 | - $needle = "/"; |
|
| 745 | - else |
|
| 746 | - $needle = "/".$file['path']; |
|
| 779 | + if($file['path'] == "/") { |
|
| 780 | + $needle = "/"; |
|
| 781 | + } else { |
|
| 782 | + $needle = "/".$file['path']; |
|
| 783 | + } |
|
| 747 | 784 | //echo $needle."---".$excluded_file_pattern."---\n"; |
| 748 | 785 | |
| 749 | 786 | if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){ |
@@ -759,10 +796,12 @@ discard block |
||
| 759 | 796 | { |
| 760 | 797 | $this->logger->debug(sprintf("Storing %s in the backup list", $file['path'])); |
| 761 | 798 | |
| 762 | - if(!isset($file['size'])) |
|
| 763 | - $file['size'] = 0; |
|
| 764 | - if(!isset($file['visibility'])) |
|
| 765 | - $file['visibility'] = "private"; |
|
| 799 | + if(!isset($file['size'])) { |
|
| 800 | + $file['size'] = 0; |
|
| 801 | + } |
|
| 802 | + if(!isset($file['visibility'])) { |
|
| 803 | + $file['visibility'] = "private"; |
|
| 804 | + } |
|
| 766 | 805 | |
| 767 | 806 | $line = '"'.addslashes($file['path']).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL; |
| 768 | 807 | |
@@ -771,7 +810,7 @@ discard block |
||
| 771 | 810 | try{ |
| 772 | 811 | $this->tmp_filesystem_append->write($this->get_included_files_handler(), $line); |
| 773 | 812 | |
| 774 | - }catch(Exception $e){ |
|
| 813 | + } catch(Exception $e){ |
|
| 775 | 814 | |
| 776 | 815 | $this->logger->error($e->getMessage()); |
| 777 | 816 | } |
@@ -779,7 +818,7 @@ discard block |
||
| 779 | 818 | if($file['type'] == "dir"){ |
| 780 | 819 | try{ |
| 781 | 820 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n"); |
| 782 | - }catch(Exception $e){ |
|
| 821 | + } catch(Exception $e){ |
|
| 783 | 822 | $this->logger->error($e->getMessage()); |
| 784 | 823 | } |
| 785 | 824 | } |
@@ -792,35 +831,39 @@ discard block |
||
| 792 | 831 | |
| 793 | 832 | public function get_filesystem($system = "") |
| 794 | 833 | { |
| 795 | - if($system == "storage_filesystem_append") |
|
| 796 | - return $this->storage_filesystem_append; |
|
| 797 | - elseif($system == "tmp_filesystem_append") |
|
| 798 | - return $this->tmp_filesystem_append; |
|
| 799 | - elseif($system == "tmp_filesystem") |
|
| 800 | - return $this->tmp_filesystem; |
|
| 801 | - elseif($system == "storage_filesystem") |
|
| 802 | - return $this->storage_filesystem; |
|
| 803 | - else |
|
| 804 | - return $this->start_filesystem; |
|
| 834 | + if($system == "storage_filesystem_append") { |
|
| 835 | + return $this->storage_filesystem_append; |
|
| 836 | + } elseif($system == "tmp_filesystem_append") { |
|
| 837 | + return $this->tmp_filesystem_append; |
|
| 838 | + } elseif($system == "tmp_filesystem") { |
|
| 839 | + return $this->tmp_filesystem; |
|
| 840 | + } elseif($system == "storage_filesystem") { |
|
| 841 | + return $this->storage_filesystem; |
|
| 842 | + } else { |
|
| 843 | + return $this->start_filesystem; |
|
| 844 | + } |
|
| 805 | 845 | } |
| 806 | 846 | |
| 807 | 847 | public function get_adapter($system) |
| 808 | 848 | { |
| 809 | - if($system == "tmp_filesystem") |
|
| 810 | - return $this->tmp_adapter; |
|
| 811 | - elseif($system == "storage_filesystem") |
|
| 812 | - return $this->storage_adapter; |
|
| 813 | - else |
|
| 814 | - return $this->start_adapter; |
|
| 849 | + if($system == "tmp_filesystem") { |
|
| 850 | + return $this->tmp_adapter; |
|
| 851 | + } elseif($system == "storage_filesystem") { |
|
| 852 | + return $this->storage_adapter; |
|
| 853 | + } else { |
|
| 854 | + return $this->start_adapter; |
|
| 855 | + } |
|
| 815 | 856 | } |
| 816 | 857 | |
| 817 | 858 | private function scan_finished() |
| 818 | 859 | { |
| 819 | - if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) |
|
| 820 | - return false; |
|
| 860 | + if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) { |
|
| 861 | + return false; |
|
| 862 | + } |
|
| 821 | 863 | |
| 822 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 823 | - $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 864 | + if($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
| 865 | + $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 866 | + } |
|
| 824 | 867 | |
| 825 | 868 | $this->logger->debug(sprintf(("File scan finished"))); |
| 826 | 869 | |