/pigeoncms/Plugins/fckeditor/editor/filemanager/connectors/perl/upload.cgi

http://pigeoncms.googlecode.com/ · Perl · 87 lines · 41 code · 12 blank · 34 comment · 10 complexity · 0072bb2bd0a932a165dd3e986f894677 MD5 · raw file

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