[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/editor/filemanager/browser/default/connectors/perl/ -> connector.cgi (source)

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


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7