Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
<?php
2
/*
3
 * FCKeditor - The text editor for internet
4
 * Copyright (C) 2003-2005 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
 * File Name: connector.php
13
 * 	This is the File Manager Connector for PHP.
14
 *
15
 * File Authors:
16
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
17
 */
18
 
19
include('config.php') ;
20
include('util.php') ;
21
include('io.php') ;
22
include('basexml.php') ;
23
include('commands.php') ;
24
 
25
if ( !$Config['Enabled'] )
26
	SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/browser/default/connectors/php/config.php" file' ) ;
27
 
28
// Get the "UserFiles" path.
29
$GLOBALS["UserFilesPath"] = '' ;
30
 
31
if ( isset( $Config['UserFilesPath'] ) )
32
	$GLOBALS["UserFilesPath"] = $Config['UserFilesPath'] ;
33
else if ( isset( $_GET['ServerPath'] ) )
34
	$GLOBALS["UserFilesPath"] = $_GET['ServerPath'] ;
35
else
36
	$GLOBALS["UserFilesPath"] = '/UserFiles/' ;
37
 
38
if ( ! ereg( '/$', $GLOBALS["UserFilesPath"] ) )
39
	$GLOBALS["UserFilesPath"] .= '/' ;
40
 
41
// Map the "UserFiles" path to a local directory.
42
//$GLOBALS["UserFilesDirectory"] = GetRootPath() . str_replace( '/', '\\', $GLOBALS["UserFilesPath"] ) ;
43
$GLOBALS["UserFilesDirectory"] = GetRootPath() . $GLOBALS["UserFilesPath"] ;
44
 
45
DoResponse() ;
46
 
47
function DoResponse()
48
{
49
	if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
50
		return ;
51
 
52
	// Get the main request informaiton.
53
	$sCommand		= $_GET['Command'] ;
54
	$sResourceType	= $_GET['Type'] ;
55
	$sCurrentFolder	= $_GET['CurrentFolder'] ;
56
 
57
	// Check if it is an allowed type.
58
	if ( !in_array( $sResourceType, array('File','Image','Flash','Media') ) )
59
		return ;
60
 
61
	// Check the current folder syntax (must begin and start with a slash).
62
	if ( ! ereg( '/$', $sCurrentFolder ) ) $sCurrentFolder .= '/' ;
63
	if ( strpos( $sCurrentFolder, '/' ) !== 0 ) $sCurrentFolder = '/' . $sCurrentFolder ;
64
 
65
	// Check for invalid folder paths (..)
66
	if ( strpos( $sCurrentFolder, '..' ) )
67
		SendError( 102, "" ) ;
68
 
69
	// File Upload doesn't have to Return XML, so it must be intercepted before anything.
70
	if ( $sCommand == 'FileUpload' )
71
	{
72
		FileUpload( $sResourceType, $sCurrentFolder ) ;
73
		return ;
74
	}
75
 
76
	CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ;
77
 
78
	// Execute the required command.
79
	switch ( $sCommand )
80
	{
81
		case 'GetFolders' :
82
			GetFolders( $sResourceType, $sCurrentFolder ) ;
83
			break ;
84
		case 'GetFoldersAndFiles' :
85
			GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
86
			break ;
87
		case 'CreateFolder' :
88
			CreateFolder( $sResourceType, $sCurrentFolder ) ;
89
			break ;
90
	}
91
 
92
	CreateXmlFooter() ;
93
 
94
	exit ;
95
}
96
?>