diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php index 991e8d79d3..4d0823a76b 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php @@ -1,45 +1,47 @@
-
+ //show icon sharedfolder + $shared_folder='shared folder'; //'shared folder' not 'shared_folder' because in $file['name'] _ is replaced with blank see class.manager.php + + ///Second step: hiding as the case + //Juan Carlos Ra�a + if((!ereg($deleted_by_chamilo_file, $file['name']) && !ereg($deleted_by_chamilo_folder, $file['path'])) && !ereg($css_folder_chamilo, $file['path']) && !ereg($hotpotatoes_folder_chamilo, $file['path']) && !ereg($chat_files_chamilo, $file['path']) && !ereg($certificates_chamilo, $file['path']) && $show_doc_group && $file['name'][0]!='.') + { + + ?> +
" class="" class=""> - + - '; - echo '' . "\n"; - break; - case 'fileFlash': - case 'fileVideo': - case 'fileMusic': - break; - default: - echo ' '; - } - if(Security::remove_XSS($_GET['editor'])!='stand_alone'){ - $path_chamilo_file='../'.$file['path'];// fix for makes a good show when pressed next on window preview, don't only one image - } - else{ - $path_chamilo_file=$file['path']; - } - ?> - - -
  class="radio" value="" /> - href="" title="" id="a">
+ '; + echo '' . "\n"; + break; + case 'fileFlash': + case 'fileVideo': + case 'fileMusic': + break; + default: + echo ' '; + } + if(Security::remove_XSS($_GET['editor'])!='stand_alone'){ + $path_chamilo_file='../'.$file['path'];// fix for makes a good show when pressed next on window preview, don't only one image + } + else{ + $path_chamilo_file=$file['path']; + } + ?> + + +
  class="radio" value="" /> + href="" title="" id="a">
