Subversion Repositories Applications.papyrus

Rev

Rev 431 | Go to most recent revision | Details | Compare with Previous | 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
 
436 ddelon 41
$GLOBALS["BaseDir"] = '';
42
if ( isset( $Config['BaseDir'] ) )
43
	$GLOBALS["BaseDir"] = $Config['BaseDir'] ;
44
else if ( isset( $_GET['BaseDir'] ) )
45
	$GLOBALS["BaseDir"] = $_GET['BaseDir'] ;
46
else
47
	$GLOBALS["BaseDir"] = '' ;
48
 
49
$GLOBALS["UrlPrefix"] = '';
50
if ( isset( $Config['UrlPrefix'] ) )
51
	$GLOBALS["UrlPrefix"] = $Config['UrlPrefix'] ;
52
else if ( isset( $_GET['UrlPrefix'] ) )
53
	$GLOBALS["UrlPrefix"] = $_GET['UrlPrefix'] ;
54
else
55
	$GLOBALS["UrlPrefix"] = '' ;
56
 
57
 
431 ddelon 58
// Map the "UserFiles" path to a local directory.
59
//$GLOBALS["UserFilesDirectory"] = GetRootPath() . str_replace( '/', '\\', $GLOBALS["UserFilesPath"] ) ;
436 ddelon 60
//$GLOBALS["UserFilesDirectory"] = GetRootPath() . $GLOBALS["UserFilesPath"] ;
61
$GLOBALS['UserFilesDirectory'] = $GLOBALS['BaseDir'].$GLOBALS['UserFilesPath'] ;
431 ddelon 62
 
436 ddelon 63
 
431 ddelon 64
DoResponse() ;
65
 
66
function DoResponse()
67
{
68
	if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
69
		return ;
70
 
71
	// Get the main request informaiton.
72
	$sCommand		= $_GET['Command'] ;
73
	$sResourceType	= $_GET['Type'] ;
74
	$sCurrentFolder	= $_GET['CurrentFolder'] ;
75
 
76
	// Check if it is an allowed type.
77
	if ( !in_array( $sResourceType, array('File','Image','Flash','Media') ) )
78
		return ;
79
 
80
	// Check the current folder syntax (must begin and start with a slash).
81
	if ( ! ereg( '/$', $sCurrentFolder ) ) $sCurrentFolder .= '/' ;
82
	if ( strpos( $sCurrentFolder, '/' ) !== 0 ) $sCurrentFolder = '/' . $sCurrentFolder ;
83
 
84
	// Check for invalid folder paths (..)
85
	if ( strpos( $sCurrentFolder, '..' ) )
86
		SendError( 102, "" ) ;
87
 
88
	// File Upload doesn't have to Return XML, so it must be intercepted before anything.
89
	if ( $sCommand == 'FileUpload' )
90
	{
91
		FileUpload( $sResourceType, $sCurrentFolder ) ;
92
		return ;
93
	}
94
 
95
	CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ;
96
 
97
	// Execute the required command.
98
	switch ( $sCommand )
99
	{
100
		case 'GetFolders' :
101
			GetFolders( $sResourceType, $sCurrentFolder ) ;
102
			break ;
103
		case 'GetFoldersAndFiles' :
104
			GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
105
			break ;
106
		case 'CreateFolder' :
107
			CreateFolder( $sResourceType, $sCurrentFolder ) ;
108
			break ;
109
	}
110
 
111
	CreateXmlFooter() ;
112
 
113
	exit ;
114
}
115
?>