Using base64 path instead of simple path when dealing with server with apache reestrictions see #2980

skala
Julio Montoya 14 years ago
parent 4669434352
commit 86e537ca12
  1. 126
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php
  2. 6
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php
  3. 164
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php
  4. 8
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php
  5. 106
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php
  6. 21
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php
  7. 104
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/ajaxfilemanager.js

@ -1,45 +1,47 @@
<div id="content">
<?php
$count = 1;
$thumbnailBaseUrl = appendQueryString(CONFIG_URL_IMG_THUMBNAIL, makeQueryString(array('path')));
foreach($fileList as $file) {
///First step for hidden some type of Chamilo files and folders
//Juan Carlos Ra<EFBFBD>a
$count = 1;
//hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat, certificates
$thumbnailBaseUrl = appendQueryString(CONFIG_URL_IMG_THUMBNAIL, 'path='.base64_decode($_REQUEST['path']));
$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';
//hidden directory of the group if the user is not a member of the group
$group_folder='_groupdocs';
foreach($fileList as $file) {
///First step for hidden some type of Chamilo files and folders
//Juan Carlos Ra<EFBFBD>a
//hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat, certificates
//show group's directory only if I'm member. Or I'm a teacher
$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';
//hidden directory of the group if the user is not a member of the group
$group_folder='_groupdocs';
//show group's directory only if I'm member. Or I'm a teacher
$show_doc_group=true;
if(ereg($group_folder, $file['path']))
{
$show_doc_group=false;
if($is_user_in_group ||( $to_group_id!=0 && api_is_allowed_to_edit()))
{
$show_doc_group=true;
if(ereg($group_folder, $file['path']))
{
$show_doc_group=false;
if($is_user_in_group ||( $to_group_id!=0 && api_is_allowed_to_edit()))
{
$show_doc_group=true;
}
}
}
}
//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<EFBFBD>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]!='.')
{
?>
<dl class="thumbnailListing" id="dl<?php echo $count; ?>">
//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<EFBFBD>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]!='.')
{
?>
<dl class="thumbnailListing" id="dl<?php echo $count; ?>">
<?php
if(preg_match('/shared_folder/', basename($file['path'])))
{ //add icon into ajaxfilemanager if sharedfolder is in Chamilo
@ -60,35 +62,35 @@
<dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' && empty($file['file']) && empty($file['subdir'])?'folderEmpty':$file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>">
<?php
}
?>
<?php
}
?>
<?php
switch($file['cssClass'])
{
case 'filePicture':
echo '<a id="thumbUrl' . $count . '" rel="thumbPhotos" href="' . $file['public_path'] . '">';
echo '<img src="' . appendQueryString($thumbnailBaseUrl, 'path=' . base64_encode($file['path'])) . '" id="thumbImg' . $count . '"></a>' . "\n";
break;
case 'fileFlash':
case 'fileVideo':
case 'fileMusic':
break;
default:
echo '&nbsp;';
}
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'];
}
?>
</dt>
<dd id="dd<?php echo $count; ?>" class="thumbnailListing_info"><span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span><input id="cb<?php echo $count; ?>" type="checkbox" name="check[]" <?php echo ($file['is_writable']?'':'disabled'); ?> class="radio" value="<?php echo $file['path']; ?>" />
<a <?php echo ($file['cssClass']== 'filePicture'?'rel="orgImg"':''); ?> href="<?php echo $path_chamilo_file;// fix for Chamilo ?>" title="<?php echo $file['name']; ?>" id="a<?php echo $count; ?>"><?php echo shortenFileName($file['name']); ?></a></dd>
<?php
switch($file['cssClass'])
{
case 'filePicture':
echo '<a id="thumbUrl' . $count . '" rel="thumbPhotos" href="' . $file['public_path'] . '">';
echo '<img src="' . appendQueryString($thumbnailBaseUrl, 'path=' . base64_encode($file['path'])) . '" id="thumbImg' . $count . '"></a>' . "\n";
break;
case 'fileFlash':
case 'fileVideo':
case 'fileMusic':
break;
default:
echo '&nbsp;';
}
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'];
}
?>
</dt>
<dd id="dd<?php echo $count; ?>" class="thumbnailListing_info"><span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span><input id="cb<?php echo $count; ?>" type="checkbox" name="check[]" <?php echo ($file['is_writable']?'':'disabled'); ?> class="radio" value="<?php echo $file['path']; ?>" />
<a <?php echo ($file['cssClass']== 'filePicture'?'rel="orgImg"':''); ?> href="<?php echo $path_chamilo_file;// fix for Chamilo ?>" title="<?php echo $file['name']; ?>" id="a<?php echo $count; ?>"><?php echo shortenFileName($file['name']); ?></a></dd>
</dl>
<?php
}//end if hidden files and folders deleted by Chamilo

@ -51,8 +51,7 @@
$pathInfo = $manager->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 "}";
?>
echo "}";