getFolderInfo(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder']); //bridge to Chamilo - if(!empty($_course['path'])) - { + if(!empty($_course['path'])) { //only inside courses $mainPath='../../../../../../../courses/'.$_course['path'].'/document/';//get Chamilo $fullPath = $_POST['currentFolderPath'].$_POST['new_folder']; //get Ajaxfilemanager @@ -95,5 +94,4 @@ } echo "error:'" . $error . "'"; echo $info; - echo "}"; -?> \ No newline at end of file + echo "}"; \ No newline at end of file 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 old mode 100755 new mode 100644 index d083e3fe90..a5d030a103 --- 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 @@ -12,13 +12,13 @@ require_once '../../../../../../inc/global.inc.php'; // Integrating with Chamilo -if(!isset($manager)) { +if (!isset($manager)) { /** * this is part of script for processing file paste */ //$_GET = $_POST; - include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php"); - include_once(CLASS_PAGINATION); + include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php"; + include_once CLASS_PAGINATION; $pagination = new pagination(false); $search_folder = str_replace("'","",$_GET['search_folder']); //security fix for Chamilo by cfasanando if(!empty($_GET['search'])) { @@ -34,10 +34,8 @@ if(!isset($manager)) { $search->addSearchKeyword('name', @$_GET['search_name']); $search->doSearch(); $fileList = $search->getFoundFiles(); - $folderInfo = $search->getRootFolderInfo(); - - }else - { + $folderInfo = $search->getRootFolderInfo(); + } else { include_once(CLASS_MANAGER); include_once(CLASS_SESSION_ACTION); $sessionAction = new SessionAction(); @@ -46,101 +44,94 @@ if(!isset($manager)) { $manager = new manager(); $manager->setSessionAction($sessionAction); - $fileList = $manager->getFileList(); - $folderInfo = $manager->getFolderInfo(); - + $fileList = $manager->getFileList(); + $folderInfo = $manager->getFolderInfo(); } - $pagination->setUrl(CONFIG_URL_FILEnIMAGE_MANAGER); - -}else -{ + $pagination->setUrl(CONFIG_URL_FILEnIMAGE_MANAGER); +} else { include_once(CLASS_PAGINATION); $pagination = new pagination(false); -} +} - - $pagination->setTotal(sizeof($fileList)); - $pagination->setFirstText(PAGINATION_FIRST); - $pagination->setPreviousText(PAGINATION_PREVIOUS); - $pagination->setNextText(PAGINATION_NEXT); - $pagination->setLastText(PAGINATION_LAST); - $pagination->setLimit(!empty($_GET['limit'])?intval($_GET['limit']):CONFIG_DEFAULT_PAGINATION_LIMIT); - echo $pagination->getPaginationHTML(); - ///////Chamilo fix for count hidden folders - $count_hideItem =0; +$pagination->setTotal(sizeof($fileList)); +$pagination->setFirstText(PAGINATION_FIRST); +$pagination->setPreviousText(PAGINATION_PREVIOUS); +$pagination->setNextText(PAGINATION_NEXT); +$pagination->setLastText(PAGINATION_LAST); +$pagination->setLimit(!empty($_GET['limit'])?intval($_GET['limit']):CONFIG_DEFAULT_PAGINATION_LIMIT); +echo $pagination->getPaginationHTML(); +///////Chamilo fix for count hidden folders +$count_hideItem =0; - $deleted_by_Chamilo_file=' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php - $deleted_by_Chamilo_folder='_DELETED_'; - $css_folder_Chamilo='css'; - $hotpotatoes_folder_Chamilo='HotPotatoes_files'; - $chat_files_Chamilo='chat_files'; - $certificates_Chamilo='certificates'; +$deleted_by_Chamilo_file=' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php +$deleted_by_Chamilo_folder='_DELETED_'; +$css_folder_Chamilo='css'; +$hotpotatoes_folder_Chamilo='HotPotatoes_files'; +$chat_files_Chamilo='chat_files'; +$certificates_Chamilo='certificates'; - //end previous fix for count hidden folders +//end previous fix for count hidden folders - echo "\n"; -if(!empty($_GET['view'])) -{ - switch($_GET['view']) - { +echo "};\n"; +if(!empty($_GET['view'])) { + switch($_GET['view']) { case 'detail': case 'thumbnail': case 'text': @@ -149,12 +140,11 @@ if(!empty($_GET['view'])) default: $view = CONFIG_DEFAULT_VIEW; } -}else -{ +} else { $view = CONFIG_DEFAULT_VIEW; } -switch($view) -{ + +switch($view) { case 'text': //list file name only include_once(DIR_AJAX_ROOT . '_ajax_get_text_listing.php'); diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php index a38b980e75..1f92e60fc5 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php @@ -302,13 +302,13 @@ if(!empty($_GET['view'])) {
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 54a65cf4c1..e994fadf9d 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php @@ -64,60 +64,54 @@ class manager { * @path the path to a folder * @calculateSubdir force to get the subdirectories information */ - function __construct($path = null, $calculateSubdir=true) - { - + function __construct($path = null, $calculateSubdir=true) { $this->calculateSubdir = $calculateSubdir; - if(defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP')) - { + if(defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP')) { $this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP; } - if(!is_null($path)) - { + + if (!is_null($path)) { $this->currentFolderPath = $path; - - }elseif(isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) ) - { - $this->currentFolderPath = api_htmlentities(Security::remove_XSS($_GET[$this->folderPathIndex])); - } - elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) - { + } elseif(isset($_GET[$this->folderPathIndex]) && file_exists(base64_decode($_GET[$this->folderPathIndex])) && !is_file(base64_decode($_GET[$this->folderPathIndex]))) { + $this->currentFolderPath = api_htmlentities(Security::remove_XSS($_GET[$this->folderPathIndex])); + + } elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) { $this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex]; - }else - { + } else { $this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH; - } + } - $this->currentFolderPath = (isUnderRoot($this->currentFolderPath)?backslashToSlash((addTrailingSlash($this->currentFolderPath))):CONFIG_SYS_DEFAULT_PATH); + $this->currentFolderPath = (isUnderRoot($this->getCurrentFolderPath())?backslashToSlash((addTrailingSlash($this->getCurrentFolderPath()))):CONFIG_SYS_DEFAULT_PATH); - if($this->calculateSubdir) - {// keep track of this folder path in session + + $this->currentFolderPath = base64_encode($this->currentFolderPath); + + if($this->calculateSubdir) { + // keep track of this folder path in session $_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath; } - if(is_dir($this->currentFolderPath)) - { - - $file = new file($this->currentFolderPath); + + if (is_dir($this->getCurrentFolderPath())) { + $file = new file($this->getCurrentFolderPath()); $folderInfo = $file->getFileInfo(); - if(sizeof($folderInfo)) - { + if(sizeof($folderInfo)) { //for Chamilo in a name folder, replace num user by user names - if(preg_match('/sf_user_/',basename($this->currentFolderPath))) + if(preg_match('/sf_user_/',basename($this->getCurrentFolderPath()))) { - $userinfo=Database::get_user_info_from_id(substr(basename($this->currentFolderPath), 8)); + $userinfo=Database::get_user_info_from_id(substr(basename($this->getCurrentFolderPath()), 8)); $this->currentFolderInfo['name']=api_get_person_name($userinfo['firstname'], $userinfo['lastname']); } else { - $this->currentFolderInfo['name']=str_replace('_',' ',basename($this->currentFolderPath));//for Chamilo. Prevent long directory name + $this->currentFolderInfo['name']=str_replace('_',' ',basename($this->getCurrentFolderPath()));//for Chamilo. Prevent long directory name } - if(preg_match('/shared_folder/', basename($this->currentFolderPath))) + if(preg_match('/shared_folder/', basename($this->getCurrentFolderPath()))) { $this->currentFolderInfo['name']=get_lang('UserFolders'); } - if(preg_match('/shared_folder_session_/',basename($this->currentFolderPath))) + if(preg_match('/shared_folder_session_/',basename($this->getCurrentFolderPath()))) { - $session = explode('_', basename($this->currentFolderPath)); + $session = explode('_', basename($this->getCurrentFolderPath())); $session = strtolower($session[sizeof($session) - 1]); $this->currentFolderInfo['name']=get_lang('UserFolders').' ('.api_get_session_name($session).')*'; } @@ -129,20 +123,20 @@ class manager { $this->currentFolderInfo['mtime']=$folderInfo['mtime']; $this->currentFolderInfo['is_readable']=$folderInfo['is_readable']; $this->currentFolderInfo['is_writable']=$folderInfo['is_writable']; - $this->currentFolderInfo['path'] = $this->currentFolderPath; - $this->currentFolderInfo['path_base64'] = base64_encode($this->currentFolderPath); + $this->currentFolderInfo['path'] = $this->getCurrentFolderPath(); + $this->currentFolderInfo['path_base64'] = base64_encode($this->getCurrentFolderPath()); - $this->currentFolderInfo['friendly_path'] = transformFilePath($this->currentFolderPath); + $this->currentFolderInfo['friendly_path'] = transformFilePath($this->getCurrentFolderPath()); $this->currentFolderInfo['type'] = "folder"; $this->currentFolderInfo['cssClass']='folder'; //$this->currentFolderInfo['flag'] = $folderInfo['flag']; } } - if($calculateSubdir && !file_exists($this->currentFolderPath)) + if($calculateSubdir && !file_exists($this->getCurrentFolderPath())) { - die(ERR_FOLDER_NOT_FOUND . $this->currentFolderPath); - } + die(ERR_FOLDER_NOT_FOUND . $this->getCurrentFolderPath()); + } } function setSessionAction(&$session) @@ -160,28 +154,27 @@ class manager { * get current folder path * @return string */ - function getCurrentFolderPath() - { - return $this->currentFolderPath; + function getCurrentFolderPath() { + return base64_decode($this->currentFolderPath); } /** - * get the list of files and folders under this current fold - * @return array - */ - function getFileList() - { + * get the list of files and folders under this current fold + * @return array + */ + function getFileList() { $outputs = array(); $files = array(); $folders = array(); $tem = array(); - $dirHandler = @opendir($this->currentFolderPath); + //var_dump($this->getCurrentFolderPath()); + $dirHandler = @opendir($this->getCurrentFolderPath()); if ($dirHandler) { while(false !== ($file = readdir($dirHandler))) { if($file != '.' && $file != '..') { $flag = $this->flags['no']; - if ($this->sessionAction->getFolder() == $this->currentFolderPath) { + if ($this->sessionAction->getFolder() == $this->getCurrentFolderPath()) { //check if any flag associated with this folder or file - $folder = addTrailingSlash(backslashToSlash($this->currentFolderPath)); + $folder = addTrailingSlash(backslashToSlash($this->getCurrentFolderPath())); if(in_array($folder . $file, $this->sessionAction->get())) { if($this->sessionAction->getAction() == "copy") { $flag = $this->flags['copy']; @@ -191,7 +184,7 @@ class manager { } } - $path=$this->currentFolderPath.$file; + $path = $this->getCurrentFolderPath().$file; if (is_dir($path) && isListingDocument($path) ) { $this->currentFolderInfo['subdir']++; //fix count left folders for Chamilo @@ -245,8 +238,8 @@ class manager { } ///end fix for Chamilo $tem['path'] = backslashToSlash($path); - $pos = strpos($this->currentFolderPath, 'courses/'); - $tem['public_path'] = api_get_path(WEB_PATH).substr($this->currentFolderPath, $pos, strlen($this->currentFolderPath)).$file; + $pos = strpos($this->getCurrentFolderPath(), 'courses/'); + $tem['public_path'] = api_get_path(WEB_PATH).substr($this->getCurrentFolderPath(), $pos, strlen($this->getCurrentFolderPath())).$file; //error_log($tem['public_path'] ); $tem['type'] = "file"; $tem['flag'] = $flag; @@ -279,7 +272,7 @@ class manager { @closedir($dirHandler); } else { - trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE); + trigger_error('Unable to locate the folder ' . $this->getCurrentFolderPath(), E_NOTICE); } return $outputs; } @@ -293,11 +286,10 @@ class manager { */ function getFolderInfo($path=null) { - if(is_null($path)) - { + if(is_null($path)) { return $this->currentFolderInfo; - }else - { + } else { + $path = base64_encode($path); $obj = new manager($path, false); $obj->setSessionAction($this->sessionAction); $obj->getFileList(); diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php index 5aa555a010..5787699b20 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php @@ -1052,19 +1052,16 @@ function getRootPath() { * @param string $path * @return string */ - function getParentFolderPath($path) - { - $realPath = addTrailingSlash(backslashToSlash(getRealPath($path))); - $parentRealPath = addTrailingSlash(backslashToSlash(dirname($realPath))); - $differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath))); - $parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath)); - if(isUnderRoot($parentPath)) - { - return $parentPath; - }else - { + function getParentFolderPath($path) { + $realPath = addTrailingSlash(backslashToSlash(getRealPath($path))); + $parentRealPath = addTrailingSlash(backslashToSlash(dirname($realPath))); + $differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath))); + $parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath)); + if (isUnderRoot($parentPath)) { + return $parentPath; + } else { return CONFIG_SYS_DEFAULT_PATH; - } + } } function getCurrentFolderPath() { diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/ajaxfilemanager.js b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/ajaxfilemanager.js index dd33c4f93e..579b682f69 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/ajaxfilemanager.js +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/ajaxfilemanager.js @@ -273,14 +273,13 @@ function changeView() function goParentFolder() { searchRequired = false; - var url = appendQueryString(getUrl('view', true, true), 'path=' + parentFolder.path , ['path']); + var url = appendQueryString(getUrl('view', true, true), 'path=' + parentFolder.path_base64 , ['path']); $('#rightCol').empty(); ajaxStart('#rightCol'); - $('#rightCol').load(url, {}, function(){ - urls.present = appendQueryString(getUrl('home', true, true), 'path=' + parentFolder.path , ['path']); + urls.present = appendQueryString(getUrl('home', true, true), 'path=' + parentFolder.path_base64 , ['path']); ajaxStop('#rightCol img.ajaxLoadingImg'); initAfterListingLoaded(); }); @@ -438,15 +437,10 @@ function initAfterListingLoaded() }; -function enableFolderBrowsable(num, debug) -{ - - switch(getView()) - { +function enableFolderBrowsable(num, debug) { + switch(getView()) { case 'thumbnail': - $('#dt'+ num + ' , #dd' + num + ' a').each(function() - - { + $('#dt'+ num + ' , #dd' + num + ' a').each(function() { /* if(typeof(debug) != 'undefined' && debug) { alert(this.tagName + ' ' + files[num].path); @@ -457,53 +451,38 @@ function enableFolderBrowsable(num, debug) break; case 'detail': default: - $('#row' + num + ' td[a]').each(function() - - { + $('#row' + num + ' td[a]').each(function(){ doEnableFolderBrowsable(this, num ); } - ); - - } - - - - + ); + } }; -function doEnableFolderBrowsable(elem, num) -{ - $(elem).click(function() - { - { - searchRequired = false; - var typeNum = typeof(num); - if(typeNum.toUpperCase() == 'STRING') - { - var fpath = (num.indexOf(urls.view) >=0?num:files[num].path); - }else - { - var fpath = files[num].path; - } - - - var url = appendQueryString(getUrl('view', true, true), 'path=' + fpath, ['path']); - - - $('#rightCol').empty(); - ajaxStart('#rightCol'); - $('#rightCol').load(url, - {}, - function(){ - urls.present = appendQueryString(getUrl('home', true, true), 'path=' + fpath, ['path']); - ajaxStop('#rightCol img.ajaxLoadingImg'); - initAfterListingLoaded(); - }); - }; - return false; - - } - ); +function doEnableFolderBrowsable(elem, num) { + $(elem).click(function() { + { + searchRequired = false; + var typeNum = typeof(num); + if (typeNum.toUpperCase() == 'STRING') { + var fpath = (num.indexOf(urls.view) >=0?num:files[num].path_base64); + } else { + var fpath = files[num].path_base64; + } + + var url = appendQueryString(getUrl('view', true, true), 'path=' + fpath, ['path']); + $('#rightCol').empty(); + ajaxStart('#rightCol'); + $('#rightCol').load(url, + {}, + function(){ + urls.present = appendQueryString(getUrl('home', true, true), 'path=' + fpath, ['path']); + ajaxStop('#rightCol img.ajaxLoadingImg'); + initAfterListingLoaded(); + }); + }; + return false; + } + ); }; /** @@ -547,7 +526,7 @@ function changePaginationLimit(elem) $('#rightCol').load(url, {}, function(){ - urls.present = appendQueryString(getUrl('home', true, true), 'path=' + parentFolder.path , ['path']) + urls.present = appendQueryString(getUrl('home', true, true), 'path=' + parentFolder.path_base64 , ['path']) ajaxStop('#rightCol img.ajaxLoadingImg'); initAfterListingLoaded(); }); @@ -1180,20 +1159,13 @@ function doCreateFolder() var folder = $('div#TB_window #new_folder'); //alert($('#new_folder').val()); - if(!pattern.test($(folder).val())) - { - - + if(!pattern.test($(folder).val())) { alert(msgInvalidFolderName); - }else - { - var options = - { + } else { + var options = { dataType: 'json', url:getUrl('create_folder'), - error: function (data, status, e) - { - + error: function (data, status, e) { alert(e); }, success: function(data)