source: companies/celepar/news_admin/templates/celepar/fckeditor/editor/filemanager/browser/default/connectors/perl/connector.cgi @ 763

Revision 763, 3.5 KB checked in by niltonneto, 15 years ago (diff)

Importação inicial do Expresso da Celepar

Line 
1#!/usr/bin/env perl
2
3#####
4#  FCKeditor - The text editor for internet
5#  Copyright (C) 2003-2006 Frederico Caldeira Knabben
6
7#  Licensed under the terms of the GNU Lesser General Public License:
8#               http://www.opensource.org/licenses/lgpl-license.php
9
10#  For further information visit:
11#               http://www.fckeditor.net/
12
13#  "Support Open Source software. What about a donation today?"
14
15#  File Name: connector.cgi
16#       This is the File Manager Connector for Perl.
17
18#  File Authors:
19#               Takashi Yamaguchi (jack@omakase.net)
20#               Frederico Caldeira Knabben (fredck@fckeditor.net)
21#####
22
23##
24# ATTENTION: To enable this connector, look for the "SECURITY" comment in this file.
25##
26
27## START: Hack for Windows (Not important to understand the editor code... Perl specific).
28if(Windows_check()) {
29        chdir(GetScriptPath($0));
30}
31
32sub Windows_check
33{
34        # IIS,PWS(NT/95)
35        $www_server_os = $^O;
36        # Win98 & NT(SP4)
37        if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
38        # AnHTTPd/Omni/IIS
39        if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
40        # Win Apache
41        if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
42        if($www_server_os=~ /win/i) { return(1); }
43        return(0);
44}
45
46sub GetScriptPath {
47        local($path) = @_;
48        if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
49        $path;
50}
51## END: Hack for IIS
52
53require 'util.pl';
54require 'io.pl';
55require 'basexml.pl';
56require 'commands.pl';
57require 'upload_fck.pl';
58
59##
60# SECURITY: REMOVE/COMMENT THE FOLLOWING LINE TO ENABLE THIS CONNECTOR.
61##
62&SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/browser/default/connectors/perl/connector.cgi" file' ) ;
63
64        &read_input();
65
66        if($FORM{'ServerPath'} ne "") {
67                $GLOBALS{'UserFilesPath'} = $FORM{'ServerPath'};
68                if(!($GLOBALS{'UserFilesPath'} =~ /\/$/)) {
69                        $GLOBALS{'UserFilesPath'} .= '/' ;
70                }
71        } else {
72                $GLOBALS{'UserFilesPath'} = '/UserFiles/';
73        }
74
75        # Map the "UserFiles" path to a local directory.
76        $rootpath = &GetRootPath();
77        $GLOBALS{'UserFilesDirectory'} = $rootpath . $GLOBALS{'UserFilesPath'};
78
79        &DoResponse();
80
81sub DoResponse
82{
83
84        if($FORM{'Command'} eq "" || $FORM{'Type'} eq "" || $FORM{'CurrentFolder'} eq "") {
85                return ;
86        }
87        # Get the main request informaiton.
88        $sCommand               = $FORM{'Command'};
89        $sResourceType  = $FORM{'Type'};
90        $sCurrentFolder = $FORM{'CurrentFolder'};
91
92        # Check the current folder syntax (must begin and start with a slash).
93        if(!($sCurrentFolder =~ /\/$/)) {
94                $sCurrentFolder .= '/';
95        }
96        if(!($sCurrentFolder =~ /^\//)) {
97                $sCurrentFolder = '/' . $sCurrentFolder;
98        }
99       
100        # Check for invalid folder paths (..)
101        if ( $sCurrentFolder =~ /\.\./ ) {
102                SendError( 102, "" ) ;
103        }
104
105        # File Upload doesn't have to Return XML, so it must be intercepted before anything.
106        if($sCommand eq 'FileUpload') {
107                FileUpload($sResourceType,$sCurrentFolder);
108                return ;
109        }
110
111        print << "_HTML_HEAD_";
112Content-Type:text/xml; charset=utf-8
113Pragma: no-cache
114Cache-Control: no-cache
115Expires: Thu, 01 Dec 1994 16:00:00 GMT
116
117_HTML_HEAD_
118
119        &CreateXmlHeader($sCommand,$sResourceType,$sCurrentFolder);
120       
121        # Execute the required command.
122        if($sCommand eq 'GetFolders') {
123                &GetFolders($sResourceType,$sCurrentFolder);
124        } elsif($sCommand eq 'GetFoldersAndFiles') {
125                &GetFoldersAndFiles($sResourceType,$sCurrentFolder);
126        } elsif($sCommand eq 'CreateFolder') {
127                &CreateFolder($sResourceType,$sCurrentFolder);
128        }
129       
130        &CreateXmlFooter();
131       
132        exit ;
133}
134
Note: See TracBrowser for help on using the repository browser.