Ticket #1871: 1871_3.patch

File 1871_3.patch, 3.8 KB (added by Wiktor Walc, 12 years ago)
  • editor/filemanager/connectors/php/commands.php

     
    220220
    221221                                        if ( is_file( $sFilePath ) )
    222222                                        {
     223                                                if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] )
     224                                                {
     225                                                        break ;
     226                                                }
     227                                               
     228                                                $permissions = 0777;
     229                                               
     230                                                if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] )
     231                                                {
     232                                                        $permissions = $Config['ChmodOnUpload'] ;
     233                                                }
     234                                               
    223235                                                $oldumask = umask(0) ;
    224                                                 chmod( $sFilePath, 0777 ) ;
     236                                                chmod( $sFilePath, $permissions ) ;
    225237                                                umask( $oldumask ) ;
    226238                                        }
    227239
  • editor/filemanager/connectors/php/config.php

     
    4747// following setting enabled.
    4848$Config['ForceSingleExtension'] = true ;
    4949
    50 // Perform additional checks for image files
    51 // if set to true, validate image size (using getimagesize)
     50// Perform additional checks for image files.
     51// If set to true, validate image size (using getimagesize).
    5252$Config['SecureImageUploads'] = true;
    5353
    54 // What the user can do with this connector
     54// What the user can do with this connector.
    5555$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder') ;
    5656
    57 // Allowed Resource Types
     57// Allowed Resource Types.
    5858$Config['ConfigAllowedTypes'] = array('File', 'Image', 'Flash', 'Media') ;
    5959
    6060// For security, HTML is allowed in the first Kb of data for files having the
    6161// following extensions only.
    6262$Config['HtmlExtensions'] = array("html", "htm", "xml", "xsd", "txt", "js") ;
    6363
     64// After file is uploaded, sometimes it is required to change its permissions
     65// so that it was possible to access it at the later time.
     66// If possible, it is recommended to set more restrictive permissions, like 0755.
     67// Set to 0 to disable this feature.
     68// Note: not needed on Windows-based servers.
     69$Config['ChmodOnUpload'] = 0777 ;
     70
     71// See comments above.
     72// Used when creating folders that does not exist.
     73$Config['ChmodOnFolderCreate'] = 0777 ;
     74
    6475/*
    6576        Configuration settings for each Resource Type
    6677
  • editor/filemanager/connectors/php/io.php

     
    8888
    8989function CreateServerFolder( $folderPath, $lastFolder = null )
    9090{
     91        global $Config ;
    9192        $sParent = GetParentFolder( $folderPath ) ;
    9293
    9394        // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
     
    117118                $php_errormsg = '' ;
    118119                // Enable error tracking to catch the error.
    119120                ini_set( 'track_errors', '1' ) ;
     121               
     122                if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] )
     123                {
     124                        mkdir( $folderPath ) ;
     125                }
     126                else
     127                {
     128                        $permissions = 0777 ;
     129                        if ( isset( $Config['ChmodOnFolderCreate'] ) )
     130                        {
     131                                $permissions = $Config['ChmodOnFolderCreate'] ;
     132                        }
     133                        // To create the folder with 0777 permissions, we need to set umask to zero.
     134                        $oldumask = umask(0) ;
     135                        mkdir( $folderPath, $permissions ) ;
     136                        umask( $oldumask ) ;                   
     137                }               
    120138
    121                 // To create the folder with 0777 permissions, we need to set umask to zero.
    122                 $oldumask = umask(0) ;
    123                 mkdir( $folderPath, 0777 ) ;
    124                 umask( $oldumask ) ;
    125 
    126139                $sErrorMsg = $php_errormsg ;
    127140
    128141                // Restore the configurations.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy