Commit 32175950594ba97515ffc4c02dee05cfff578455

Authored by Elena.Budnik
1 parent 1be10ccb

delete hidden file - use scandir in deltree

Showing 1 changed file with 10 additions and 6 deletions   Show diff stats
php/classes/Guest.php
@@ -117,17 +117,21 @@ class Guest { @@ -117,17 +117,21 @@ class Guest {
117 117
118 } 118 }
119 119
120 - public function deltree($f) {  
121 - 120 + public function deltree($f) {
  121 +
122 if (is_dir($f)) { 122 if (is_dir($f)) {
123 - foreach(glob($f.'/*') as $sf) {  
124 - if (is_dir($sf) && !is_link($sf)) {  
125 - $this->deltree($sf); 123 +
  124 + $files = array_diff(scandir($f), array('.','..'));
  125 +
  126 + foreach($files as $sf) {
  127 + if (is_dir("$f/$sf") && !is_link("$f/$sf")) {
  128 + $this->deltree("$f/$sf");
126 } else { 129 } else {
127 - unlink($sf); 130 + unlink("$f/$sf");
128 } 131 }
129 } 132 }
130 } 133 }
  134 +
131 if (is_dir($f)) rmdir($f); 135 if (is_dir($f)) rmdir($f);
132 } 136 }
133 137