source: trunk/admin/inc/FCKeditor/editor/filemanager/browser/default/connectors/php/connector.php@ 23

Last change on this file since 23 was 23, checked in by roby, 14 years ago

Gestione charset con query mysql e sostituzione funzioni ereg

File size: 3.4 KB
Line 
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
21ob_start() ;
22
23include('config.php') ;
24include('util.php') ;
25include('io.php') ;
26include('basexml.php') ;
27include('commands.php') ;
28
29if ( !$Config['Enabled'] )
30 SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/browser/default/connectors/php/config.php" file' ) ;
31
32if(!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
42if ( isset( $Config['UserFilesPath'] ) )
43 $GLOBALS["UserFilesPath"] = $Config['UserFilesPath'] ;
44else if ( isset( $_GET['ServerPath'] ) )
45 $GLOBALS["UserFilesPath"] = $_GET['ServerPath'] ;
46else
47{
48
49 $strBP = dirname($_SERVER['PHP_SELF']);
50 $strBP = stristr_reverse($strBP, 'includes/FCKeditor/editor/filemanager/browser/default/connectors/php');
51 if ($strBP{strlen($strBP)-1} != "/") $strBP .= "/";
52 $strBP .= 'includes/FCKeditor/upload/';
53 $GLOBALS["UserFilesPath"] = $strBP ;
54}
55if ( ! preg_match( '/\/$/', $GLOBALS["UserFilesPath"] ) )
56 $GLOBALS["UserFilesPath"] .= '/' ;
57
58if ( strlen( $Config['UserFilesAbsolutePath'] ) > 0 )
59{
60 $GLOBALS["UserFilesDirectory"] = $Config['UserFilesAbsolutePath'] ;
61
62 if ( ! preg_match( '/\/$/', $GLOBALS["UserFilesDirectory"] ) )
63 $GLOBALS["UserFilesDirectory"] .= '/' ;
64}
65else
66{
67 // Map the "UserFiles" path to a local directory.
68 $GLOBALS["UserFilesDirectory"] = GetRootPath() . $GLOBALS["UserFilesPath"] ;
69}
70
71DoResponse() ;
72
73function 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?>
Note: See TracBrowser for help on using the repository browser.