// Copyright: Copyright (C) 2004-2007 Pristine Communications // rmalldir: Remove a whole directory // Input: The directory $dir to be removed. It won't check at all // Output: none function rmalldir($dir) { // Non-existing if (!file_exists($dir)) { return; } // Get everything inside $ents = array(); $dh = opendir($dir); while (($ent = readdir($dh)) !== false) { // Not a real entry if ($ent == "." || $ent == "..") { continue; } $ents[] = "$dir/$ent"; } closedir($dh); // Remove them foreach ($ents as $ent) { if (is_dir($ent)) { rmalldir($ent); } else { unlink($ent); } } rmdir($dir); return; } ?>