FCKeditor 2.6.6
[freeside.git] / httemplate / elements / fckeditor / editor / filemanager / connectors / perl / upload.cgi
1 #!/usr/bin/env perl\r
2 \r
3 #####\r
4 #  FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
5 #  Copyright (C) 2003-2010 Frederico Caldeira Knabben\r
6 #\r
7 #  == BEGIN LICENSE ==\r
8 #\r
9 #  Licensed under the terms of any of the following licenses at your\r
10 #  choice:\r
11 #\r
12 #   - GNU General Public License Version 2 or later (the "GPL")\r
13 #     http://www.gnu.org/licenses/gpl.html\r
14 #\r
15 #   - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
16 #     http://www.gnu.org/licenses/lgpl.html\r
17 #\r
18 #   - Mozilla Public License Version 1.1 or later (the "MPL")\r
19 #     http://www.mozilla.org/MPL/MPL-1.1.html\r
20 #\r
21 #  == END LICENSE ==\r
22 #\r
23 #  This is the File Manager Connector for Perl.\r
24 #####\r
25 \r
26 ##\r
27 # ATTENTION: To enable this connector, look for the "SECURITY" comment in config.pl.\r
28 ##\r
29 \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
33 }\r
34 \r
35 sub Windows_check\r
36 {\r
37         # IIS,PWS(NT/95)\r
38         $www_server_os = $^O;\r
39         # Win98 & NT(SP4)\r
40         if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }\r
41         # AnHTTPd/Omni/IIS\r
42         if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }\r
43         # Win Apache\r
44         if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }\r
45         if($www_server_os=~ /win/i) { return(1); }\r
46         return(0);\r
47 }\r
48 \r
49 sub GetScriptPath {\r
50         local($path) = @_;\r
51         if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }\r
52         $path;\r
53 }\r
54 ## END: Hack for IIS\r
55 \r
56 require 'util.pl';\r
57 require 'io.pl';\r
58 require 'basexml.pl';\r
59 require 'commands.pl';\r
60 require 'upload_fck.pl';\r
61 require 'config.pl';\r
62 \r
63 &read_input();\r
64 &DoResponse();\r
65 \r
66 sub DoResponse\r
67 {\r
68         # Get the main request information.\r
69         $sCommand               = 'FileUpload';\r
70         $sResourceType  = &specialchar_cnv($FORM{'Type'});\r
71         $sCurrentFolder = "/";\r
72 \r
73         if ($sResourceType eq '') {\r
74                 $sResourceType = 'File' ;\r
75         }\r
76 \r
77         if ( !($sResourceType =~ /^(File|Image|Flash|Media)$/) ) {\r
78                 SendError( 1, "Invalid type specified" ) ;\r
79         }\r
80 \r
81         # File Upload doesn't have to Return XML, so it must be intercepted before anything.\r
82         if($sCommand eq 'FileUpload') {\r
83                 FileUpload($sResourceType,$sCurrentFolder);\r
84                 return ;\r
85         }\r
86 \r
87 }\r