1<?php
2/*
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2009 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
27require('./config.php') ;
28require('./util.php') ;
29require('./io.php') ;
30require('./basexml.php') ;
31require('./commands.php') ;
32require('./phpcompat.php') ;
33require_once('./SafeFN.class.php');
34
35if ( !$Config['Enabled'] )
36	SendError( 1, 'FileBrowserError_Connector') ;
37
38
39DoResponse() ;
40
41function DoResponse()
42{
43
44
45    if (!isset($_GET)) {
46        global $_GET;
47    }
48
49
50
51	if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
52		return ;
53
54
55
56	// Get the main request informaiton.
57	$sCommand		= $_GET['Command'] ;
58	$sResourceType	= $_GET['Type'] ;
59	$sCurrentFolder	= GetCurrentFolder() ;
60
61	// Check if it is an allowed command
62	if ( ! IsAllowedCommand( $sCommand ) )
63		SendError( 1, 'FileBrowserError_Command' . ';;' . $sCommand ) ;
64
65	// Check if it is an allowed type.
66	if ( !IsAllowedType( $sResourceType ) )
67		SendError( 1, 'FileBrowserError_Type'  . ';;' . $sResourceType) ;
68
69
70	// File Upload doesn't have to Return XML, so it must be intercepted before anything.
71	if ( $sCommand == 'FileUpload' )
72	{
73		FileUpload( $sResourceType, $sCurrentFolder, $sCommand ) ;
74		return ;
75	}
76
77	if ( $sCommand == 'GetDwfckNs' )
78	{
79		GetDwfckNs();
80		return;
81	}
82
83
84
85	CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ;
86
87
88
89	// Execute the required command.
90	switch ( $sCommand )
91	{
92		case 'GetFolders' :
93			GetFolders( $sResourceType, $sCurrentFolder ) ;
94			break ;
95		case 'GetFoldersAndFiles' :
96			GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
97			break ;
98		case 'CreateFolder' :
99			CreateFolder( $sResourceType, $sCurrentFolder ) ;
100			break ;
101        case 'UnlinkFile' :
102            UnlinkFile($sResourceType, $sCurrentFolder, $sCommand, $_GET['file']);
103            break;
104
105	}
106
107	CreateXmlFooter() ;
108
109	exit ;
110}
111?>
112