2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2004 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
14 define('AT_INCLUDE_PATH', '../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 require(AT_INCLUDE_PATH.'lib/filemanager.inc.php');
18 if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
19 authenticate(AT_PRIV_CONTENT);
22 $current_path = AT_CONTENT_DIR.$_SESSION['course_id'].'/';
24 $popup = $_REQUEST['popup'];
25 $framed = $_REQUEST['framed'];
27 if (isset($_POST['submit_no'])) {
28 $msg->addFeedback('CANCELLED');
29 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup']);
33 if (isset($_POST['submit_yes'])) {
34 /* delete files and directories */
36 $pathext = $_POST['pathext'];
37 if (isset($_POST['listoffiles'])) {
38 $checkbox = explode(',',$_POST['listoffiles']);
39 $count = count($checkbox);
41 for ($i=0; $i<$count; $i++) {
42 $filename=$checkbox[$i];
44 if (course_realpath($current_path . $pathext . $filename) == FALSE) {
45 $msg->addError('FILE_NOT_DELETED');
48 } else if (!(@unlink($current_path.$pathext.$filename))) {
49 $msg->addError('FILE_NOT_DELETED');
55 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
57 /* delete directory */
58 if (isset($_POST['listofdirs'])) {
60 $checkbox = explode(',',$_POST['listofdirs']);
61 $count = count($checkbox);
63 for ($i=0; $i<$count; $i++) {
64 $filename=$checkbox[$i];
66 if (strpos($filename, '..') !== false) {
67 $msg->addError('UNKNOWN');
69 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup']);
71 } else if (!is_dir($current_path.$pathext.$filename)) {
72 $msg->addError(array('DIR_NOT_DELETED',$filename));
74 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup']);
76 } else if (!($result = clr_dir($current_path.$pathext.$filename))) {
77 $msg->addError('DIR_NO_PERMISSION');
79 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup']);
84 $msg->addFeedback('DIR_DELETED');
87 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup']);
91 require(AT_INCLUDE_PATH.'header.inc.php');
92 // find the files and directories to be deleted
93 $total_list = explode(',', $_GET['list']);
94 $pathext = $_GET['pathext'];
95 $popup = $_GET['popup'];
96 $framed = $_GET['framed'];
98 $count = count($total_list);
102 foreach ($total_list as $list_item) {
103 if (is_dir($current_path.$pathext.$list_item)) {
104 $_dirs[$countd] = $list_item;
107 $_files[$countf] = $list_item;
112 $hidden_vars['pathext'] = $pathext;
113 $hidden_vars['popup'] = $popup;
114 $hidden_vars['framed'] = $framed;
116 if (isset($_files)) {
117 $list_of_files = implode(',', $_files);
118 $hidden_vars['listoffiles'] = $list_of_files;
120 foreach ($_files as $file) {
121 $file_list_to_print .= '<li>'.$file.'</li>';
123 $msg->addConfirm(array('FILE_DELETE', $file_list_to_print), $hidden_vars);
127 $list_of_dirs = implode(',', $_dirs);
128 $hidden_vars['listofdirs'] = $list_of_dirs;
130 foreach ($_dirs as $dir) {
131 $dir_list_to_print .= '<li>'.$dir.'</li>';
134 $msg->addConfirm(array('DIR_DELETE',$dir_list_to_print), $hidden_vars);
137 $msg->printConfirm();
139 require(AT_INCLUDE_PATH.'footer.inc.php');