diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php index d603b93913..5bfc1ab3d6 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php @@ -28,80 +28,78 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_NEWFOLDER) { $error = ERR_FOLDER_NAME_EMPTY; } elseif (!preg_match("/^[a-zA-Z0-9_\- ]+$/", $_POST['new_folder'])) { $error = ERR_FOLDER_FORMAT; +} elseif (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) { + $error = ERR_FOLDER_PATH_NOT_ALLOWED; +} elseif (file_exists(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'])) { + $error = ERR_FOLDER_EXISTS; } else { - if (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) { - $error = ERR_FOLDER_PATH_NOT_ALLOWED; - } elseif (file_exists(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'])) { - $error = ERR_FOLDER_EXISTS; - } else { - include_once CLASS_FILE; - $file = new file(); - if ($file->mkdir(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'], 0775)) { - include_once CLASS_MANAGER; - $manager = new manager(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'], false); - $pathInfo = $manager->getFolderInfo(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder']); - - //bridge to Chamilo - if (!empty($_course['path'])) { - //only inside courses - $mainPath = '../../../../../../../courses/'.$_course['path'].'/document/'; //get Chamilo - $fullPath = $_POST['currentFolderPath'].$_POST['new_folder']; //get Ajaxfilemanager - $chamiloPath = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1); - $_POST['new_folder'] = str_replace( - '_', - ' ', - $_POST['new_folder'] - ); //Restore for interaction with Chamilo. Because fix long names. See: ajaxfilemanager/inc/class.manager.php - $chamiloFile = $_POST['new_folder']; //get Ajaxfilemanager + include_once CLASS_FILE; + $file = new file(); + if ($file->mkdir(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], 0775)) { + event_system(LOG_MY_FOLDER_CREATE, LOG_MY_FOLDER_PATH, $_POST['currentFolderPath'] . $_POST['new_folder']); + include_once CLASS_MANAGER; + $manager = new manager(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], false); + $pathInfo = $manager->getFolderInfo(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder']); + //bridge to Chamilo + if (!empty($_course['path'])) { + //only inside courses + $mainPath = '../../../../../../../courses/'.$_course['path'].'/document/'; //get Chamilo + $fullPath = $_POST['currentFolderPath'].$_POST['new_folder']; //get Ajaxfilemanager + $chamiloPath = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1); + $_POST['new_folder'] = str_replace( + '_', + ' ', + $_POST['new_folder'] + ); //Restore for interaction with Chamilo. Because fix long names. See: ajaxfilemanager/inc/class.manager.php + $chamiloFile = $_POST['new_folder']; //get Ajaxfilemanager - $doc_id = add_document($_course, $chamiloPath, 'folder', 0, $chamiloFile); //get Chamilo - $current_session_id = api_get_session_id(); //get Chamilo - api_item_property_update( - $_course, - TOOL_DOCUMENT, - $doc_id, - 'FolderCreated', - api_get_user_id(), - $to_group_id, - null, - null, - null, - $current_session_id - ); //get Chamilo - api_item_property_update( - $_course, - TOOL_DOCUMENT, - $doc_id, - 'invisible', - api_get_user_id(), - $to_group_id, - null, - null, - null, - $current_session_id - ); //get Chamilo - } - // end bridge to Chamilo + $doc_id = add_document($_course, $chamiloPath, 'folder', 0, $chamiloFile); //get Chamilo + $current_session_id = api_get_session_id(); //get Chamilo + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $doc_id, + 'FolderCreated', + api_get_user_id(), + $to_group_id, + null, + null, + null, + $current_session_id + ); //get Chamilo + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $doc_id, + 'invisible', + api_get_user_id(), + $to_group_id, + null, + null, + null, + $current_session_id + ); //get Chamilo + } + // end bridge to Chamilo - foreach ($pathInfo as $k => $v) { - switch ($k) { - case "ctime"; - case "mtime": - case "atime": - $v = date(DATE_TIME_FORMAT, $v); - break; - case 'name': - $info .= sprintf(", %s:'%s'", 'short_name', shortenFileName($v)); - break; - case 'cssClass': - $v = 'folderEmpty'; - break; - } - $info .= sprintf(", %s:'%s'", $k, $v); + foreach ($pathInfo as $k => $v) { + switch ($k) { + case "ctime"; + case "mtime": + case "atime": + $v = date(DATE_TIME_FORMAT, $v); + break; + case 'name': + $info .= sprintf(", %s:'%s'", 'short_name', shortenFileName($v)); + break; + case 'cssClass': + $v = 'folderEmpty'; + break; } - } else { - $error = ERR_FOLDER_CREATION_FAILED; + $info .= sprintf(", %s:'%s'", $k, $v); } + } else { + $error = ERR_FOLDER_CREATION_FAILED; } } echo "error:'".$error."'"; diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_delete_file.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_delete_file.php index 86c7de5acc..cb8fddfac1 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_delete_file.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_delete_file.php @@ -63,6 +63,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) { 'document_path', addTrailingSlash(backslashToSlash($_GET['delete'])) ); + event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $_GET['delete']); } //////end bridge to Chamilo $file->delete(addTrailingSlash(backslashToSlash($_GET['delete']))); @@ -101,6 +102,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) { } else { $file->delete($_GET['delete']); //deleted by ajaxfilemanager event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', $_GET['delete']); + event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $_GET['delete']); } //////end bridge to Chamilo } @@ -158,6 +160,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) { 'document_path', addTrailingSlash(backslashToSlash($doc)) ); + event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $doc); } //////end bridge to Chamilo } elseif (is_file($doc) @@ -196,6 +199,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) { } else { $file->delete($doc); //deleted by ajaxfilemanager event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', $doc); + event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $doc); } //////end bridge to Chamilo } diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_copy.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_copy.php index 97d7484e31..27177df27b 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_copy.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_copy.php @@ -24,5 +24,8 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_COPY) { $sessionAction->setFolder($_POST['currentFolderPath']); $sessionAction->set($_POST['selectedDoc']); $info = ',num:'.sizeof($_POST['selectedDoc']); + foreach ($_POST['selectedDoc'] as $doc) { + event_system(LOG_MY_FOLDER_COPY, LOG_MY_FOLDER_PATH, $doc); + } } -echo "{error:'".$error."'\n".$info."}"; +echo "{error:'".$error."'\n".$info."}"; \ No newline at end of file diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_cut.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_cut.php index 9b3bcf56b1..3d22d94bd8 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_cut.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_cut.php @@ -26,5 +26,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_CUT) { $sessionAction->setFolder($_POST['currentFolderPath']); $sessionAction->set($_POST['selectedDoc']); $info = ',num:'.sizeof($_POST['selectedDoc']); + foreach ($_POST['selectedDoc'] as $doc) { + event_system(LOG_MY_FOLDER_COPY, LOG_MY_FOLDER_PATH, $doc); + } } -echo "{error:'".$error."'\n".$info."}"; diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_paste.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_paste.php index 9a4333563c..252e74338d 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_paste.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_paste.php @@ -12,6 +12,7 @@ require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanage $error = ''; $fileMoved = array(); $unmovedDocDueToSamePath = array(); +$finalPath = ''; if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) { $error = SYS_DISABLED; } elseif (empty($_GET['current_folder_path'])) { @@ -61,6 +62,7 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) { $obj = new manager($finalPath, false); $fileType = $obj->getFileType($finalPath, (is_dir($finalPath) ? true : false)); + event_system(LOG_MY_FOLDER_PASTE, LOG_MY_FOLDER_PATH, $finalPath); foreach ($fileType as $k => $v) { $tem[$k] = $v; diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php index 136396f3ab..357471b19d 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php @@ -14,7 +14,8 @@ require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanage sleep(3); echo "{"; $error = ""; -$info = ""; +$info = ""; +$fullPath = ''; include_once CLASS_UPLOAD; $upload = new Upload(); @@ -115,12 +116,13 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD) { } $info .= sprintf(", url:'%s'", getFileUrl($path)); $info .= sprintf(", tipedit:'%s'", TIP_DOC_RENAME); + // Log to TRACK_E_DEFAULT + event_system(LOG_MY_FOLDER_UPLOAD, LOG_MY_FOLDER_PATH, $fullPath); } else { $error = ERR_FILE_NOT_AVAILABLE; } } } - echo "error:'".$error."'"; echo $info; echo "}"; diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php index 482b361b13..27239e37e7 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php @@ -10,6 +10,7 @@ require_once '../../../../../../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php'; +$path = isset($_REQUEST['path'])? Security::remove_XSS($_REQUEST['path']) : null ; if (!isset($manager)) { /** * this is part of script for processing file paste @@ -41,7 +42,7 @@ if (!isset($manager)) { $sessionAction = new SessionAction(); include_once(DIR_AJAX_INC."class.manager.php"); - $manager = new manager(); + $manager = new manager($path); $manager->setSessionAction($sessionAction); $fileList = $manager->getFileList(); diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_name.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_name.php index a189054c10..09f04af9e1 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_name.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_name.php @@ -70,6 +70,8 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_RENAME) { $fileInfo = $manager->getFolderInfo(); $fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']); } + event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_PATH, $_POST['original_path']); + event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_NEW_PATH, $path); } echo "{"; diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php index d2437cd1f6..8c902bf51a 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php @@ -82,7 +82,7 @@ class manager $this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH; } - $this->currentFolderPath = (isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash((addTrailingSlash($this->getCurrentFolderPath()))) : CONFIG_SYS_DEFAULT_PATH); + $this->currentFolderPath = (isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash((addTrailingSlash($this->getCurrentFolderPath()))) : $this->currentFolderPath); $this->currentFolderPath = base64_encode($this->currentFolderPath); if ($this->calculateSubdir) { diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index b5e1a78657..6a873d99fe 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -196,7 +196,15 @@ define('LOG_EXERCISE_RESULT_DELETE', 'exe_result_deleted'); define('LOG_LP_ATTEMPT_DELETE', 'lp_attempt_deleted'); define('LOG_QUESTION_RESULT_DELETE', 'qst_attempt_deleted'); -// event logs data types (max 20 chars) +define('LOG_MY_FOLDER_CREATE', 'my_folder_created'); +define('LOG_MY_FOLDER_CHANGE', 'my_folder_changed'); +define('LOG_MY_FOLDER_DELETE', 'my_folder_deleted'); +define('LOG_MY_FOLDER_COPY', 'my_folder_copied'); +define('LOG_MY_FOLDER_CUT', 'my_folder_cut'); +define('LOG_MY_FOLDER_PASTE', 'my_folder_pasted'); +define('LOG_MY_FOLDER_UPLOAD', 'my_folder_uploaded'); + +// Event logs data types define('LOG_COURSE_CODE', 'course_code'); define('LOG_COURSE_ID', 'course_id'); define('LOG_USER_ID', 'user_id'); @@ -218,6 +226,9 @@ define('LOG_EXERCISE_AND_USER_ID', 'exercise_and_user_id'); define('LOG_LP_ID', 'lp_id'); define('LOG_EXERCISE_ATTEMPT_QUESTION_ID', 'exercise_a_q_id'); +define('LOG_MY_FOLDER_PATH', 'path'); +define('LOG_MY_FOLDER_NEW_PATH', 'new_path'); + define('USERNAME_PURIFIER', '/[^0-9A-Za-z_\.]/'); //used when login_is_email setting is true