Hi all, I'm new here
I did an improvment to the FCKeditor file manager. I needed to give access to the folder tree of my site in the file manager, yet avoiding the user of access to some folders and files. Here are the modifications:
I did an improvment to the FCKeditor file manager. I needed to give access to the folder tree of my site in the file manager, yet avoiding the user of access to some folders and files. Here are the modifications:

Re: showing only allowed files and folders in the file manager
Re: showing only allowed files and folders in the file manager
function ValidateGotFolderOrFile ($path) { global $Config; $info = pathinfo($path); if (is_dir($path)) { foreach($Config['NotListedFolders'] as $Mask) if (preg_match ("/$Mask/", Substr($path, strlen($Config['UserFilesAbsolutePath'])+1))) return false; return true; } if (in_array($info['extension'], $Config['NotListedFilesByExtension'])) return false; foreach ($Config['NotListedFilesByMask'] as $Mask) { if (preg_match($Mask, basename($path))) return false; } if (in_array($info['extension'], $Config['ListedFilesByExtension'] + $Config['AllowedExtensions']['File'])) return true; return false; } function GetFolders( $resourceType, $currentFolder ) { // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFolders' ) ; // Array that will hold the folders names. $aFolders = array() ; $oCurrentFolder = opendir( $sServerDir ) ; while ( $sFile = readdir( $oCurrentFolder ) ) { if ( $sFile != '.' && $sFile != '..' && is_dir( $sServerDir . $sFile ) && ValidateGotFolderOrFile ( $sServerDir . $sFile ) ) $aFolders[] = '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ; } closedir( $oCurrentFolder ) ; // Open the "Folders" node. echo "<Folders>" ; natcasesort( $aFolders ) ; foreach ( $aFolders as $sFolder ) echo $sFolder ; // Close the "Folders" node. echo "</Folders>" ; } function GetFoldersAndFiles( $resourceType, $currentFolder ) { // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ) ; // Arrays that will hold the folders and files names. $aFolders = array() ; $aFiles = array() ; $oCurrentFolder = opendir( $sServerDir ) ; while ( $sFile = readdir( $oCurrentFolder ) ) { if ( $sFile != '.' && $sFile != '..' && ValidateGotFolderOrFile ("$sServerDir{$sFile}")) { if ( is_dir( $sServerDir . $sFile ) ) $aFolders[] = '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ; else { $iFileSize = @filesize( $sServerDir . $sFile ) ; if ( !$iFileSize ) { $iFileSize = 0 ; } if ( $iFileSize > 0 ) { $iFileSize = round( $iFileSize / 1024 ) ; if ( $iFileSize < 1 ) $iFileSize = 1 ; } $aFiles[] = '<File name="' . ConvertToXmlAttribute( $sFile ) . '" size="' . $iFileSize . '" />' ; } } } // Send the folders natcasesort( $aFolders ) ; echo '<Folders>' ; foreach ( $aFolders as $sFolder ) echo $sFolder ; echo '</Folders>' ; // Send the files natcasesort( $aFiles ) ; echo '<Files>' ; foreach ( $aFiles as $sFiles ) echo $sFiles ; echo '</Files>' ; }File: config.php :
// Besides the extensions in $Config['AllowedExtensions']['File'], show the files with the // next extensions: $Config['ListedFilesByExtension'] = array('php', 'php3', 'phtml'); // Excepto for the ones with these extensions (for blocking some of the included in // the $Config['AllowedExtensions']['File'] array) $Config['NotListedFilesByExtension'] = array ('css', 'htc', 'js', 'htaccess', 'flv', 'swf', 'fla'); // And except for the files whose names would match the following preg_match patterns: $Config['NotListedFilesByMask'] = array('/tests?\.php/'); // Hidden folders (preg_match'ing them): $Config['NotListedFolders'] = array( '^admin$', '^core$','^rest$');I hope it is useful for sumeone.
Best regards.
Re: showing only allowed files and folders in the file manager