4 # FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
5 # Copyright (C) 2003-2007 Frederico Caldeira Knabben
\r
7 # == BEGIN LICENSE ==
\r
9 # Licensed under the terms of any of the following licenses at your
\r
12 # - GNU General Public License Version 2 or later (the "GPL")
\r
13 # http://www.gnu.org/licenses/gpl.html
\r
15 # - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
16 # http://www.gnu.org/licenses/lgpl.html
\r
18 # - Mozilla Public License Version 1.1 or later (the "MPL")
\r
19 # http://www.mozilla.org/MPL/MPL-1.1.html
\r
23 # This is the File Manager Connector for Perl.
\r
27 # ATTENTION: To enable this connector, look for the "SECURITY" comment in this file.
\r
30 ## START: Hack for Windows (Not important to understand the editor code... Perl specific).
\r
31 if(Windows_check()) {
\r
32 chdir(GetScriptPath($0));
\r
38 $www_server_os = $^O;
\r
40 if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
\r
42 if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
\r
44 if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
\r
45 if($www_server_os=~ /win/i) { return(1); }
\r
51 if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
\r
54 ## END: Hack for IIS
\r
58 require 'basexml.pl';
\r
59 require 'commands.pl';
\r
60 require 'upload_fck.pl';
\r
63 # SECURITY: REMOVE/COMMENT THE FOLLOWING LINE TO ENABLE THIS CONNECTOR.
\r
65 &SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/browser/default/connectors/perl/connector.cgi" file' ) ;
\r
69 if($FORM{'ServerPath'} ne "") {
\r
70 $GLOBALS{'UserFilesPath'} = $FORM{'ServerPath'};
\r
71 if(!($GLOBALS{'UserFilesPath'} =~ /\/$/)) {
\r
72 $GLOBALS{'UserFilesPath'} .= '/' ;
\r
75 $GLOBALS{'UserFilesPath'} = '/userfiles/';
\r
78 # Map the "UserFiles" path to a local directory.
\r
79 $rootpath = &GetRootPath();
\r
80 $GLOBALS{'UserFilesDirectory'} = $rootpath . $GLOBALS{'UserFilesPath'};
\r
87 if($FORM{'Command'} eq "" || $FORM{'Type'} eq "" || $FORM{'CurrentFolder'} eq "") {
\r
90 # Get the main request informaiton.
\r
91 $sCommand = $FORM{'Command'};
\r
92 $sResourceType = $FORM{'Type'};
\r
93 $sCurrentFolder = $FORM{'CurrentFolder'};
\r
95 # Check the current folder syntax (must begin and start with a slash).
\r
96 if(!($sCurrentFolder =~ /\/$/)) {
\r
97 $sCurrentFolder .= '/';
\r
99 if(!($sCurrentFolder =~ /^\//)) {
\r
100 $sCurrentFolder = '/' . $sCurrentFolder;
\r
103 # Check for invalid folder paths (..)
\r
104 if ( $sCurrentFolder =~ /\.\./ ) {
\r
105 SendError( 102, "" ) ;
\r
108 # File Upload doesn't have to Return XML, so it must be intercepted before anything.
\r
109 if($sCommand eq 'FileUpload') {
\r
110 FileUpload($sResourceType,$sCurrentFolder);
\r
114 print << "_HTML_HEAD_";
\r
115 Content-Type:text/xml; charset=utf-8
\r
117 Cache-Control: no-cache
\r
118 Expires: Thu, 01 Dec 1994 16:00:00 GMT
\r
122 &CreateXmlHeader($sCommand,$sResourceType,$sCurrentFolder);
\r
124 # Execute the required command.
\r
125 if($sCommand eq 'GetFolders') {
\r
126 &GetFolders($sResourceType,$sCurrentFolder);
\r
127 } elsif($sCommand eq 'GetFoldersAndFiles') {
\r
128 &GetFoldersAndFiles($sResourceType,$sCurrentFolder);
\r
129 } elsif($sCommand eq 'CreateFolder') {
\r
130 &CreateFolder($sResourceType,$sCurrentFolder);
\r
133 &CreateXmlFooter();
\r