| @@ 96-128 (lines=33) @@ | ||
| 93 | * @param bool|int $empty |
|
| 94 | * @return true |
|
| 95 | */ |
|
| 96 | public function smallworld_remDir($userid, $directory, $empty = false) |
|
| 97 | { |
|
| 98 | if ('' != $userid) { |
|
| 99 | if ('/' === mb_substr($directory, -1)) { |
|
| 100 | $directory = mb_substr($directory, 0, -1); |
|
| 101 | } |
|
| 102 | ||
| 103 | if (!file_exists($directory) || !is_dir($directory)) { |
|
| 104 | return false; |
|
| 105 | } elseif (!is_readable($directory)) { |
|
| 106 | return false; |
|
| 107 | } |
|
| 108 | $directoryHandle = opendir($directory); |
|
| 109 | while (false !== ($contents = readdir($directoryHandle))) { |
|
| 110 | if ('.' !== $contents && '..' !== $contents) { |
|
| 111 | $path = $directory . '/' . $contents; |
|
| 112 | if (is_dir($path)) { |
|
| 113 | $this->smallworld_remDir($userid, $path); |
|
| 114 | } else { |
|
| 115 | unlink($path); |
|
| 116 | } |
|
| 117 | } |
|
| 118 | } |
|
| 119 | closedir($directoryHandle); |
|
| 120 | if (false === $empty) { |
|
| 121 | if (!rmdir($directory)) { |
|
| 122 | return false; |
|
| 123 | } |
|
| 124 | } |
|
| 125 | ||
| 126 | return true; |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * 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 ('/' === mb_substr($directory, -1)) { |
|
| 590 | $directory = mb_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 | } |
|
| 598 | $directoryHandle = opendir($directory); |
|
| 599 | while (false !== ($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 | ||
| 616 | return true; |
|
| 617 | } |
|
| 618 | } |
|
| 619 | ||
| 620 | /** |
|
| 621 | * Update private settings |
|