@ -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 "<script type=\"text/javascript\">\n";
echo "<script type=\"text/javascript\">";
echo "parentFolder = {path:'" . getParentFolderPath($folderInfo['path']). "'};\n";
echo 'currentFolder ={';
$count =1;
foreach($folderInfo as $k=>$v)
{
echo ($count++ == 1?'':',') . "'" . $k . "':'" . ($k=='ctime'|| $k=='mtime'?date(DATE_TIME_FORMAT, $v):$v) . "'";
echo "parentFolder = {path_base64:'" . base64_encode(getParentFolderPath($folderInfo['path'])). "', path:'" . getParentFolderPath($folderInfo['path']). "'};";
echo 'currentFolder ={';
$count =1;
foreach($folderInfo as $k=>$v) {
echo ($count++ == 1?'':',') . "'" . $k . "':'" . ($k=='ctime'|| $k=='mtime'?date(DATE_TIME_FORMAT, $v):$v) . "'";
}
echo "};";
}
echo "};\n";
// moved below for Chamilo integration $fileList = array_slice($fileList, $pagination->getPageOffset(), $pagination->getLimit());
echo 'numRows = ' . sizeof($fileList) . ";\n";
echo "files = {\n";
$count = 1;
foreach($fileList as $file)
// moved below for Chamilo integration $fileList = array_slice($fileList, $pagination->getPageOffset(), $pagination->getLimit());
echo 'numRows = ' . sizeof($fileList) . ";\n";
echo "files = {\n";
$count = 1;
foreach($fileList as $file)
{
//show group's directory only if I'm member. Or if I'm a teacher. TODO: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder). Teachers can access to all groups ?
$group_folder='_groupdocs';
$hide_doc_group=false;
if(ereg($group_folder, $file['path']))
{
//show group's directory only if I'm member. Or if I'm a teacher. TODO: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder). Teachers can access to all groups ?
$group_folder='_groupdocs';
$hide_doc_group=false;
if(ereg($group_folder, $file['path']))
$hide_doc_group=true;
if($is_user_in_group ||( $to_group_id!=0 && api_is_allowed_to_edit()))
{
$hide_doc_group=true;
if($is_user_in_group ||( $to_group_id!=0 && api_is_allowed_to_edit()))
{
$hide_doc_group=false;
}
$hide_doc_group=false;
}
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']) || $hide_doc_group || $file['name'][0]=='.')//Chamilo fix for hidden items.
{
}
$count_hideItem=$count_hideItem+1;
}
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']) || $hide_doc_group || $file['name'][0]=='.')//Chamilo fix for hidden items.
{
$count_hideItem=$count_hideItem+1;
}
echo (($count > 1)?",":'').$count++ . ":{";
$j = 1;
foreach($file as $k=>$v)
echo (($count > 1)?",":'').$count++ . ":{";
$j = 1;
foreach($file as $k=>$v)
{
if($k == 'ctime' || $k == 'mtime')
{
$v = @date(DATE_TIME_FORMAT, $v);
}
if($k == 'size')
{
if($k == 'ctime' || $k == 'mtime')
{
$v = @date(DATE_TIME_FORMAT, $v);
}
if($k == 'size')
{
$v = transformFileSize($v);
}
echo (($j++ > 1)?",":'') . "'" . $k . "':'" . $v . "'";
$v = transformFileSize($v);
}
echo (($j++ > 1)?",":'') . "'url':'" . getFileUrl($file['path']) . "'";
echo "}\n";
echo (($j++ > 1)?",":'') . "'" . $k . "':'" . $v . "'";
}
$fileList = array_slice($fileList, $pagination->getPageOffset(), $pagination->getLimit());//Chamilo fix for hidden files added +$count_hideItem
echo (($j++ > 1)?",":'') . "'url':'" . getFileUrl($file['path']) . "'";
echo "}\n";
}
$fileList = array_slice($fileList, $pagination->getPageOffset(), $pagination->getLimit());//Chamilo fix for hidden files added +$count_hideItem
echo "};</script>\n";
if(!empty($_GET['view']))
{
switch($_GET['view'])
{
echo "};</script>\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');

@ -302,13 +302,13 @@ if(!empty($_GET['view'])) {
<div id="body">
<div id="rightCol">
<?php
if(CONFIG_LOAD_DOC_LATTER )
{
if(CONFIG_LOAD_DOC_LATTER ) {
$currentPath = getCurrentFolderPath();
?>
<script type="text/javascript">
parentFolder = {'path':'<?php echo getParentFolderPath($currentPath); ?>'};
parentFolder = {'path_base64':'<?php echo base64_encode(getParentFolderPath($currentPath)); ?>', 'path':'<?php echo getParentFolderPath($currentPath); ?>'};
currentFolder = {'friendly_path':'<?php echo transformFilePath($currentPath); ?>'};
$(document).ready(
function()
@ -329,7 +329,7 @@ if(!empty($_GET['view'])) {
</script>
<?php
} else {
include_once(CONFIG_URL_LIST_LISTING);
include_once CONFIG_URL_LIST_LISTING;
}
?>
</div>

@ -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();

@ -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() {

@ -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)

Loading…
Cancel
Save