New translation added.
[moodle.git] / admin / delete.php
blobca1988a3f02127703fd716185b9bcf0873d85e77
1 <?PHP //$Id$
3 // Deletes the moodledata directory, COMPLETELY!!
4 // BE VERY CAREFUL USING THIS!
6 require_once("../config.php");
8 require_login();
10 if (!isadmin()) {
11 error("You must be admin to use this script!");
14 $deletedir = $CFG->dataroot; // The directory to delete!
16 if (!$sure) {
17 notice_yesno ("Are you completely sure you want to delete everything inside the directory $deletedir ?", "delete.php?sure=yes", "index.php");
18 exit;
21 if (!$reallysure) {
22 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", "index.php");
23 exit;
26 /// OK, here goes ...
28 delete_subdirectories($deletedir);
30 echo "<H1 align=center>Done!</H1>";
31 print_continue($CFG->wwwroot);
32 exit;
35 function delete_subdirectories($rootdir) {
37 $dir = opendir($rootdir);
39 while ($file = readdir($dir)) {
40 if ($file != "." and $file != "..") {
41 $fullfile = "$rootdir/$file";
42 if (filetype($fullfile) == "dir") {
43 delete_subdirectories($fullfile);
44 echo "Deleting $fullfile ... ";
45 if (rmdir($fullfile)) {
46 echo "Done.<BR>";
47 } else {
48 echo "FAILED.<BR>";
50 } else {
51 echo "Deleting $fullfile ... ";
52 if (unlink("$fullfile")) {
53 echo "Done.<BR>";
54 } else {
55 echo "FAILED.<BR>";
60 closedir($dir);