dataroot; // The directory to delete! if (empty($sure)) { notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', 'delete.php?sure=yes&sesskey='.sesskey(), 'index.php'); exit; } if (empty($reallysure)) { notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?', 'delete.php?sure=yes&reallysure=yes&sesskey='.sesskey(), 'index.php'); exit; } if (!confirm_sesskey()) { error('This script was called wrongly'); } /// OK, here goes ... delete_subdirectories($deletedir); echo '

Done!

'; print_continue($CFG->wwwroot); exit; function delete_subdirectories($rootdir) { $dir = opendir($rootdir); while ($file = readdir($dir)) { if ($file != '.' and $file != '..') { $fullfile = $rootdir .'/'. $file; if (filetype($fullfile) == 'dir') { delete_subdirectories($fullfile); echo 'Deleting '. $fullfile .' ... '; if (rmdir($fullfile)) { echo 'Done.
'; } else { echo 'FAILED.
'; } } else { echo 'Deleting '. $fullfile .' ... '; if (unlink($fullfile)) { echo 'Done.
'; } else { echo 'FAILED.
'; } } } } closedir($dir); } ?>