--- /dev/null
+#!/usr/bin/env perl\r
+\r
+#####\r
+# FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+# Copyright (C) 2003-2008 Frederico Caldeira Knabben\r
+#\r
+# == BEGIN LICENSE ==\r
+#\r
+# Licensed under the terms of any of the following licenses at your\r
+# choice:\r
+#\r
+# - GNU General Public License Version 2 or later (the "GPL")\r
+# http://www.gnu.org/licenses/gpl.html\r
+#\r
+# - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+# http://www.gnu.org/licenses/lgpl.html\r
+#\r
+# - Mozilla Public License Version 1.1 or later (the "MPL")\r
+# http://www.mozilla.org/MPL/MPL-1.1.html\r
+#\r
+# == END LICENSE ==\r
+#\r
+# This is the File Manager Connector for Perl.\r
+#####\r
+\r
+##\r
+# ATTENTION: To enable this connector, look for the "SECURITY" comment in this file.\r
+##\r
+\r
+## START: Hack for Windows (Not important to understand the editor code... Perl specific).\r
+if(Windows_check()) {\r
+ chdir(GetScriptPath($0));\r
+}\r
+\r
+sub Windows_check\r
+{\r
+ # IIS,PWS(NT/95)\r
+ $www_server_os = $^O;\r
+ # Win98 & NT(SP4)\r
+ if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }\r
+ # AnHTTPd/Omni/IIS\r
+ if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }\r
+ # Win Apache\r
+ if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }\r
+ if($www_server_os=~ /win/i) { return(1); }\r
+ return(0);\r
+}\r
+\r
+sub GetScriptPath {\r
+ local($path) = @_;\r
+ if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }\r
+ $path;\r
+}\r
+## END: Hack for IIS\r
+\r
+require 'util.pl';\r
+require 'io.pl';\r
+require 'basexml.pl';\r
+require 'commands.pl';\r
+require 'upload_fck.pl';\r
+\r
+##\r
+# SECURITY: REMOVE/COMMENT THE FOLLOWING LINE TO ENABLE THIS CONNECTOR.\r
+##\r
+ &SendUploadResults(1, '', '', 'This connector is disabled. Please check the "editor/filemanager/connectors/perl/upload.cgi" file' ) ;\r
+\r
+ &read_input();\r
+\r
+ if($FORM{'ServerPath'} ne "") {\r
+ $GLOBALS{'UserFilesPath'} = $FORM{'ServerPath'};\r
+ if(!($GLOBALS{'UserFilesPath'} =~ /\/$/)) {\r
+ $GLOBALS{'UserFilesPath'} .= '/' ;\r
+ }\r
+ } else {\r
+ $GLOBALS{'UserFilesPath'} = '/userfiles/';\r
+ }\r
+\r
+ # Map the "UserFiles" path to a local directory.\r
+ $rootpath = &GetRootPath();\r
+ $GLOBALS{'UserFilesDirectory'} = $rootpath . $GLOBALS{'UserFilesPath'};\r
+\r
+ &DoResponse();\r
+\r
+sub DoResponse\r
+{\r
+ # Get the main request information.\r
+ $sCommand = 'FileUpload'; #$FORM{'Command'};\r
+ $sResourceType = $FORM{'Type'};\r
+ $sCurrentFolder = $FORM{'CurrentFolder'};\r
+\r
+ if ($sResourceType eq '') {\r
+ $sResourceType = 'File' ;\r
+ }\r
+ if ($sCurrentFolder eq '') {\r
+ $sCurrentFolder = '/' ;\r
+ }\r
+\r
+ # Check the current folder syntax (must begin and start with a slash).\r
+ if(!($sCurrentFolder =~ /\/$/)) {\r
+ $sCurrentFolder .= '/';\r
+ }\r
+ if(!($sCurrentFolder =~ /^\//)) {\r
+ $sCurrentFolder = '/' . $sCurrentFolder;\r
+ }\r
+\r
+ # Check for invalid folder paths (..)\r
+ if ( $sCurrentFolder =~ /(?:\.\.|\\)/ ) {\r
+ SendError( 102, "" ) ;\r
+ }\r
+\r
+ # File Upload doesn't have to Return XML, so it must be intercepted before anything.\r
+ if($sCommand eq 'FileUpload') {\r
+ FileUpload($sResourceType,$sCurrentFolder);\r
+ return ;\r
+ }\r
+\r
+}\r