1
<?PHP //$Id: delete.php,v 1.12 2006/09/25 20:22:56 skodak Exp $
1
<?PHP //$Id: delete.php,v 1.13.4.2 2008/05/02 04:07:27 dongsheng Exp $
3
3
// Deletes the moodledata directory, COMPLETELY!!
4
4
// BE VERY CAREFUL USING THIS!
6
6
require_once('../config.php');
7
7
require_once($CFG->libdir.'/adminlib.php');
8
$adminroot = admin_get_root();
9
admin_externalpage_setup('purgemoodledata', $adminroot);
9
admin_externalpage_setup('purgemoodledata');
13
13
$sure = optional_param('sure', 0, PARAM_BOOL);
14
14
$reallysure = optional_param('reallysure', 0, PARAM_BOOL);
16
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
16
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
18
18
$deletedir = $CFG->dataroot; // The directory to delete!
20
admin_externalpage_print_header($adminroot);
20
admin_externalpage_print_header();
21
21
print_heading('Purge moodledata');
23
23
if (empty($sure)) {
24
24
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey());
25
25
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?',
26
26
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
27
admin_externalpage_print_footer($adminroot);
27
admin_externalpage_print_footer();
32
32
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
33
33
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) ?',
34
34
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
35
admin_externalpage_print_footer($adminroot);
35
admin_externalpage_print_footer();
55
55
$dir = opendir($rootdir);
57
while ($file = readdir($dir)) {
57
while (false !== ($file = readdir($dir))) {
58
58
if ($file != '.' and $file != '..') {
59
59
$fullfile = $rootdir .'/'. $file;
60
60
if (filetype($fullfile) == 'dir') {