Source for file commands.php
Documentation is available at commands.php
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2006 Frederico Caldeira Knabben
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
* For further information visit:
* http://www.fckeditor.net/
* "Support Open Source software. What about a donation today?"
* File Name: commands.php
* This is the File Manager Connector for PHP.
* Frederico Caldeira Knabben (fredck@fckeditor.net)
function GetFolders( $resourceType, $currentFolder )
// Map the virtual path to the local server path.
// Array that will hold the folders names.
$oCurrentFolder =
opendir( $sServerDir ) ;
while ( $sFile =
readdir( $oCurrentFolder ) )
if ( $sFile !=
'.' &&
$sFile !=
'..' &&
is_dir( $sServerDir .
$sFile ) )
// Open the "Folders" node.
foreach ( $aFolders as $sFolder )
// Close the "Folders" node.
// Map the virtual path to the local server path.
// Arrays that will hold the folders and files names.
$oCurrentFolder =
opendir( $sServerDir ) ;
while ( $sFile =
readdir( $oCurrentFolder ) )
if ( $sFile !=
'.' &&
$sFile !=
'..' )
if ( is_dir( $sServerDir .
$sFile ) )
$iFileSize =
filesize( $sServerDir .
$sFile ) ;
$iFileSize =
round( $iFileSize /
1024 ) ;
if ( $iFileSize <
1 ) $iFileSize =
1 ;
foreach ( $aFolders as $sFolder )
foreach ( $aFiles as $sFiles )
if ( isset
( $_GET['NewFolderName'] ) )
$sNewFolderName =
$_GET['NewFolderName'] ;
if ( strpos( $sNewFolderName, '..' ) !==
FALSE )
$sErrorNumber =
'102' ; // Invalid folder name.
// Map the virtual path to the local server path of the current folder.
$sServerDir .=
$sNewFolderName ;
case 'Invalid argument' :
case 'No such file or directory' :
$sErrorNumber =
'102' ; // Path too long.
// Create the "Error" node.
echo
'<Error number="' .
$sErrorNumber .
'" originalDescription="' .
ConvertToXmlAttribute( $sErrorMsg ) .
'" />' ;
function FileUpload( $resourceType, $currentFolder )
if ( isset
( $_FILES['NewFile'] ) &&
!is_null( $_FILES['NewFile']['tmp_name'] ) )
$oFile =
$_FILES['NewFile'] ;
// Map the virtual path to the local server path.
// Get the uploaded file name.
$sFileName =
$oFile['name'] ;
// Replace dots in the name with underscores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] )
$sFileName =
preg_replace( '/\\.(?![^.]*$)/', '_', $sFileName ) ;
$sOriginalFileName =
$sFileName ;
$sExtension =
substr( $sFileName, ( strrpos($sFileName, '.') +
1 ) ) ;
$arAllowed =
$Config['AllowedExtensions'][$resourceType] ;
$arDenied =
$Config['DeniedExtensions'][$resourceType] ;
if ( ( count($arAllowed) ==
0 ||
in_array( $sExtension, $arAllowed ) ) &&
( count($arDenied) ==
0 ||
!in_array( $sExtension, $arDenied ) ) )
$sFilePath =
$sServerDir .
$sFileName ;
$sFileName =
RemoveExtension( $sOriginalFileName ) .
'(' .
$iCounter .
').' .
$sExtension ;
chmod( $sFilePath, 0777 ) ;
echo
'<script type="text/javascript">' ;
echo
'window.parent.frames["frmUpload"].OnUploadCompleted(' .
$sErrorNumber .
',"' .
str_replace( '"', '\\"', $sFileName ) .
'") ;' ;
Documentation generated on Sun, 09 Mar 2008 23:50:54 -0300 by phpDocumentor 1.4.0