Show
Ignore:
Timestamp:
2007-06-16 18:32:46 (19 months ago)
Author:
alfonsoml
Message:

Proposed fix for #560 as part of #454 (with other little changes)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/branches/developers/alfonsoml/editor/filemanager/connectors/php/io.php

    r383 r386  
    4545 
    4646                // Map the "UserFiles" path to a local directory. 
    47                 return GetRootPath() . $Config['QuickUploadPath'][$resourceType] ; 
     47                return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ) ; 
    4848        } 
    4949        else 
     
    5353 
    5454                // Map the "UserFiles" path to a local directory. 
    55                 return GetRootPath() . $Config['FileTypesPath'][$resourceType] ; 
     55                return Server_MapPath( $Config['FileTypesPath'][$resourceType] ) ; 
    5656        } 
    5757} 
     
    7575        $sErrorMsg = CreateServerFolder( $sResourceTypePath ) ; 
    7676        if ( $sErrorMsg != '' ) 
    77         { 
    78                 if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) 
    79                 {  
    80                         SendErrorNode( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ; 
    81                         CreateXmlFooter() ; 
    82                         exit ; 
    83                 } 
    84                 else 
    85                 { 
    86                         SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ; 
    87                 } 
    88         } 
     77                SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ; 
    8978 
    9079        // Return the resource type directory combined with the required path. 
     
    149138        $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ; 
    150139 
    151         // Get the slash according to the filesystem 
    152         $slash = ( strpos( $sRealPath, '/' ) === false ) ? '\\' : '/' ; 
    153         $sSelfPath = str_replace( '/', $slash, $sSelfPath ) ; 
     140        $sSelfPath = str_replace( '/', DIRECTORY_SEPARATOR, $sSelfPath ) ; 
    154141         
    155142        $position = strpos( $sRealPath, $sSelfPath ) ; 
    156143 
    157144        // This can check only that this script isn't run from a virtual dir 
    158         // But it avoids problems the problems that arise if it isn't checked 
     145        // But it avoids the problems that arise if it isn't checked 
    159146        if ( $position === false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) ) 
    160147                SendError( 1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ) ; 
     
    163150} 
    164151 
     152// Emulate the asp Server.mapPath function. 
     153// given an url path return the physical directory that it corresponds to 
     154function Server_MapPath( $path ) 
     155{ 
     156        // This function is available only for Apache 
     157        if ( function_exists( 'apache_lookup_uri' ) ) 
     158        { 
     159                $info = apache_lookup_uri( $path ) ; 
     160                return $info->filename . $info->path_info ; 
     161        } 
     162 
     163        // This isn't correct but for the moment there's no other solution 
     164        // If this script is under a virtual directory or symlink it will detect the problem and stop 
     165        return GetRootPath() . $path ; 
     166} 
    165167 
    166168function IsAllowedExt( $sExtension, $resourceType )