2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
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_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/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['cancel'])) {
28 $msg->addFeedback('CANCELLED');
29 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type']);
33 if (isset($_POST['rename_action'])) {
35 $_POST['new_name'] = trim($_POST['new_name']);
36 $_POST['new_name'] = str_replace(' ', '_', $_POST['new_name']);
37 $_POST['new_name'] = str_replace(array(' ', '/', '\\', ':', '*', '?', '"', '<', '>', '|', '\''), '', $_POST['new_name']);
39 $_POST['oldname'] = trim($_POST['oldname']);
40 $_POST['oldname'] = str_replace(array(' ', '/', '\\', ':', '*', '?', '"', '<', '>', '|', '\''), '', $_POST['oldname']);
42 $path_parts_new = pathinfo($_POST['new_name']);
43 $ext_new = $path_parts_new['extension'];
44 $pathext = $_POST['pathext'];
46 /* check if this file extension is allowed: */
47 /* $IllegalExtentions is defined in ./include/config.inc.php */
48 if (in_array($ext_new, $IllegalExtentions)) {
49 $errors = array('FILE_ILLEGAL', $ext_new);
50 $msg->addError($errors);
52 else if ($current_path.$pathext.$_POST['new_name'] == $current_path.$pathext.$_POST['oldname']) {
54 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
55 header('Location: index.php?pathext='.urlencode($_POST['pathext']).SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type']);
59 //make sure new file is inside content directory
60 else if (course_realpath($current_path . $pathext . $_POST['new_name']) == FALSE) {
61 $msg->addError('CANNOT_RENAME');
63 else if (course_realpath($current_path . $pathext . $_POST['oldname']) == FALSE) {
64 $msg->addError('CANNOT_RENAME');
66 else if (file_exists($current_path . $pathext . $_POST['new_name'])) {
67 $msg->addError('CANNOT_RENAME');
70 @rename($current_path.$pathext.$_POST['oldname'], $current_path.$pathext.$_POST['new_name']);
71 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
72 header('Location: index.php?pathext='.urlencode($_POST['pathext']).SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type']);
77 require(AT_INCLUDE_PATH.'header.inc.php');
79 <form name="rename" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
80 <input type="hidden" name="pathext" value="<?php echo $_REQUEST['pathext']; ?>" />
81 <input type="hidden" name="oldname" value="<?php echo $_REQUEST['oldname']; ?>" />
82 <input type="hidden" name="framed" value="<?php echo $_REQUEST['framed']; ?>" />
83 <input type="hidden" name="popup" value="<?php echo $_REQUEST['popup']; ?>" />
85 <div class="input-form">
87 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span>
88 <label for="new"><?php echo _AT('new_name'); ?></label><br />
89 <?php echo $_GET['pathext']; ?><input type="text" name="new_name" id="new" value="<?php echo $_REQUEST['oldname']; ?>" size="30" />
92 <div class="row buttons">
93 <input type="submit" name="rename_action" value="<?php echo _AT('save'); ?>" accesskey="s" />
94 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
99 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>