| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?PHP //$Id: delete.php,v 1.13.4.2 2008/05/02 04:07:27 dongsheng Exp $ 2 3 // Deletes the moodledata directory, COMPLETELY!! 4 // BE VERY CAREFUL USING THIS! 5 6 require_once ('../config.php'); 7 require_once($CFG->libdir.'/adminlib.php'); 8 9 admin_externalpage_setup('purgemoodledata'); 10 11 require_login(); 12 13 $sure = optional_param('sure', 0, PARAM_BOOL); 14 $reallysure = optional_param('reallysure', 0, PARAM_BOOL); 15 16 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); 17 18 $deletedir = $CFG->dataroot; // The directory to delete! 19 20 admin_externalpage_print_header(); 21 print_heading('Purge moodledata'); 22 23 if (empty($sure)) { 24 $optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey()); 25 notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', 26 'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get'); 27 admin_externalpage_print_footer(); 28 exit; 29 } 30 31 if (!data_submitted() or empty($reallysure)) { 32 $optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes'); 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 'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get'); 35 admin_externalpage_print_footer(); 36 exit; 37 } 38 39 if (!confirm_sesskey()) { 40 error('This script was called wrongly'); 41 } 42 43 /// OK, here goes ... 44 45 delete_subdirectories($deletedir); 46 47 echo '<h1 align="center">Done!</h1>'; 48 print_continue($CFG->wwwroot); 49 admin_externalpage_print_footer(); 50 exit; 51 52 53 function delete_subdirectories($rootdir) { 54 55 $dir = opendir($rootdir); 56 57 while (false !== ($file = readdir($dir))) { 58 if ($file != '.' and $file != '..') { 59 $fullfile = $rootdir .'/'. $file; 60 if (filetype($fullfile) == 'dir') { 61 delete_subdirectories($fullfile); 62 echo 'Deleting '. $fullfile .' ... '; 63 if (rmdir($fullfile)) { 64 echo 'Done.<br />'; 65 } else { 66 echo 'FAILED.<br />'; 67 } 68 } else { 69 echo 'Deleting '. $fullfile .' ... '; 70 if (unlink($fullfile)) { 71 echo 'Done.<br />'; 72 } else { 73 echo 'FAILED.<br />'; 74 } 75 } 76 } 77 } 78 closedir($dir); 79 } 80 81 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |