lesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ) ;
return substr( $sRealPath, 0, $position ) ;
}
// Emulate the asp Server.mapPath function.
// given an url path return the physical directory that it corresponds to
function Server_MapPath( $path )
{
// This function is available only for Apache
if ( function_exists( 'apache_lookup_uri' ) )
{
$info = apache_lookup_uri( $path ) ;
return $info->filename . $info->path_info ;
}
// This isn't correct but for the moment there's no other solution
// If this script is under a virtual directory or symlink it will detect the problem and stop
return GetRootPath() . $path ;
}
function IsAllowedExt( $sExtension, $resourceType )
{
global $Config ;
// Get the allowed and denied extensions arrays.
$arAllowed = $Config['AllowedExtensions'][$resourceType] ;
$arDenied = $Config['DeniedExtensions'][$resourceType] ;
if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) )
return false ;
if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) )
return false ;
return true ;
}
function IsAllowedType( $resourceType )
{
global $Config ;
if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) )
return false ;
return true ;
}
function IsAllowedCommand( $sCommand )
{
global $Config ;
if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) )
return false ;
return true ;
}
function GetCurrentFolder()
{
if (!isset($_GET)) {
global $_GET;
}
$sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ;
// Check the current folder syntax (must begin and start with a slash).
if ( ! ereg( '/$', $sCurrentFolder ) ) $sCurrentFolder .= '/' ;
if ( strpos( $sCurrentFolder, '/' ) !== 0 ) $sCurrentFolder = '/' . $sCurrentFolder ;
// Ensure the folder path has no double-slashes
while ( strpos ($sCurrentFolder, '//') !== false ) {
$sCurrentFolder = str_replace ('//', '/', $sCurrentFolder) ;
}
// Check for invalid folder paths (..)
if ( strpos( $sCurrentFolder, '..' ) )
SendError( 102, '' ) ;
return $sCurrentFolder ;
}
// Do a cleanup of the folder name to avoid possible problems
function SanitizeFolderName( $sNewFolderName )
{
$sNewFolderName = stripslashes( $sNewFolderName ) ;
// Remove . \ / | : ? * " < >
$sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>/', '_', $sNewFolderName ) ;
return $sNewFolderName ;
}
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( $sNewFileName )
{
global $Config ;
$sNewFileName = stripslashes( $sNewFileName ) ;
// Replace dots in the name with underscores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] )
$sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;
// Remove \ / | : ? * " < >
$sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>/', '_', $sNewFileName ) ;
return $sNewFileName ;
}
// This is the function that sends the results of the uploading process.
function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' )
{
echo '<script type="text/javascript">' ;
$rpl = array( '\\' => '\\\\', '"' => '\\"' ) ;
echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr( $fileUrl, $rpl ) . '","' . strtr( $fileName, $rpl ) . '", "' . strtr( $customMsg, $rpl ) . '") ;' ;
echo '</script>' ;
exit ;
}
?>