[763] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * FCKeditor - The text editor for internet |
---|
| 4 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben |
---|
| 5 | * |
---|
| 6 | * Licensed under the terms of the GNU Lesser General Public License: |
---|
| 7 | * http://www.opensource.org/licenses/lgpl-license.php |
---|
| 8 | * |
---|
| 9 | * For further information visit: |
---|
| 10 | * http://www.fckeditor.net/ |
---|
| 11 | * |
---|
| 12 | * "Support Open Source software. What about a donation today?" |
---|
| 13 | * |
---|
| 14 | * File Name: connector.php |
---|
| 15 | * This is the File Manager Connector for PHP. |
---|
| 16 | * |
---|
| 17 | * File Authors: |
---|
| 18 | * Frederico Caldeira Knabben (fredck@fckeditor.net) |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | ob_start() ; |
---|
| 22 | |
---|
| 23 | include('config.php') ; |
---|
| 24 | include('util.php') ; |
---|
| 25 | include('io.php') ; |
---|
| 26 | include('basexml.php') ; |
---|
| 27 | include('commands.php') ; |
---|
| 28 | |
---|
| 29 | if ( !$Config['Enabled'] ) |
---|
| 30 | SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/browser/default/connectors/php/config.php" file' ) ; |
---|
| 31 | |
---|
| 32 | // Get the "UserFiles" path. |
---|
| 33 | $GLOBALS["UserFilesPath"] = '' ; |
---|
| 34 | |
---|
| 35 | if ( isset( $Config['UserFilesPath'] ) ) |
---|
| 36 | $GLOBALS["UserFilesPath"] = $Config['UserFilesPath'] ; |
---|
| 37 | else if ( isset( $_GET['ServerPath'] ) ) |
---|
| 38 | $GLOBALS["UserFilesPath"] = $_GET['ServerPath'] ; |
---|
| 39 | else |
---|
| 40 | $GLOBALS["UserFilesPath"] = '/UserFiles/' ; |
---|
| 41 | |
---|
| 42 | if ( ! ereg( '/$', $GLOBALS["UserFilesPath"] ) ) |
---|
| 43 | $GLOBALS["UserFilesPath"] .= '/' ; |
---|
| 44 | |
---|
| 45 | if ( strlen( $Config['UserFilesAbsolutePath'] ) > 0 ) |
---|
| 46 | { |
---|
| 47 | $GLOBALS["UserFilesDirectory"] = $Config['UserFilesAbsolutePath'] ; |
---|
| 48 | |
---|
| 49 | if ( ! ereg( '/$', $GLOBALS["UserFilesDirectory"] ) ) |
---|
| 50 | $GLOBALS["UserFilesDirectory"] .= '/' ; |
---|
| 51 | } |
---|
| 52 | else |
---|
| 53 | { |
---|
| 54 | // Map the "UserFiles" path to a local directory. |
---|
| 55 | $GLOBALS["UserFilesDirectory"] = GetRootPath() . $GLOBALS["UserFilesPath"] ; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | DoResponse() ; |
---|
| 59 | |
---|
| 60 | function DoResponse() |
---|
| 61 | { |
---|
| 62 | if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) ) |
---|
| 63 | return ; |
---|
| 64 | |
---|
| 65 | // Get the main request informaiton. |
---|
| 66 | $sCommand = $_GET['Command'] ; |
---|
| 67 | $sResourceType = $_GET['Type'] ; |
---|
| 68 | $sCurrentFolder = $_GET['CurrentFolder'] ; |
---|
| 69 | |
---|
| 70 | // Check if it is an allowed type. |
---|
| 71 | if ( !in_array( $sResourceType, array('File','Image','Flash','Media') ) ) |
---|
| 72 | return ; |
---|
| 73 | |
---|
| 74 | // Check the current folder syntax (must begin and start with a slash). |
---|
| 75 | if ( ! ereg( '/$', $sCurrentFolder ) ) $sCurrentFolder .= '/' ; |
---|
| 76 | if ( strpos( $sCurrentFolder, '/' ) !== 0 ) $sCurrentFolder = '/' . $sCurrentFolder ; |
---|
| 77 | |
---|
| 78 | // Check for invalid folder paths (..) |
---|
| 79 | if ( strpos( $sCurrentFolder, '..' ) ) |
---|
| 80 | SendError( 102, "" ) ; |
---|
| 81 | |
---|
| 82 | // File Upload doesn't have to Return XML, so it must be intercepted before anything. |
---|
| 83 | if ( $sCommand == 'FileUpload' ) |
---|
| 84 | { |
---|
| 85 | FileUpload( $sResourceType, $sCurrentFolder ) ; |
---|
| 86 | return ; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ; |
---|
| 90 | |
---|
| 91 | // Execute the required command. |
---|
| 92 | switch ( $sCommand ) |
---|
| 93 | { |
---|
| 94 | case 'GetFolders' : |
---|
| 95 | GetFolders( $sResourceType, $sCurrentFolder ) ; |
---|
| 96 | break ; |
---|
| 97 | case 'GetFoldersAndFiles' : |
---|
| 98 | GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ; |
---|
| 99 | break ; |
---|
| 100 | case 'CreateFolder' : |
---|
| 101 | CreateFolder( $sResourceType, $sCurrentFolder ) ; |
---|
| 102 | break ; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | CreateXmlFooter() ; |
---|
| 106 | |
---|
| 107 | exit ; |
---|
| 108 | } |
---|
| 109 | ?> |
---|