3 // Deletes the moodledata directory, COMPLETELY!!
4 // BE VERY CAREFUL USING THIS!
6 require_once('../config.php');
10 $sure = optional_param('sure', 0, PARAM_BOOL
);
11 $reallysure = optional_param('reallysure', 0, PARAM_BOOL
);
14 error('You must be admin to use this script!');
17 $deletedir = $CFG->dataroot
; // The directory to delete!
20 notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', 'delete.php?sure=yes&sesskey='.sesskey(), 'index.php');
24 if (empty($reallysure)) {
25 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');
29 if (!confirm_sesskey()) {
30 error('This script was called wrongly');
35 delete_subdirectories($deletedir);
37 echo '<h1 align="center">Done!</h1>';
38 print_continue($CFG->wwwroot
);
42 function delete_subdirectories($rootdir) {
44 $dir = opendir($rootdir);
46 while ($file = readdir($dir)) {
47 if ($file != '.' and $file != '..') {
48 $fullfile = $rootdir .'/'. $file;
49 if (filetype($fullfile) == 'dir') {
50 delete_subdirectories($fullfile);
51 echo 'Deleting '. $fullfile .' ... ';
52 if (rmdir($fullfile)) {
58 echo 'Deleting '. $fullfile .' ... ';
59 if (unlink($fullfile)) {