source: branches/1.2/workflow/js/fckeditor/editor/filemanager/browser/default/connectors/php/connector.php @ 1349

Revision 1349, 3.0 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

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