diff --git a/class_csrf.php b/class_csrf.php
new file mode 100644
index 00000000..521c0d35
--- /dev/null
+++ b/class_csrf.php
@@ -0,0 +1,104 @@
+";
+ }
+
+ /**
+ * Returns true if user-submitted POST token is
+ * identical to the previously stored SESSION token.
+ * Returns false otherwise.
+ */
+ public static function isValid()
+ {
+ if (isset($_POST['token']))
+ {
+ $user_token = $_POST['token'];
+ $stored_token = $_SESSION['token'];
+ return hash_equals($_SESSION['token'], $_POST['token']);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * You can simply check the token validity and
+ * handle the failure yourself, or you can use
+ * this "stop-everything-on-failure" method.
+ */
+ public static function exitOnFailure()
+ {
+ if (!self::isValid())
+ {
+ exit('Invalid Security Token.');
+ }
+ }
+
+ /**
+ * This doesn't have to be used but it
+ * checks to see if the token is recent.
+ */
+ public static function isRecent()
+ {
+ if (isset($_SESSION['token_time']))
+ {
+ $stored_time = $_SESSION['token_time'];
+ return ($stored_time + self::$max_elapsed) >= time();
+ }
+ else
+ {
+ self::destroyToken();
+ return false;
+ }
+ }
+}
diff --git a/documentation/index.php b/documentation/index.php
index ffa0a10c..126ba889 100644
--- a/documentation/index.php
+++ b/documentation/index.php
@@ -11,13 +11,16 @@
/************************************************************************/
define('TR_INCLUDE_PATH', '../include/');
+
include(TR_INCLUDE_PATH.'vitals.inc.php');
include(TR_INCLUDE_PATH.'handbook_pages.inc.php');
global $handbook_pages;
if (isset($_GET['p'])) {
- $p = htmlentities($_GET['p']);
+ // We depend on htmlspecialchars, trim, stripslashes, and strip_tags to prevent Reflected XSS
+ // for p parameter
+ $p = htmlspecialchars(trim(stripslashes(strip_tags($_GET['p']))));
} else {
// go to first handbook page defined in $handbook_pages
foreach ($handbook_pages as $page_key => $page_value)
diff --git a/file_manager/delete.php b/file_manager/delete.php
index 1feea3d9..9b5af48f 100644
--- a/file_manager/delete.php
+++ b/file_manager/delete.php
@@ -1,172 +1,173 @@
-addFeedback('CANCELLED');
- 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'].SEP.'_course_id='.$_course_id);
- exit;
-}
-
-if (isset($_POST['submit_yes'])) {
- /* delete files and directories */
- /* delete the file */
- $pathext = $_POST['pathext'];
- if (isset($_POST['listoffiles'])) {
- $checkbox = explode(',',$_POST['listoffiles']);
- $count = count($checkbox);
- $result=true;
- for ($i=0; $i<$count; $i++) {
- $filename=$checkbox[$i];
-
- if (FileUtility::course_realpath($current_path . $pathext . $filename) == FALSE) {
- $msg->addError('FILE_NOT_DELETED');
- $result=false;
- break;
- } else if (!(@unlink($current_path.$pathext.$filename))) {
- $msg->addError('FILE_NOT_DELETED');
- $result=false;
- break;
- }
- }
- if ($result)
- {
- // delete according definition of primary resources and alternatives for adapted content
- $filename = '../'.$pathext.$filename;
-
- // 1. delete secondary resources types
- $secondaryResourcesTypesDAO = new SecondaryResourcesTypesDAO();
- $secondaryResourcesTypesDAO->DeleteByResourceName($filename);
-
- // 2. delete secondary resources
- $secondaryResourcesDAO = new SecondaryResourcesDAO();
- $secondaryResourcesDAO->DeleteByResourceName($filename);
-
- // 3. delete primary resources types
- $primaryResourcesTypesDAO = new PrimaryResourcesTypesDAO();
- $primaryResourcesTypesDAO->DeleteByResourceName($filename);
-
- // 4. delete primary resources
- $primaryResourcesDAO = new PrimaryResourcesDAO();
- $primaryResourcesDAO->DeleteByResourceName($filename);
-
- $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
- }
- }
- /* delete directory */
- if (isset($_POST['listofdirs'])) {
-
- $checkbox = explode(',',$_POST['listofdirs']);
- $count = count($checkbox);
- $result=true;
- for ($i=0; $i<$count; $i++) {
- $filename=$checkbox[$i];
-
- if (strpos($filename, '..') !== false) {
- $msg->addError('UNKNOWN');
- $result=false;
- 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'].SEP.'_course_id='.$_course_id);
- exit;
- } else if (!is_dir($current_path.$pathext.$filename)) {
- $msg->addError(array('DIR_NOT_DELETED',$filename));
- $result=false;
- 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'].SEP.'_course_id='.$_course_id);
- exit;
- } else if (!($result = FileUtility::clr_dir($current_path.$pathext.$filename))) {
- $msg->addError('DIR_NO_PERMISSION');
- $result=false;
- 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'].SEP.'_course_id='.$_course_id);
- exit;
- }
- }
- if ($result)
- $msg->addFeedback('DIR_DELETED');
- }
-
- 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'].SEP.'_course_id='.$_course_id);
- exit;
-}
-
- require(TR_INCLUDE_PATH.'header.inc.php');
- // find the files and directories to be deleted
- $total_list = explode(',', $_GET['list']);
- $pathext = $_GET['pathext'];
- $popup = $_GET['popup'];
- $framed = $_GET['framed'];
- $cp = $_GET['cp'];
- $cid = $_GET['cid'];
- $pid = $_GET['pid'];
- $a_type = $_GET['a_type'];
-
- $count = count($total_list);
- $countd = 0;
- $countf = 0;
-
- foreach ($total_list as $list_item) {
- if (is_dir($current_path.$pathext.$list_item)) {
- $_dirs[$countd] = $list_item;
- $countd++;
- } else {
- $_files[$countf] = $list_item;
- $countf++;
- }
- }
-
- $hidden_vars['pathext'] = $pathext;
- $hidden_vars['popup'] = $popup;
- $hidden_vars['framed'] = $framed;
- $hidden_vars['cp'] = $cp;
- $hidden_vars['cid'] = $cid;
- $hidden_vars['pid'] = $pid;
- $hidden_vars['a_type'] = $a_type;
- $hidden_vars['_course_id'] = $_course_id;
-
- if (isset($_files)) {
- $list_of_files = implode(',', $_files);
- $hidden_vars['listoffiles'] = $list_of_files;
-
- foreach ($_files as $file) {
- $file_list_to_print .= '
'.$file.'';
- }
- $msg->addConfirm(array('FILE_DELETE', $file_list_to_print), $hidden_vars);
- }
-
- if (isset($_dirs)) {
- $list_of_dirs = implode(',', $_dirs);
- $hidden_vars['listofdirs'] = $list_of_dirs;
-
- foreach ($_dirs as $dir) {
- $dir_list_to_print .= ''.$dir.'';
- }
-
- $msg->addConfirm(array('DIR_DELETE',$dir_list_to_print), $hidden_vars);
- }
-
- $msg->printConfirm();
-
- require(TR_INCLUDE_PATH.'footer.inc.php');
-?>
+addFeedback('CANCELLED');
+ 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'].SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+if (isset($_POST['submit_yes'])) {
+ /* delete files and directories */
+ /* delete the file */
+ $pathext = $_POST['pathext'];
+ if (isset($_POST['listoffiles'])) {
+ $checkbox = explode(',',$_POST['listoffiles']);
+ $count = count($checkbox);
+ $result=true;
+ for ($i=0; $i<$count; $i++) {
+ $filename=$checkbox[$i];
+
+ if (FileUtility::course_realpath($current_path . $pathext . $filename) == FALSE) {
+ $msg->addError('FILE_NOT_DELETED');
+ $result=false;
+ break;
+ } else if (!(@unlink($current_path.$pathext.$filename))) {
+ $msg->addError('FILE_NOT_DELETED');
+ $result=false;
+ break;
+ }
+ }
+ if ($result)
+ {
+ // delete according definition of primary resources and alternatives for adapted content
+ $filename = '../'.$pathext.$filename;
+
+ // 1. delete secondary resources types
+ $secondaryResourcesTypesDAO = new SecondaryResourcesTypesDAO();
+ $secondaryResourcesTypesDAO->DeleteByResourceName($filename);
+
+ // 2. delete secondary resources
+ $secondaryResourcesDAO = new SecondaryResourcesDAO();
+ $secondaryResourcesDAO->DeleteByResourceName($filename);
+
+ // 3. delete primary resources types
+ $primaryResourcesTypesDAO = new PrimaryResourcesTypesDAO();
+ $primaryResourcesTypesDAO->DeleteByResourceName($filename);
+
+ // 4. delete primary resources
+ $primaryResourcesDAO = new PrimaryResourcesDAO();
+ $primaryResourcesDAO->DeleteByResourceName($filename);
+
+ $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+ }
+ }
+ /* delete directory */
+ if (isset($_POST['listofdirs'])) {
+
+ $checkbox = explode(',',$_POST['listofdirs']);
+ $count = count($checkbox);
+ $result=true;
+ for ($i=0; $i<$count; $i++) {
+ $filename=$checkbox[$i];
+
+ if (strpos($filename, '..') !== false) {
+ $msg->addError('UNKNOWN');
+ $result=false;
+ 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'].SEP.'_course_id='.$_course_id);
+ exit;
+ } else if (!is_dir($current_path.$pathext.$filename)) {
+ $msg->addError(array('DIR_NOT_DELETED',$filename));
+ $result=false;
+ 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'].SEP.'_course_id='.$_course_id);
+ exit;
+ } else if (!($result = FileUtility::clr_dir($current_path.$pathext.$filename))) {
+ $msg->addError('DIR_NO_PERMISSION');
+ $result=false;
+ 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'].SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ }
+ if ($result)
+ $msg->addFeedback('DIR_DELETED');
+ }
+
+ 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'].SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+ require(TR_INCLUDE_PATH.'header.inc.php');
+ // find the files and directories to be deleted
+ $total_list = explode(',', $_GET['list']);
+ $pathext = $_GET['pathext'];
+ $popup = $_GET['popup'];
+ $framed = $_GET['framed'];
+ $cp = $_GET['cp'];
+ $cid = $_GET['cid'];
+ $pid = $_GET['pid'];
+ $a_type = $_GET['a_type'];
+
+ $count = count($total_list);
+ $countd = 0;
+ $countf = 0;
+
+ foreach ($total_list as $list_item) {
+ if (is_dir($current_path.$pathext.$list_item)) {
+ $_dirs[$countd] = $list_item;
+ $countd++;
+ } else {
+ $_files[$countf] = $list_item;
+ $countf++;
+ }
+ }
+
+ $hidden_vars['pathext'] = $pathext;
+ $hidden_vars['popup'] = $popup;
+ $hidden_vars['framed'] = $framed;
+ $hidden_vars['cp'] = $cp;
+ $hidden_vars['cid'] = $cid;
+ $hidden_vars['pid'] = $pid;
+ $hidden_vars['a_type'] = $a_type;
+ $hidden_vars['_course_id'] = $_course_id;
+
+ if (isset($_files)) {
+ $list_of_files = implode(',', $_files);
+ $hidden_vars['listoffiles'] = $list_of_files;
+
+ foreach ($_files as $file) {
+ $file_list_to_print .= ''.$file.'';
+ }
+ $msg->addConfirm(array('FILE_DELETE', $file_list_to_print), $hidden_vars);
+ }
+
+ if (isset($_dirs)) {
+ $list_of_dirs = implode(',', $_dirs);
+ $hidden_vars['listofdirs'] = $list_of_dirs;
+
+ foreach ($_dirs as $dir) {
+ $dir_list_to_print .= ''.$dir.'';
+ }
+
+ $msg->addConfirm(array('DIR_DELETE',$dir_list_to_print), $hidden_vars);
+ }
+
+ $msg->printConfirm();
+
+ require(TR_INCLUDE_PATH.'footer.inc.php');
+?>
diff --git a/file_manager/edit.php b/file_manager/edit.php
index 76cd9631..34f69201 100644
--- a/file_manager/edit.php
+++ b/file_manager/edit.php
@@ -11,6 +11,7 @@
/************************************************************************/
define('TR_INCLUDE_PATH', '../include/');
+
require_once(TR_INCLUDE_PATH.'vitals.inc.php');
require_once(TR_INCLUDE_PATH.'classes/FileUtility.class.php');
diff --git a/file_manager/index.php b/file_manager/index.php
index d7fa0344..b43f3a3b 100644
--- a/file_manager/index.php
+++ b/file_manager/index.php
@@ -1,91 +1,92 @@
-
-
-
-';
- }
-
- $fluid_dir = 'include/jscripts/infusion/';
- $framed = intval($_GET['framed']);
- $popup = intval($_GET['popup']);
- $current_path = TR_CONTENT_DIR.$_course_id.'/';
-
- if ($_GET['pathext'] != '') {
- $pathext = urldecode($_GET['pathext']);
- } else if ($_POST['pathext'] != '') {
- $pathext = $_POST['pathext'];
- }
-
- if($_GET['back'] == 1) {
- $pathext = substr($pathext, 0, -1);
- $slashpos = strrpos($pathext, '/');
- if($slashpos == 0) {
- $pathext = '';
- } else {
- $pathext = substr($pathext, 0, ($slashpos+1));
- }
-
- }
-}
-
-global $msg;
-if (isset($_GET['msg'])) $msg->addFeedback($_GET['msg']);
-
-require('top.php');
-$_SESSION['done'] = 1;
-
-require(TR_INCLUDE_PATH.'../file_manager/filemanager_display.inc.php');
-
-closedir($dir);
-
-?>
-
-
+
+
+
+';
+ }
+
+ $fluid_dir = 'include/jscripts/infusion/';
+ $framed = intval($_GET['framed']);
+ $popup = intval($_GET['popup']);
+ $current_path = TR_CONTENT_DIR.$_course_id.'/';
+
+ if ($_GET['pathext'] != '') {
+ $pathext = urldecode($_GET['pathext']);
+ } else if ($_POST['pathext'] != '') {
+ $pathext = $_POST['pathext'];
+ }
+
+ if($_GET['back'] == 1) {
+ $pathext = substr($pathext, 0, -1);
+ $slashpos = strrpos($pathext, '/');
+ if($slashpos == 0) {
+ $pathext = '';
+ } else {
+ $pathext = substr($pathext, 0, ($slashpos+1));
+ }
+
+ }
+}
+
+global $msg;
+if (isset($_GET['msg'])) $msg->addFeedback($_GET['msg']);
+
+require('top.php');
+$_SESSION['done'] = 1;
+
+require(TR_INCLUDE_PATH.'../file_manager/filemanager_display.inc.php');
+
+closedir($dir);
+
+?>
+
+
diff --git a/file_manager/move.php b/file_manager/move.php
index 8ce3ca85..abdb499f 100644
--- a/file_manager/move.php
+++ b/file_manager/move.php
@@ -1,206 +1,207 @@
-addFeedback('CANCELLED');
- 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'].SEP.'_course_id='.$_course_id);
- exit;
-}
-
-if (isset($_POST['cancel'])) {
- $msg->addFeedback('CANCELLED');
- header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_REQUEST['framed'].SEP.'popup='.$_REQUEST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
- exit;
-}
-
-if (isset($_POST['submit_yes'])) {
- $dest = $_POST['dest'] .'/';
- $pathext = $_POST['pathext'];
-
- if (isset($_POST['listofdirs'])) {
-
- $_dirs = explode(',',$_POST['listofdirs']);
- $count = count($_dirs);
-
- for ($i = 0; $i < $count; $i++) {
- $source = $_dirs[$i];
-
- if (FileUtility::course_realpath($current_path . $pathext . $source) == FALSE) {
- // error: File does not exist
- $msg->addError('DIR_NOT_EXIST');
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
- exit;
- }
- else if (FileUtility::course_realpath($current_path . $dest) == FALSE) {
- // error: File does not exist
- $msg->addError('UNKNOWN');
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
- exit;
- }
- else if (strpos($source, '..') !== false) {
- $msg->addError('UNKNOWN');
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
- exit;
- }
- else {
- @rename($current_path.$pathext.$source, $current_path.$dest.$source);
- }
- }
- $msg->addFeedback('DIRS_MOVED');
- }
- if (isset($_POST['listoffiles'])) {
-
- $_files = explode(',',$_POST['listoffiles']);
- $count = count($_files);
-
- for ($i = 0; $i < $count; $i++) {
- $source = $_files[$i];
-
- if (FileUtility::course_realpath($current_path . $pathext . $source) == FALSE) {
- // error: File does not exist
- $msg->addError('FILE_NOT_EXIST');
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
- exit;
- }
- else if (FileUtility::course_realpath($current_path . $dest) == FALSE) {
- // error: File does not exist
- $msg->addError('UNKNOWN');
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
- exit;
- }
- else if (strpos($source, '..') !== false) {
- $msg->addError('UNKNOWN');
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
- exit;
- }
- else {
- @rename($current_path.$pathext.$source, $current_path.$dest.$source);
- }
- }
- $msg->addFeedback('MOVED_FILES');
- }
- 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'].SEP.'_course_id='.$_course_id);
- exit;
-}
-
-if (isset($_POST['dir_chosen'])) {
- $hidden_vars['framed'] = $_REQUEST['framed'];
- $hidden_vars['popup'] = $_REQUEST['popup'];
- $hidden_vars['pathext'] = $_REQUEST['pathext'];
- $hidden_vars['dest'] = $_REQUEST['dir_name'];
- $hidden_vars['cp'] = $_REQUEST['cp'];
- $hidden_vars['cid'] = $_REQUEST['cid'];
- $hidden_vars['pid'] = $_REQUEST['pid'];
- $hidden_vars['a_type'] = $_REQUEST['a_type'];
- $hidden_vars['_course_id'] = $_course_id;
-
- if (isset($_POST['files'])) {
- $list_of_files = implode(',', $_POST['files']);
- $hidden_vars['listoffiles'] = $list_of_files;
- $msg->addConfirm(array('FILE_MOVE', $list_of_files, $_POST['dir_name']), $hidden_vars);
- }
- if (isset($_POST['dirs'])) {
- $list_of_dirs = implode(',', $_POST['dirs']);
- $hidden_vars['listoffiles'] = $list_of_dirs;
- $msg->addConfirm(array('DIR_MOVE', $list_of_dirs, $_POST['dir_name']), $hidden_vars);
- }
- require(TR_INCLUDE_PATH.'header.inc.php');
- $msg->printConfirm();
- require(TR_INCLUDE_PATH.'footer.inc.php');
-}
-else {
- require(TR_INCLUDE_PATH.'header.inc.php');
-
- $tree = TR_CONTENT_DIR.$_course_id.'/';
- $file = $_GET['file'];
- $pathext = $_GET['pathext'];
- $popup = $_GET['popup'];
- $framed = $_GET['framed'];
- $cp = $_GET['cp'];
- $cid = $_GET['cid'];
- $pid = $_GET['pid'];
- $a_type = $_GET['a_type'];
-
- /* find the files and directories to be copied */
- $total_list = explode(',', $_GET['list']);
-
- $count = count($total_list);
- $countd = 0;
- $countf = 0;
- for ($i=0; $i<$count; $i++) {
- if (is_dir($current_path.$pathext.$total_list[$i])) {
- $_dirs[$countd] = $total_list[$i];
- $hidden_dirs .= '';
- $countd++;
- } else {
- $_files[$countf] = $total_list[$i];
- $hidden_files .= '';
- $countf++;
- }
- }
-?>
-
-
-
-
\ No newline at end of file
+addFeedback('CANCELLED');
+ 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'].SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+if (isset($_POST['cancel'])) {
+ $msg->addFeedback('CANCELLED');
+ header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_REQUEST['framed'].SEP.'popup='.$_REQUEST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+if (isset($_POST['submit_yes'])) {
+ $dest = $_POST['dest'] .'/';
+ $pathext = $_POST['pathext'];
+
+ if (isset($_POST['listofdirs'])) {
+
+ $_dirs = explode(',',$_POST['listofdirs']);
+ $count = count($_dirs);
+
+ for ($i = 0; $i < $count; $i++) {
+ $source = $_dirs[$i];
+
+ if (FileUtility::course_realpath($current_path . $pathext . $source) == FALSE) {
+ // error: File does not exist
+ $msg->addError('DIR_NOT_EXIST');
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ else if (FileUtility::course_realpath($current_path . $dest) == FALSE) {
+ // error: File does not exist
+ $msg->addError('UNKNOWN');
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ else if (strpos($source, '..') !== false) {
+ $msg->addError('UNKNOWN');
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ else {
+ @rename($current_path.$pathext.$source, $current_path.$dest.$source);
+ }
+ }
+ $msg->addFeedback('DIRS_MOVED');
+ }
+ if (isset($_POST['listoffiles'])) {
+
+ $_files = explode(',',$_POST['listoffiles']);
+ $count = count($_files);
+
+ for ($i = 0; $i < $count; $i++) {
+ $source = $_files[$i];
+
+ if (FileUtility::course_realpath($current_path . $pathext . $source) == FALSE) {
+ // error: File does not exist
+ $msg->addError('FILE_NOT_EXIST');
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ else if (FileUtility::course_realpath($current_path . $dest) == FALSE) {
+ // error: File does not exist
+ $msg->addError('UNKNOWN');
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ else if (strpos($source, '..') !== false) {
+ $msg->addError('UNKNOWN');
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ else {
+ @rename($current_path.$pathext.$source, $current_path.$dest.$source);
+ }
+ }
+ $msg->addFeedback('MOVED_FILES');
+ }
+ 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'].SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+if (isset($_POST['dir_chosen'])) {
+ $hidden_vars['framed'] = $_REQUEST['framed'];
+ $hidden_vars['popup'] = $_REQUEST['popup'];
+ $hidden_vars['pathext'] = $_REQUEST['pathext'];
+ $hidden_vars['dest'] = $_REQUEST['dir_name'];
+ $hidden_vars['cp'] = $_REQUEST['cp'];
+ $hidden_vars['cid'] = $_REQUEST['cid'];
+ $hidden_vars['pid'] = $_REQUEST['pid'];
+ $hidden_vars['a_type'] = $_REQUEST['a_type'];
+ $hidden_vars['_course_id'] = $_course_id;
+
+ if (isset($_POST['files'])) {
+ $list_of_files = implode(',', $_POST['files']);
+ $hidden_vars['listoffiles'] = $list_of_files;
+ $msg->addConfirm(array('FILE_MOVE', $list_of_files, $_POST['dir_name']), $hidden_vars);
+ }
+ if (isset($_POST['dirs'])) {
+ $list_of_dirs = implode(',', $_POST['dirs']);
+ $hidden_vars['listoffiles'] = $list_of_dirs;
+ $msg->addConfirm(array('DIR_MOVE', $list_of_dirs, $_POST['dir_name']), $hidden_vars);
+ }
+ require(TR_INCLUDE_PATH.'header.inc.php');
+ $msg->printConfirm();
+ require(TR_INCLUDE_PATH.'footer.inc.php');
+}
+else {
+ require(TR_INCLUDE_PATH.'header.inc.php');
+
+ $tree = TR_CONTENT_DIR.$_course_id.'/';
+ $file = $_GET['file'];
+ $pathext = $_GET['pathext'];
+ $popup = $_GET['popup'];
+ $framed = $_GET['framed'];
+ $cp = $_GET['cp'];
+ $cid = $_GET['cid'];
+ $pid = $_GET['pid'];
+ $a_type = $_GET['a_type'];
+
+ /* find the files and directories to be copied */
+ $total_list = explode(',', $_GET['list']);
+
+ $count = count($total_list);
+ $countd = 0;
+ $countf = 0;
+ for ($i=0; $i<$count; $i++) {
+ if (is_dir($current_path.$pathext.$total_list[$i])) {
+ $_dirs[$countd] = $total_list[$i];
+ $hidden_dirs .= '';
+ $countd++;
+ } else {
+ $_files[$countf] = $total_list[$i];
+ $hidden_files .= '';
+ $countf++;
+ }
+ }
+?>
+
+
+
+
diff --git a/file_manager/new.php b/file_manager/new.php
index 9051d0b5..b3297f2a 100644
--- a/file_manager/new.php
+++ b/file_manager/new.php
@@ -1,201 +1,202 @@
-addFeedback('CANCELLED');
- header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'_course_id='.$_course_id);
- exit;
-}
-
-if (isset($_POST['submit_no'])) {
- $msg->addFeedback('CANCELLED');
- header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'_course_id='.$_course_id);
- exit;
-}
-
-if (isset($_POST['submit_yes'])) {
- $filename = preg_replace("{[^a-zA-Z0-9_]}","_", trim($_POST['filename']));
- $pathext = $_POST['pathext'];
-
- /* only html or txt extensions allowed */
- if ($_POST['extension'] == 'html') {
- $extension = 'html';
- } else {
- $extension = 'txt';
- }
-
- if (FileUtility::course_realpath($current_path . $pathext . $filename.'.'.$extension) == FALSE) {
- $msg->addError('FILE_NOT_SAVED');
- /* take user to home page to avoid unspecified error warning */
- header('Location: index.php?pathext='.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
- exit;
- }
-
- if (($f = @fopen($current_path.$pathext.$filename.'.'.$extension,'w')) && @fwrite($f, stripslashes($_POST['body_text'])) !== FALSE && @fclose($f)){
- $msg->addFeedback('FILE_OVERWRITE');
- } else {
- $msg->addError('CANNOT_OVERWRITE_FILE');
- }
- unset($_POST['newfile']);
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
- exit;
-}
-
-if (isset($_POST['savenewfile'])) {
-
- if (isset($_POST['filename']) && ($_POST['filename'] != "")) {
- $filename = preg_replace("{[^a-zA-Z0-9_]}","_", trim($_POST['filename']));
- $pathext = $_POST['pathext'];
- $current_path = TR_CONTENT_DIR.$_course_id.'/';
-
- /* only html or txt extensions allowed */
- if ($_POST['extension'] == 'html') {
- $extension = 'html';
- $head_html = "\n\n".$_POST['filename']."\n\n";
- $foot_html ="\n\n";
- } else {
- $extension = 'txt';
- }
-
- if (!@file_exists($current_path.$pathext.$filename.'.'.$extension)) {
- $content = str_replace("\r\n", "\n", $head_html.$_POST['body_text'].$foot_html);
-
- if (FileUtility::course_realpath($current_path . $pathext . $filename.'.'.$extension) == FALSE) {
- $msg->addError('FILE_NOT_SAVED');
- /* take user to home page to avoid unspecified error warning */
- header('Location: index.php?pathext='.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
- exit;
- }
-
- if (($f = fopen($current_path.$pathext.$filename.'.'.$extension, 'w')) && (@fwrite($f, stripslashes($content)) !== false) && (@fclose($f))) {
- $msg->addFeedback(array('FILE_SAVED', $filename.'.'.$extension));
- header('Location: index.php?pathext='.urlencode($_POST['pathext']).SEP.'popup='.$_POST['popup'].SEP.'_course_id='.$_course_id);
- exit;
- } else {
- $msg->addError('FILE_NOT_SAVED');
- header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
- exit;
- }
- }
- else {
- require(TR_INCLUDE_PATH.'header.inc.php');
- $pathext = $_POST['pathext'];
- $popup = $_POST['popup'];
-
- $_POST['newfile'] = "new";
-
- $hidden_vars['pathext'] = $pathext;
- $hidden_vars['filename'] = $filename;
- $hidden_vars['extension'] = $extension;
- $hidden_vars['_course_id'] = $_course_id;
- $hidden_vars['body_text'] = $_POST['body_text'];
-
- $hidden_vars['popup'] = $popup;
- $hidden_vars['framed'] = $framed;
-
- $msg->addConfirm(array('FILE_EXISTS', $filename.'.'.$extension), $hidden_vars);
- $msg->printConfirm();
-
- require(TR_INCLUDE_PATH.'footer.inc.php');
- exit;
- }
- } else {
- $msg->addError(array('EMPTY_FIELDS', _AT('file_name')));
- }
-}
-
-$onload="on_load()";
-
-require(TR_INCLUDE_PATH.'header.inc.php');
-require_once(TR_INCLUDE_PATH.'lib/tinymce.inc.php');
-
-// set default body editor to tinymce editor
-if (!isset($_POST['extension'])) $_POST['extension'] = 'html';
-
-// load tinymce library
-load_editor(true, false, "none");
-
-$pathext = $_GET['pathext'];
-$popup = $_GET['popup'];
-
-$msg->printAll();
-
-?>
-
-
-
-
-
\ No newline at end of file
+addFeedback('CANCELLED');
+ header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+if (isset($_POST['submit_no'])) {
+ $msg->addFeedback('CANCELLED');
+ header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+if (isset($_POST['submit_yes'])) {
+ $filename = preg_replace("{[^a-zA-Z0-9_]}","_", trim($_POST['filename']));
+ $pathext = $_POST['pathext'];
+
+ /* only html or txt extensions allowed */
+ if ($_POST['extension'] == 'html') {
+ $extension = 'html';
+ } else {
+ $extension = 'txt';
+ }
+
+ if (FileUtility::course_realpath($current_path . $pathext . $filename.'.'.$extension) == FALSE) {
+ $msg->addError('FILE_NOT_SAVED');
+ /* take user to home page to avoid unspecified error warning */
+ header('Location: index.php?pathext='.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
+ exit;
+ }
+
+ if (($f = @fopen($current_path.$pathext.$filename.'.'.$extension,'w')) && @fwrite($f, stripslashes($_POST['body_text'])) !== FALSE && @fclose($f)){
+ $msg->addFeedback('FILE_OVERWRITE');
+ } else {
+ $msg->addError('CANNOT_OVERWRITE_FILE');
+ }
+ unset($_POST['newfile']);
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
+ exit;
+}
+
+if (isset($_POST['savenewfile'])) {
+
+ if (isset($_POST['filename']) && ($_POST['filename'] != "")) {
+ $filename = preg_replace("{[^a-zA-Z0-9_]}","_", trim($_POST['filename']));
+ $pathext = $_POST['pathext'];
+ $current_path = TR_CONTENT_DIR.$_course_id.'/';
+
+ /* only html or txt extensions allowed */
+ if ($_POST['extension'] == 'html') {
+ $extension = 'html';
+ $head_html = "\n\n".$_POST['filename']."\n\n";
+ $foot_html ="\n\n";
+ } else {
+ $extension = 'txt';
+ }
+
+ if (!@file_exists($current_path.$pathext.$filename.'.'.$extension)) {
+ $content = str_replace("\r\n", "\n", $head_html.$_POST['body_text'].$foot_html);
+
+ if (FileUtility::course_realpath($current_path . $pathext . $filename.'.'.$extension) == FALSE) {
+ $msg->addError('FILE_NOT_SAVED');
+ /* take user to home page to avoid unspecified error warning */
+ header('Location: index.php?pathext='.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
+ exit;
+ }
+
+ if (($f = fopen($current_path.$pathext.$filename.'.'.$extension, 'w')) && (@fwrite($f, stripslashes($content)) !== false) && (@fclose($f))) {
+ $msg->addFeedback(array('FILE_SAVED', $filename.'.'.$extension));
+ header('Location: index.php?pathext='.urlencode($_POST['pathext']).SEP.'popup='.$_POST['popup'].SEP.'_course_id='.$_course_id);
+ exit;
+ } else {
+ $msg->addError('FILE_NOT_SAVED');
+ header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'_course_id='.$_course_id);
+ exit;
+ }
+ }
+ else {
+ require(TR_INCLUDE_PATH.'header.inc.php');
+ $pathext = $_POST['pathext'];
+ $popup = $_POST['popup'];
+
+ $_POST['newfile'] = "new";
+
+ $hidden_vars['pathext'] = $pathext;
+ $hidden_vars['filename'] = $filename;
+ $hidden_vars['extension'] = $extension;
+ $hidden_vars['_course_id'] = $_course_id;
+ $hidden_vars['body_text'] = $_POST['body_text'];
+
+ $hidden_vars['popup'] = $popup;
+ $hidden_vars['framed'] = $framed;
+
+ $msg->addConfirm(array('FILE_EXISTS', $filename.'.'.$extension), $hidden_vars);
+ $msg->printConfirm();
+
+ require(TR_INCLUDE_PATH.'footer.inc.php');
+ exit;
+ }
+ } else {
+ $msg->addError(array('EMPTY_FIELDS', _AT('file_name')));
+ }
+}
+
+$onload="on_load()";
+
+require(TR_INCLUDE_PATH.'header.inc.php');
+require_once(TR_INCLUDE_PATH.'lib/tinymce.inc.php');
+
+// set default body editor to tinymce editor
+if (!isset($_POST['extension'])) $_POST['extension'] = 'html';
+
+// load tinymce library
+load_editor(true, false, "none");
+
+$pathext = $_GET['pathext'];
+$popup = $_GET['popup'];
+
+$msg->printAll();
+
+?>
+
+
+
+
+
diff --git a/file_manager/preview.php b/file_manager/preview.php
index f85986f2..1363e2ac 100644
--- a/file_manager/preview.php
+++ b/file_manager/preview.php
@@ -11,6 +11,7 @@
/************************************************************************/
define('TR_INCLUDE_PATH', '../include/');
+
require(TR_INCLUDE_PATH.'vitals.inc.php');
global $_course_id;
@@ -42,4 +43,4 @@
-
\ No newline at end of file
+
diff --git a/file_manager/preview_top.php b/file_manager/preview_top.php
index 1c586da0..f60aed3e 100644
--- a/file_manager/preview_top.php
+++ b/file_manager/preview_top.php
@@ -11,6 +11,7 @@
/************************************************************************/
define('TR_INCLUDE_PATH', '../include/');
+
require(TR_INCLUDE_PATH.'vitals.inc.php');
global $_course_id;
@@ -40,4 +41,4 @@
-
\ No newline at end of file
+