| @@ 97-129 (lines=33) @@ | ||
| 94 | * @param bool|int $empty |
|
| 95 | * @return bool |
|
| 96 | */ |
|
| 97 | public function smallworld_remDir($userid, $directory, $empty = false) |
|
| 98 | { |
|
| 99 | if ('' != $userid) { |
|
| 100 | if ('/' === mb_substr($directory, -1)) { |
|
| 101 | $directory = mb_substr($directory, 0, -1); |
|
| 102 | } |
|
| 103 | ||
| 104 | if (!file_exists($directory) || !is_dir($directory)) { |
|
| 105 | return false; |
|
| 106 | } elseif (!is_readable($directory)) { |
|
| 107 | return false; |
|
| 108 | } |
|
| 109 | $directoryHandle = opendir($directory); |
|
| 110 | while (false !== ($contents = readdir($directoryHandle))) { |
|
| 111 | if ('.' !== $contents && '..' !== $contents) { |
|
| 112 | $path = $directory . '/' . $contents; |
|
| 113 | if (is_dir($path)) { |
|
| 114 | $this->smallworld_remDir($userid, $path); |
|
| 115 | } else { |
|
| 116 | unlink($path); |
|
| 117 | } |
|
| 118 | } |
|
| 119 | } |
|
| 120 | closedir($directoryHandle); |
|
| 121 | if (false === $empty) { |
|
| 122 | if (!rmdir($directory)) { |
|
| 123 | return false; |
|
| 124 | } |
|
| 125 | } |
|
| 126 | ||
| 127 | return true; |
|
| 128 | } |
|
| 129 | } |
|
| 130 | ||
| 131 | /** |
|
| 132 | * SmallworldDeleteDirectory function |
|
| @@ 528-561 (lines=34) @@ | ||
| 525 | * @param bool|int $empty |
|
| 526 | * @return true |
|
| 527 | */ |
|
| 528 | public function smallworld_remDir($userid, $directory, $empty = false) |
|
| 529 | { |
|
| 530 | if ('' != $userid) { |
|
| 531 | if ('/' === substr($directory, -1)) { |
|
| 532 | $directory = substr($directory, 0, -1); |
|
| 533 | } |
|
| 534 | ||
| 535 | if (!file_exists($directory) || !is_dir($directory)) { |
|
| 536 | return false; |
|
| 537 | } elseif (!is_readable($directory)) { |
|
| 538 | return false; |
|
| 539 | } else { |
|
| 540 | $directoryHandle = opendir($directory); |
|
| 541 | while ($contents = readdir($directoryHandle)) { |
|
| 542 | if ('.' !== $contents && '..' !== $contents) { |
|
| 543 | $path = $directory . '/' . $contents; |
|
| 544 | if (is_dir($path)) { |
|
| 545 | $this->smallworld_remDir($userid, $path); |
|
| 546 | } else { |
|
| 547 | unlink($path); |
|
| 548 | } |
|
| 549 | } |
|
| 550 | } |
|
| 551 | closedir($directoryHandle); |
|
| 552 | if (false === $empty) { |
|
| 553 | if (!rmdir($directory)) { |
|
| 554 | return false; |
|
| 555 | } |
|
| 556 | } |
|
| 557 | ||
| 558 | return true; |
|
| 559 | } |
|
| 560 | } |
|
| 561 | } |
|
| 562 | ||
| 563 | /** |
|
| 564 | * SmallworldDeleteDirectory function |
|
| @@ 586-618 (lines=33) @@ | ||
| 583 | * @param bool|int $empty |
|
| 584 | * @return true |
|
| 585 | */ |
|
| 586 | public function smallworld_remDir($userid, $directory, $empty = false) |
|
| 587 | { |
|
| 588 | if ('' != $userid) { |
|
| 589 | if ('/' === substr($directory, -1)) { |
|
| 590 | $directory = substr($directory, 0, -1); |
|
| 591 | } |
|
| 592 | ||
| 593 | if (!file_exists($directory) || !is_dir($directory)) { |
|
| 594 | return false; |
|
| 595 | } elseif (!is_readable($directory)) { |
|
| 596 | return false; |
|
| 597 | } else { |
|
| 598 | $directoryHandle = opendir($directory); |
|
| 599 | while ($contents = readdir($directoryHandle)) { |
|
| 600 | if ('.' !== $contents && '..' !== $contents) { |
|
| 601 | $path = $directory . '/' . $contents; |
|
| 602 | if (is_dir($path)) { |
|
| 603 | $this->smallworld_remDir($userid, $path); |
|
| 604 | } else { |
|
| 605 | unlink($path); |
|
| 606 | } |
|
| 607 | } |
|
| 608 | } |
|
| 609 | closedir($directoryHandle); |
|
| 610 | if (false === $empty) { |
|
| 611 | if (!rmdir($directory)) { |
|
| 612 | return false; |
|
| 613 | } |
|
| 614 | } |
|
| 615 | return true; |
|
| 616 | } |
|
| 617 | } |
|
| 618 | } |
|
| 619 | ||
| 620 | /** |
|
| 621 | * Update private settings |
|
| @@ 704-738 (lines=35) @@ | ||
| 701 | * @param bool|int $empty |
|
| 702 | * @return bool |
|
| 703 | */ |
|
| 704 | public function smallworld_remDir($userid, $directory, $empty = false) |
|
| 705 | { |
|
| 706 | //@todo verify $userid should be int and then sanitize $userid accordingly before |
|
| 707 | // executing this routine |
|
| 708 | if (!empty($userid)) { |
|
| 709 | if ('/' === mb_substr($directory, -1)) { |
|
| 710 | $directory = mb_substr($directory, 0, -1); |
|
| 711 | } |
|
| 712 | ||
| 713 | if (!file_exists($directory) || !is_dir($directory)) { |
|
| 714 | return false; |
|
| 715 | } elseif (!is_readable($directory)) { |
|
| 716 | return false; |
|
| 717 | } |
|
| 718 | $directoryHandle = opendir($directory); |
|
| 719 | while (false !== ($contents = readdir($directoryHandle))) { |
|
| 720 | if ('.' !== $contents && '..' !== $contents) { |
|
| 721 | $path = $directory . '/' . $contents; |
|
| 722 | if (is_dir($path)) { |
|
| 723 | $this->smallworld_remDir($userid, $path); |
|
| 724 | } else { |
|
| 725 | unlink($path); |
|
| 726 | } |
|
| 727 | } |
|
| 728 | } |
|
| 729 | closedir($directoryHandle); |
|
| 730 | if (false === $empty) { |
|
| 731 | if (!rmdir($directory)) { |
|
| 732 | return false; |
|
| 733 | } |
|
| 734 | } |
|
| 735 | ||
| 736 | return true; |
|
| 737 | } |
|
| 738 | } |
|
| 739 | ||
| 740 | /** |
|
| 741 | * Update private settings |
|