| @@ 95-128 (lines=34) @@ | ||
| 92 | * @param bool|int $empty |
|
| 93 | * @return true |
|
| 94 | */ |
|
| 95 | public function smallworld_remDir($userid, $directory, $empty = false) |
|
| 96 | { |
|
| 97 | if ('' != $userid) { |
|
| 98 | if ('/' === substr($directory, -1)) { |
|
| 99 | $directory = substr($directory, 0, -1); |
|
| 100 | } |
|
| 101 | ||
| 102 | if (!file_exists($directory) || !is_dir($directory)) { |
|
| 103 | return false; |
|
| 104 | } elseif (!is_readable($directory)) { |
|
| 105 | return false; |
|
| 106 | } else { |
|
| 107 | $directoryHandle = opendir($directory); |
|
| 108 | while ($contents = readdir($directoryHandle)) { |
|
| 109 | if ('.' !== $contents && '..' !== $contents) { |
|
| 110 | $path = $directory . '/' . $contents; |
|
| 111 | if (is_dir($path)) { |
|
| 112 | $this->smallworld_remDir($userid, $path); |
|
| 113 | } else { |
|
| 114 | unlink($path); |
|
| 115 | } |
|
| 116 | } |
|
| 117 | } |
|
| 118 | closedir($directoryHandle); |
|
| 119 | if (false === $empty) { |
|
| 120 | if (!rmdir($directory)) { |
|
| 121 | return false; |
|
| 122 | } |
|
| 123 | } |
|
| 124 | ||
| 125 | return true; |
|
| 126 | } |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * SmallworldDeleteDirectory function |
|
| @@ 587-619 (lines=33) @@ | ||
| 584 | * @param bool|int $empty |
|
| 585 | * @return true |
|
| 586 | */ |
|
| 587 | public function smallworld_remDir($userid, $directory, $empty = false) |
|
| 588 | { |
|
| 589 | if ('' != $userid) { |
|
| 590 | if ('/' === substr($directory, -1)) { |
|
| 591 | $directory = substr($directory, 0, -1); |
|
| 592 | } |
|
| 593 | ||
| 594 | if (!file_exists($directory) || !is_dir($directory)) { |
|
| 595 | return false; |
|
| 596 | } elseif (!is_readable($directory)) { |
|
| 597 | return false; |
|
| 598 | } else { |
|
| 599 | $directoryHandle = opendir($directory); |
|
| 600 | while ($contents = readdir($directoryHandle)) { |
|
| 601 | if ('.' !== $contents && '..' !== $contents) { |
|
| 602 | $path = $directory . '/' . $contents; |
|
| 603 | if (is_dir($path)) { |
|
| 604 | $this->smallworld_remDir($userid, $path); |
|
| 605 | } else { |
|
| 606 | unlink($path); |
|
| 607 | } |
|
| 608 | } |
|
| 609 | } |
|
| 610 | closedir($directoryHandle); |
|
| 611 | if (false === $empty) { |
|
| 612 | if (!rmdir($directory)) { |
|
| 613 | return false; |
|
| 614 | } |
|
| 615 | } |
|
| 616 | return true; |
|
| 617 | } |
|
| 618 | } |
|
| 619 | } |
|
| 620 | ||
| 621 | /** |
|
| 622 | * Update private settings |
|