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 | if(!function_exists('stristr_reverse')){
|
---|
33 | function stristr_reverse($haystack, $needle) {
|
---|
34 | $pos = strpos($haystack, $needle);
|
---|
35 | return substr($haystack, 0, $pos);
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | // Get the "UserFiles" path.
|
---|
40 | $GLOBALS["UserFilesPath"] = '' ;
|
---|
41 |
|
---|
42 | if ( isset( $Config['UserFilesPath'] ) )
|
---|
43 | $GLOBALS["UserFilesPath"] = $Config['UserFilesPath'] ;
|
---|
44 | else if ( isset( $_GET['ServerPath'] ) )
|
---|
45 | $GLOBALS["UserFilesPath"] = $_GET['ServerPath'] ;
|
---|
46 | else
|
---|
47 | {
|
---|
48 |
|
---|
49 | $strBP = dirname($_SERVER['PHP_SELF']);
|
---|
50 | $strBP = stristr_reverse($strBP, 'inc/FCKeditor/editor/filemanager/browser/default/connectors/php');
|
---|
51 | if ($strBP{strlen($strBP)-1} != "/") $strBP .= "/";
|
---|
52 | $strBP .= 'inc/FCKeditor/upload/';
|
---|
53 | $GLOBALS["UserFilesPath"] = $strBP ;
|
---|
54 | }
|
---|
55 | if ( ! preg_match( '/\/$/', $GLOBALS["UserFilesPath"] ) )
|
---|
56 | $GLOBALS["UserFilesPath"] .= '/' ;
|
---|
57 |
|
---|
58 | if ( strlen( $Config['UserFilesAbsolutePath'] ) > 0 )
|
---|
59 | {
|
---|
60 | $GLOBALS["UserFilesDirectory"] = $Config['UserFilesAbsolutePath'] ;
|
---|
61 |
|
---|
62 | if ( ! preg_match( '/\/$/', $GLOBALS["UserFilesDirectory"] ) )
|
---|
63 | $GLOBALS["UserFilesDirectory"] .= '/' ;
|
---|
64 | }
|
---|
65 | else
|
---|
66 | {
|
---|
67 | // Map the "UserFiles" path to a local directory.
|
---|
68 | $GLOBALS["UserFilesDirectory"] = GetRootPath() . $GLOBALS["UserFilesPath"] ;
|
---|
69 | }
|
---|
70 |
|
---|
71 | DoResponse() ;
|
---|
72 |
|
---|
73 | function DoResponse()
|
---|
74 | {
|
---|
75 | if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
|
---|
76 | return ;
|
---|
77 |
|
---|
78 | // Get the main request informaiton.
|
---|
79 | $sCommand = $_GET['Command'] ;
|
---|
80 | $sResourceType = $_GET['Type'] ;
|
---|
81 | $sCurrentFolder = $_GET['CurrentFolder'] ;
|
---|
82 |
|
---|
83 | // Check if it is an allowed type.
|
---|
84 | if ( !in_array( $sResourceType, array('File','Image','Flash','Media') ) )
|
---|
85 | return ;
|
---|
86 |
|
---|
87 | // Check the current folder syntax (must begin and start with a slash).
|
---|
88 | if ( ! preg_match( '/\/$/', $sCurrentFolder ) ) $sCurrentFolder .= '/' ;
|
---|
89 | if ( strpos( $sCurrentFolder, '/' ) !== 0 ) $sCurrentFolder = '/' . $sCurrentFolder ;
|
---|
90 |
|
---|
91 | // Check for invalid folder paths (..)
|
---|
92 | if ( strpos( $sCurrentFolder, '..' ) )
|
---|
93 | SendError( 102, "" ) ;
|
---|
94 |
|
---|
95 | // File Upload doesn't have to Return XML, so it must be intercepted before anything.
|
---|
96 | if ( $sCommand == 'FileUpload' )
|
---|
97 | {
|
---|
98 | FileUpload( $sResourceType, $sCurrentFolder ) ;
|
---|
99 | return ;
|
---|
100 | }
|
---|
101 |
|
---|
102 | CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ;
|
---|
103 |
|
---|
104 | // Execute the required command.
|
---|
105 | switch ( $sCommand )
|
---|
106 | {
|
---|
107 | case 'GetFolders' :
|
---|
108 | GetFolders( $sResourceType, $sCurrentFolder ) ;
|
---|
109 | break ;
|
---|
110 | case 'GetFoldersAndFiles' :
|
---|
111 | GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
|
---|
112 | break ;
|
---|
113 | case 'CreateFolder' :
|
---|
114 | CreateFolder( $sResourceType, $sCurrentFolder ) ;
|
---|
115 | break ;
|
---|
116 | }
|
---|
117 |
|
---|
118 | CreateXmlFooter() ;
|
---|
119 |
|
---|
120 | exit ;
|
---|
121 | }
|
---|
122 | ?>
|
---|