From: Raphael D. P. <rap...@us...> - 2005-09-01 18:16:01
|
Update of /cvsroot/thyapi/thyapi/thywidgets/external/fckeditor/editor/filemanager/browser/default/connectors/perl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32492/thywidgets/external/fckeditor/editor/filemanager/browser/default/connectors/perl Added Files: basexml.pl commands.pl connector.cgi io.pl upload_fck.pl util.pl Log Message: Synching... --- NEW FILE: commands.pl --- ##### # FCKeditor - The text editor for internet # Copyright (C) 2003-2004 Frederico Caldeira Knabben # # Licensed under the terms of the GNU Lesser General Public License: # http://www.opensource.org/licenses/lgpl-license.php # # For further information visit: # http://www.fckeditor.net/ # # File Name: commands.pl # This is the File Manager Connector for Perl. # # Version: 2.0 RC3 # Modified: 2005-02-28 17:06:07 # # File Authors: # Takashi Yamaguchi (ja...@om...) ##### sub GetFolders { local($resourceType, $currentFolder) = @_; # Map the virtual path to the local server path. $sServerDir = &ServerMapFolder($resourceType, $currentFolder); print "<Folders>"; # Open the "Folders" node. opendir(DIR,"$sServerDir"); @files = grep(!/^\.\.?$/,readdir(DIR)); closedir(DIR); foreach $sFile (@files) { if($sFile != '.' && $sFile != '..' && (-d "$sServerDir$sFile")) { $cnv_filename = &ConvertToXmlAttribute($sFile); print '<Folder name="' . $cnv_filename . '" />'; } } print "</Folders>"; # Close the "Folders" node. } sub GetFoldersAndFiles { local($resourceType, $currentFolder) = @_; # Map the virtual path to the local server path. $sServerDir = &ServerMapFolder($resourceType,$currentFolder); # Initialize the output buffers for "Folders" and "Files". $sFolders = '<Folders>'; $sFiles = '<Files>'; opendir(DIR,"$sServerDir"); @files = grep(!/^\.\.?$/,readdir(DIR)); closedir(DIR); foreach $sFile (@files) { if($sFile ne '.' && $sFile ne '..') { if(-d "$sServerDir$sFile") { $cnv_filename = &ConvertToXmlAttribute($sFile); $sFolders .= '<Folder name="' . $cnv_filename . '" />' ; } else { ($iFileSize,$refdate,$filedate,$fileperm) = (stat("$sServerDir$sFile"))[7,8,9,2]; if($iFileSize > 0) { $iFileSize = int($iFileSize / 1024); if($iFileSize < 1) { $iFileSize = 1; } } $cnv_filename = &ConvertToXmlAttribute($sFile); $sFiles .= '<File name="' . $cnv_filename . '" size="' . $iFileSize . '" />' ; } } } print $sFolders ; print '</Folders>'; # Close the "Folders" node. print $sFiles ; print '</Files>'; # Close the "Files" node. } sub CreateFolder { local($resourceType, $currentFolder) = @_; $sErrorNumber = '0' ; $sErrorMsg = '' ; if($FORM{'NewFolderName'} ne "") { $sNewFolderName = $FORM{'NewFolderName'}; # Map the virtual path to the local server path of the current folder. $sServerDir = &ServerMapFolder($resourceType, $currentFolder); if(-w $sServerDir) { $sServerDir .= $sNewFolderName; $sErrorMsg = &CreateServerFolder($sServerDir); if($sErrorMsg == 0) { $sErrorNumber = '0'; } elsif($sErrorMsg eq 'Invalid argument' || $sErrorMsg eq 'No such file or directory') { $sErrorNumber = '102'; #// Path too long. } else { $sErrorNumber = '110'; } } else { $sErrorNumber = '103'; } } else { $sErrorNumber = '102' ; } # Create the "Error" node. $cnv_errmsg = &ConvertToXmlAttribute($sErrorMsg); print '<Error number="' . $sErrorNumber . '" originalDescription="' . $cnv_errmsg . '" />'; } sub FileUpload { eval("use File::Copy;"); local($resourceType, $currentFolder) = @_; $sErrorNumber = '0' ; $sFileName = '' ; if($new_fname) { # Map the virtual path to the local server path. $sServerDir = &ServerMapFolder($resourceType,$currentFolder); # Get the uploaded file name. $sFileName = $new_fname; $sOriginalFileName = $sFileName; $iCounter = 0; while(1) { $sFilePath = $sServerDir . $sFileName; if(-e $sFilePath) { $iCounter++ ; ($path,$BaseName,$ext) = &RemoveExtension($sOriginalFileName); $sFileName = $BaseName . '(' . $iCounter . ').' . $ext; $sErrorNumber = '201'; } else { copy("$img_dir/$new_fname","$sFilePath"); chmod(0777,$sFilePath); unlink("$img_dir/$new_fname"); last; } } } else { $sErrorNumber = '202' ; } $sFileName =~ s/"/\\"/g; print "Content-type: text/html\n\n"; print '<script type="text/javascript">'; print 'window.parent.frames["frmUpload"].OnUploadCompleted(' . $sErrorNumber . ',"' . $sFileName . '") ;'; print '</script>'; exit ; } 1; --- NEW FILE: connector.cgi --- #!/usr/bin/env perl #/* # * FCKeditor - The text editor for internet # * Copyright (C) 2003-2004 Frederico Caldeira Knabben # * # * Licensed under the terms of the GNU Lesser General Public License: # * http://www.opensource.org/licenses/lgpl-license.php # * # * For further information visit: # * http://www.fckeditor.net/ # * # * File Name: connector.cgi # * This is the File Manager Connector for Perl. # * # * Version: 2.0 RC2 # * Modified: 2005-01-7 13:20:00 # * # * File Authors: # * Frederico Caldeira Knabben (fr...@fc...) # * Takashi Yamaguchi (ja...@om...) # */ require 'util.pl'; require 'io.pl'; require 'basexml.pl'; require 'commands.pl'; require 'upload_fck.pl'; &read_input(); if($FORM{'ServerPath'} ne "") { $GLOBALS{'UserFilesPath'} = $FORM{'ServerPath'}; if(!($GLOBALS{'UserFilesPath'} =~ /\/$/)) { $GLOBALS{'UserFilesPath'} .= '/' ; } } else { $GLOBALS{'UserFilesPath'} = '/UserFiles/'; } # Map the "UserFiles" path to a local directory. $rootpath = &GetRootPath(); $GLOBALS{'UserFilesDirectory'} = $rootpath . $GLOBALS{'UserFilesPath'}; &DoResponse(); sub DoResponse { if($FORM{'Command'} eq "" || $FORM{'Type'} eq "" || $FORM{'CurrentFolder'} eq "") { return ; } # Get the main request informaiton. $sCommand = $FORM{'Command'}; $sResourceType = $FORM{'Type'}; $sCurrentFolder = $FORM{'CurrentFolder'}; # Check the current folder syntax (must begin and start with a slash). if(!($sCurrentFolder =~ /\/$/)) { $sCurrentFolder .= '/'; } if(!($sCurrentFolder =~ /^\//)) { $sCurrentFolder = '/' . $sCurrentFolder; } # File Upload doesn't have to Return XML, so it must be intercepted before anything. if($sCommand eq 'FileUpload') { FileUpload($sResourceType,$sCurrentFolder); return ; } print << "_HTML_HEAD_"; Content-Type:text/xml; charset=utf-8 Pragma: no-cache Cache-Control: no-cache Expires: Thu, 01 Dec 1994 16:00:00 GMT _HTML_HEAD_ &CreateXmlHeader($sCommand,$sResourceType,$sCurrentFolder); # Execute the required command. if($sCommand eq 'GetFolders') { &GetFolders($sResourceType,$sCurrentFolder); } elsif($sCommand eq 'GetFoldersAndFiles') { &GetFoldersAndFiles($sResourceType,$sCurrentFolder); } elsif($sCommand eq 'CreateFolder') { &CreateFolder($sResourceType,$sCurrentFolder); } &CreateXmlFooter(); exit ; } --- NEW FILE: upload_fck.pl --- ##### # FCKeditor - The text editor for internet # Copyright (C) 2003-2004 Frederico Caldeira Knabben # # Licensed under the terms of the GNU Lesser General Public License: # http://www.opensource.org/licenses/lgpl-license.php # # For further information visit: # http://www.fckeditor.net/ # # File Name: upload_fck.pl # This is the File Manager Connector for Perl. # # Version: 2.0 RC3 # Modified: 2005-02-28 17:05:41 # # File Authors: # Takashi Yamaguchi (ja...@om...) ##### # image data save dir $img_dir = './temp/'; # File size max(unit KB) $MAX_CONTENT_SIZE = 30000; # Filelock (1=use,0=not use) $PM{'flock'} = '1'; # upload Content-Type list my %UPLOAD_CONTENT_TYPE_LIST = ( 'image/(x-)?png' => 'png', # PNG image 'image/p?jpe?g' => 'jpg', # JPEG image 'image/gif' => 'gif', # GIF image 'image/x-xbitmap' => 'xbm', # XBM image 'image/(x-(MS-)?)?bmp' => 'bmp', # Windows BMP image 'image/pict' => 'pict', # Macintosh PICT image 'image/tiff' => 'tif', # TIFF image 'application/pdf' => 'pdf', # PDF image 'application/x-shockwave-flash' => 'swf', # Shockwave Flash 'video/(x-)?msvideo' => 'avi', # Microsoft Video 'video/quicktime' => 'mov', # QuickTime Video 'video/mpeg' => 'mpeg', # MPEG Video 'video/x-mpeg2' => 'mpv2', # MPEG2 Video 'audio/(x-)?midi?' => 'mid', # MIDI Audio 'audio/(x-)?wav' => 'wav', # WAV Audio 'audio/basic' => 'au', # ULAW Audio 'audio/mpeg' => 'mpga', # MPEG Audio 'application/(x-)?zip(-compressed)?' => 'zip', # ZIP Compress 'text/html' => 'html', # HTML 'text/plain' => 'txt', # TEXT '(?:application|text)/(?:rtf|richtext)' => 'rtf', # RichText 'application/msword' => 'doc', # Microsoft Word 'application/vnd.ms-excel' => 'xls', # Microsoft Excel '' ); # Upload is permitted. # A regular expression is possible. my %UPLOAD_EXT_LIST = ( 'png' => 'PNG image', 'p?jpe?g|jpe|jfif|pjp' => 'JPEG image', 'gif' => 'GIF image', 'xbm' => 'XBM image', 'bmp|dib|rle' => 'Windows BMP image', 'pi?ct' => 'Macintosh PICT image', 'tiff?' => 'TIFF image', 'pdf' => 'PDF image', 'swf' => 'Shockwave Flash', 'avi' => 'Microsoft Video', 'moo?v|qt' => 'QuickTime Video', 'm(p(e?gv?|e|v)|1v)' => 'MPEG Video', 'mp(v2|2v)' => 'MPEG2 Video', 'midi?|kar|smf|rmi|mff' => 'MIDI Audio', 'wav' => 'WAVE Audio', 'au|snd' => 'ULAW Audio', 'mp(e?ga|2|a|3)|abs' => 'MPEG Audio', 'zip' => 'ZIP Compress', 'lzh' => 'LZH Compress', 'cab' => 'CAB Compress', 'd?html?' => 'HTML', 'rtf|rtx' => 'RichText', 'txt|text' => 'Text', '' ); # sjis or euc my $CHARCODE = 'sjis'; $TRANS_2BYTE_CODE = 0; ############################################################################## # Summary # # Form Read input # # Parameters # Returns # Memo ############################################################################## sub read_input { eval("use File::Copy;"); eval("use File::Path;"); my ($FORM) = @_; mkdir($img_dir,0777); chmod(0777,$img_dir); undef $img_data_exists; undef @NEWFNAMES; undef @NEWFNAME_DATA; if($ENV{'CONTENT_LENGTH'} > 10000000 || $ENV{'CONTENT_LENGTH'} > $MAX_CONTENT_SIZE * 1024) { &upload_error( 'Size Error', sprintf( "Transmitting size is too large.MAX <strong>%d KB</strong> Now Size <strong>%d KB</strong>(<strong>%d bytes</strong> Over)", $MAX_CONTENT_SIZE, int($ENV{'CONTENT_LENGTH'} / 1024), $ENV{'CONTENT_LENGTH'} - $MAX_CONTENT_SIZE * 1024 ) ); } my $Buffer; if($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/) { # METHOD POST only return unless($ENV{'CONTENT_LENGTH'}); binmode(STDIN); # STDIN A pause character is detected.'(MacIE3.0 boundary of $ENV{'CONTENT_TYPE'} cannot be trusted.) my $Boundary = <STDIN>; $Boundary =~ s/\x0D\x0A//; $Boundary = quotemeta($Boundary); while(<STDIN>) { if(/^\s*Content-Disposition:/i) { my($name,$ContentType,$FileName); # form data get if(/\bname="([^"]+)"/i || /\bname=([^\s:;]+)/i) { $name = $1; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &Encode(\$name); } if(/\bfilename="([^"]*)"/i || /\bfilename=([^\s:;]*)/i) { $FileName = $1 || 'unknown'; } # head read while(<STDIN>) { last if(! /\w/); if(/^\s*Content-Type:\s*"([^"]+)"/i || /^\s*Content-Type:\s*([^\s:;]+)/i) { $ContentType = $1; } } # body read $value = ""; while(<STDIN>) { last if(/^$Boundary/o); $value .= $_; } $value =~s /\x0D\x0A$//; if($value ne '') { if($FileName || $ContentType) { $img_data_exists = 1; ( $FileName, # $Ext, # $Length, # $ImageWidth, # $ImageHeight, # $ContentName # ) = &CheckContentType(\$value,$FileName,$ContentType); $FORM{$name} = $FileName; $new_fname = $FileName; push(@NEWFNAME_DATA,"$FileName\t$Ext\t$Length\t$ImageWidth\t$ImageHeight\t$ContentName"); # Multi-upload correspondence push(@NEWFNAMES,$new_fname); open(OUT,">$img_dir/$new_fname"); binmode(OUT); eval "flock(OUT,2);" if($PM{'flock'} == 1); print OUT $value; eval "flock(OUT,8);" if($PM{'flock'} == 1); close(OUT); } elsif($name) { $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &Encode(\$value,'trans'); $FORM{$name} .= "\0" if(defined($FORM{$name})); $FORM{$name} .= $value; } } } last if(/^$Boundary\-\-/o); } } elsif($ENV{'CONTENT_LENGTH'}) { read(STDIN,$Buffer,$ENV{'CONTENT_LENGTH'}); } foreach(split(/&/,$Buffer),split(/&/,$ENV{'QUERY_STRING'})) { my($name, $value) = split(/=/); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &Encode(\$name); &Encode(\$value,'trans'); $FORM{$name} .= "\0" if(defined($FORM{$name})); $FORM{$name} .= $value; } } ############################################################################## # Summary # # CheckContentType # # Parameters # Returns # Memo ############################################################################## sub CheckContentType { my($DATA,$FileName,$ContentType) = @_; my($Ext,$ImageWidth,$ImageHeight,$ContentName,$Infomation); my $DataLength = length($$DATA); # An unknown file type $_ = $ContentType; my $UnknownType = ( !$_ || /^application\/(x-)?macbinary$/i || /^application\/applefile$/i || /^application\/octet-stream$/i || /^text\/plane$/i || /^x-unknown-content-type/i ); # MacBinary(Mac Unnecessary data are deleted.) if($UnknownType || $ENV{'HTTP_USER_AGENT'} =~ /Macintosh|Mac_/) { if($DataLength > 128 && !unpack("C",substr($$DATA,0,1)) && !unpack("C",substr($$DATA,74,1)) && !unpack("C",substr($$DATA,82,1)) ) { my $MacBinary_ForkLength = unpack("N", substr($$DATA, 83, 4)); # ForkLength Get my $MacBinary_FileName = quotemeta(substr($$DATA, 2, unpack("C",substr($$DATA, 1, 1)))); if($MacBinary_FileName && $MacBinary_ForkLength && $DataLength >= $MacBinary_ForkLength + 128 && ($FileName =~ /$MacBinary_FileName/i || substr($$DATA,102,4) eq 'mBIN')) { # DATA TOP 128byte MacBinary!! $$DATA = substr($$DATA,128,$MacBinary_ForkLength); my $ResourceLength = $DataLength - $MacBinary_ForkLength - 128; $DataLength = $MacBinary_ForkLength; } } } # A file name is changed into EUC. # &jcode::convert(\$FileName,'euc',$FormCodeDefault); # &jcode::h2z_euc(\$FileName); $FileName =~ s/^.*\\//; # Windows, Mac $FileName =~ s/^.*\///; # UNIX $FileName =~ s/&/&/g; $FileName =~ s/"/"/g; $FileName =~ s/</</g; $FileName =~ s/>/>/g; # # if($CHARCODE ne 'euc') { # &jcode::convert(\$FileName,$CHARCODE,'euc'); # } # An extension is extracted and it changes into a small letter. my $FileExt; if($FileName =~ /\.(\w+)$/) { $FileExt = $1; $FileExt =~ tr/A-Z/a-z/; } # Executable file detection (ban on upload) if($$DATA =~ /^MZ/) { $Ext = 'exe'; } # text if(!$Ext && ($UnknownType || $ContentType =~ /^text\//i || $ContentType =~ /^application\/(?:rtf|richtext)$/i || $ContentType =~ /^image\/x-xbitmap$/i) && ! $$DATA =~ /[\000-\006\177\377]/) { # $$DATA =~ s/\x0D\x0A/\n/g; # $$DATA =~ tr/\x0D\x0A/\n\n/; # # if( # $$DATA =~ /<\s*SCRIPT(?:.|\n)*?>/i # || $$DATA =~ /<\s*(?:.|\n)*?\bONLOAD\s*=(?:.|\n)*?>/i # || $$DATA =~ /<\s*(?:.|\n)*?\bONCLICK\s*=(?:.|\n)*?>/i # ) { # $Infomation = '(JavaScript contains)'; # } # if($$DATA =~ /<\s*TABLE(?:.|\n)*?>/i # || $$DATA =~ /<\s*BLINK(?:.|\n)*?>/i # || $$DATA =~ /<\s*MARQUEE(?:.|\n)*?>/i # || $$DATA =~ /<\s*OBJECT(?:.|\n)*?>/i # || $$DATA =~ /<\s*EMBED(?:.|\n)*?>/i # || $$DATA =~ /<\s*FRAME(?:.|\n)*?>/i # || $$DATA =~ /<\s*APPLET(?:.|\n)*?>/i # || $$DATA =~ /<\s*FORM(?:.|\n)*?>/i # || $$DATA =~ /<\s*(?:.|\n)*?\bSRC\s*=(?:.|\n)*?>/i # || $$DATA =~ /<\s*(?:.|\n)*?\bDYNSRC\s*=(?:.|\n)*?>/i # ) { # $Infomation = '(the HTML tag which is not safe is included)'; # } if($FileExt =~ /^txt$/i || $FileExt =~ /^cgi$/i || $FileExt =~ /^pl$/i) { # Text File $Ext = 'txt'; } elsif($ContentType =~ /^text\/html$/i || $FileExt =~ /html?/i || $$DATA =~ /<\s*HTML(?:.|\n)*?>/i) { # HTML File $Ext = 'html'; } elsif($ContentType =~ /^image\/x-xbitmap$/i || $FileExt =~ /^xbm$/i) { # XBM(x-BitMap) Image my $XbmName = $1; my ($XbmWidth, $XbmHeight); if($$DATA =~ /\#define\s*$XbmName\_width\s*(\d+)/i) { $XbmWidth = $1; } if($$DATA =~ /\#define\s*$XbmName\_height\s*(\d+)/i) { $XbmHeight = $1; } if($XbmWidth && $XbmHeight) { $Ext = 'xbm'; $ImageWidth = $XbmWidth; $ImageHeight = $XbmHeight; } } else { # $Ext = 'txt'; } } # image if(!$Ext && ($UnknownType || $ContentType =~ /^image\//i)) { # PNG if($$DATA =~ /^\x89PNG\x0D\x0A\x1A\x0A/) { if(substr($$DATA, 12, 4) eq 'IHDR') { $Ext = 'png'; ($ImageWidth, $ImageHeight) = unpack("N2", substr($$DATA, 16, 8)); } } elsif($$DATA =~ /^GIF8(?:9|7)a/) { # GIF89a(modified), GIF89a, GIF87a $Ext = 'gif'; ($ImageWidth, $ImageHeight) = unpack("v2", substr($$DATA, 6, 4)); } elsif($$DATA =~ /^II\x2a\x00\x08\x00\x00\x00/ || $$DATA =~ /^MM\x00\x2a\x00\x00\x00\x08/) { # TIFF $Ext = 'tif'; } elsif($$DATA =~ /^BM/) { # BMP $Ext = 'bmp'; } elsif($$DATA =~ /^\xFF\xD8\xFF/ || $$DATA =~ /JFIF/) { # JPEG my $HeaderPoint = index($$DATA, "\xFF\xD8\xFF", 0); my $Point = $HeaderPoint + 2; while($Point < $DataLength) { my($Maker, $MakerType, $MakerLength) = unpack("C2n",substr($$DATA,$Point,4)); if($Maker != 0xFF || $MakerType == 0xd9 || $MakerType == 0xda) { last; } elsif($MakerType >= 0xC0 && $MakerType <= 0xC3) { $Ext = 'jpg'; ($ImageHeight, $ImageWidth) = unpack("n2", substr($$DATA, $Point + 5, 4)); if($HeaderPoint > 0) { $$DATA = substr($$DATA, $HeaderPoint); $DataLength = length($$DATA); } last; } else { $Point += $MakerLength + 2; } } } } # audio if(!$Ext && ($UnknownType || $ContentType =~ /^audio\//i)) { # MIDI Audio if($$DATA =~ /^MThd/) { $Ext = 'mid'; } elsif($$DATA =~ /^\x2esnd/) { # ULAW Audio $Ext = 'au'; } elsif($$DATA =~ /^RIFF/ || $$DATA =~ /^ID3/ && $$DATA =~ /RIFF/) { my $HeaderPoint = index($$DATA, "RIFF", 0); $_ = substr($$DATA, $HeaderPoint + 8, 8); if(/^WAVEfmt $/) { # WAVE if(unpack("V",substr($$DATA, $HeaderPoint + 16, 4)) == 16) { $Ext = 'wav'; } else { # RIFF WAVE MP3 $Ext = 'mp3'; } } elsif(/^RMIDdata$/) { # RIFF MIDI $Ext = 'rmi'; } elsif(/^RMP3data$/) { # RIFF MP3 $Ext = 'rmp'; } if($ContentType =~ /^audio\//i) { $Infomation .= '(RIFF '. substr($$DATA, $HeaderPoint + 8, 4). ')'; } } } # a binary file unless ($Ext) { # PDF image if($$DATA =~ /^\%PDF/) { # Picture size is not measured. $Ext = 'pdf'; } elsif($$DATA =~ /^FWS/) { # Shockwave Flash $Ext = 'swf'; } elsif($$DATA =~ /^RIFF/ || $$DATA =~ /^ID3/ && $$DATA =~ /RIFF/) { my $HeaderPoint = index($$DATA, "RIFF", 0); $_ = substr($$DATA,$HeaderPoint + 8, 8); # AVI if(/^AVI LIST$/) { $Ext = 'avi'; } if($ContentType =~ /^video\//i) { $Infomation .= '(RIFF '. substr($$DATA, $HeaderPoint + 8, 4). ')'; } } elsif($$DATA =~ /^PK/) { # ZIP Compress File $Ext = 'zip'; } elsif($$DATA =~ /^MSCF/) { # CAB Compress File $Ext = 'cab'; } elsif($$DATA =~ /^Rar\!/) { # RAR Compress File $Ext = 'rar'; } elsif(substr($$DATA, 2, 5) =~ /^\-lh(\d+|d)\-$/) { # LHA Compress File $Infomation .= "(lh$1)"; $Ext = 'lzh'; } elsif(substr($$DATA, 325, 25) eq "Apple Video Media Handler" || substr($$DATA, 325, 30) eq "Apple \x83\x72\x83\x66\x83\x49\x81\x45\x83\x81\x83\x66\x83\x42\x83\x41\x83\x6E\x83\x93\x83\x68\x83\x89") { # QuickTime $Ext = 'mov'; } } # Header analysis failure unless ($Ext) { # It will be followed if it applies for the MIME type from the browser. foreach (keys %UPLOAD_CONTENT_TYPE_LIST) { next unless ($_); if($ContentType =~ /^$_$/i) { $Ext = $UPLOAD_CONTENT_TYPE_LIST{$_}; $ContentName = &CheckContentExt($Ext); if( grep {$_ eq $Ext;} ( 'png', 'gif', 'jpg', 'xbm', 'tif', 'bmp', 'pdf', 'swf', 'mov', 'zip', 'cab', 'lzh', 'rar', 'mid', 'rmi', 'au', 'wav', 'avi', 'exe' ) ) { $Infomation .= ' / Header analysis failure'; } if($Ext ne $FileExt && &CheckContentExt($FileExt) eq $ContentName) { $Ext = $FileExt; } last; } } # a MIME type is unknown--It judges from an extension. unless ($Ext) { $ContentName = &CheckContentExt($FileExt); if($ContentName) { $Ext = $FileExt; $Infomation .= ' / MIME type is unknown('. $ContentType. ')'; last; } } } # $ContentName = &CheckContentExt($Ext) unless($ContentName); # if($Ext && $ContentName) { # $ContentName .= $Infomation; # } else { # &upload_error( # 'Extension Error', # "$FileName A not corresponding extension ($Ext)<BR>The extension which can be responded ". join(',', sort values(%UPLOAD_EXT_LIST)) # ); # } # # SSI Tag Deletion # if($Ext =~ /.?html?/ && $$DATA =~ /<\!/) { # foreach ( # 'config', # 'echo', # 'exec', # 'flastmod', # 'fsize', # 'include' # ) { # $$DATA =~ s/\#\s*$_/\&\#35\;$_/ig # } # } return ( $FileName, $Ext, int($DataLength / 1024 + 1), $ImageWidth, $ImageHeight, $ContentName ); } ############################################################################## # Summary # # Extension discernment # # Parameters # Returns # Memo ############################################################################## sub CheckContentExt { my($Ext) = @_; my $ContentName; foreach (keys %UPLOAD_EXT_LIST) { next unless ($_); if($_ && $Ext =~ /^$_$/) { $ContentName = $UPLOAD_EXT_LIST{$_}; last; } } return $ContentName; } ############################################################################## # Summary # # Form decode # # Parameters # Returns # Memo ############################################################################## sub Encode { my($value,$Trans) = @_; # my $FormCode = &jcode::getcode($value) || $FormCodeDefault; # $FormCodeDefault ||= $FormCode; # # if($Trans && $TRANS_2BYTE_CODE) { # if($FormCode ne 'euc') { # &jcode::convert($value, 'euc', $FormCode); # } # &jcode::tr( # $value, # "\xA3\xB0-\xA3\xB9\xA3\xC1-\xA3\xDA\xA3\xE1-\xA3\xFA", # '0-9A-Za-z' # ); # if($CHARCODE ne 'euc') { # &jcode::convert($value,$CHARCODE,'euc'); # } # } else { # if($CHARCODE ne $FormCode) { # &jcode::convert($value,$CHARCODE,$FormCode); # } # } # if($CHARCODE eq 'euc') { # &jcode::h2z_euc($value); # } elsif($CHARCODE eq 'sjis') { # &jcode::h2z_sjis($value); # } } ############################################################################## # Summary # # Error Msg # # Parameters # Returns # Memo ############################################################################## sub upload_error { local($error_message) = $_[0]; local($error_message2) = $_[1]; print "Content-type: text/html\n\n"; print<<EOF; <HTML> <HEAD> <TITLE>Error Message</TITLE></HEAD> <BODY> <table border="1" cellspacing="10" cellpadding="10"> <TR bgcolor="#0000B0"> <TD bgcolor="#0000B0" NOWRAP><font size="-1" color="white"><B>Error Message</B></font></TD> </TR> </table> <UL> <H4> $error_message </H4> $error_message2 <BR> </UL> </BODY> </HTML> EOF &rm_tmp_uploaded_files; # Image Temporary deletion exit; } ############################################################################## # Summary # # Image Temporary deletion # # Parameters # Returns # Memo ############################################################################## sub rm_tmp_uploaded_files { if($img_data_exists == 1){ sleep 1; foreach $fname_list(@NEWFNAMES) { if(-e "$img_dir/$fname_list") { unlink("$img_dir/$fname_list"); } } } } 1; --- NEW FILE: util.pl --- ##### # FCKeditor - The text editor for internet # Copyright (C) 2003-2004 Frederico Caldeira Knabben # # Licensed under the terms of the GNU Lesser General Public License: # http://www.opensource.org/licenses/lgpl-license.php # # For further information visit: # http://www.fckeditor.net/ # # File Name: util.pl # This is the File Manager Connector for Perl. # # Version: 2.0 RC3 # Modified: 2005-02-28 17:06:13 # # File Authors: # Takashi Yamaguchi (ja...@om...) ##### sub RemoveFromStart { local($sourceString, $charToRemove) = @_; $sPattern = '^' . $charToRemove . '+' ; $sourceString =~ s/^$charToRemove+//g; return $sourceString; } sub RemoveFromEnd { local($sourceString, $charToRemove) = @_; $sPattern = $charToRemove . '+$' ; $sourceString =~ s/$charToRemove+$//g; return $sourceString; } sub ConvertToXmlAttribute { local($value) = @_; return $value; # return utf8_encode(htmlspecialchars($value)); } 1; --- NEW FILE: io.pl --- ##### # FCKeditor - The text editor for internet # Copyright (C) 2003-2004 Frederico Caldeira Knabben # # Licensed under the terms of the GNU Lesser General Public License: # http://www.opensource.org/licenses/lgpl-license.php # # For further information visit: # http://www.fckeditor.net/ # # File Name: io.pl # This is the File Manager Connector for Perl. # # Version: 2.0 RC3 # Modified: 2005-02-28 17:06:00 # # File Authors: # Takashi Yamaguchi (ja...@om...) ##### sub GetUrlFromPath { local($resourceType, $folderPath) = @_; if($resourceType eq '') { $rmpath = &RemoveFromEnd($GLOBALS{'UserFilesPath'},'/'); return("$rmpath$folderPath"); } else { return("$GLOBALS{'UserFilesPath'}$resourceType$folderPath"); } } sub RemoveExtension { local($fileName) = @_; local($path, $base, $ext); if($fileName !~ /\./) { $fileName .= '.'; } if($fileName =~ /([^\\\/]*)\.(.*)$/) { $base = $1; $ext = $2; if($fileName =~ /(.*)$base\.$ext$/) { $path = $1; } } return($path,$base,$ext); } sub ServerMapFolder { local($resourceType,$folderPath) = @_; # Get the resource type directory. $sResourceTypePath = $GLOBALS{'UserFilesDirectory'} . $resourceType . '/'; # Ensure that the directory exists. &CreateServerFolder($sResourceTypePath); # Return the resource type directory combined with the required path. $rmpath = &RemoveFromStart($folderPath,'/'); return("$sResourceTypePath$rmpath"); } sub GetParentFolder { local($folderPath) = @_; $folderPath =~ s/[\/][^\/]+[\/]?$//g; return $folderPath; } sub CreateServerFolder { local($folderPath) = @_; $sParent = &GetParentFolder($folderPath); # Check if the parent exists, or create it. if(!(-e $sParent)) { $sErrorMsg = &CreateServerFolder($sParent); if($sErrorMsg == 1) { return(1); } } if(!(-e $folderPath)) { umask(000); mkdir("$folderPath",0777); chmod(0777,"$folderPath"); return(0); } else { return(1); } } sub GetRootPath { #use Cwd; # my $dir = getcwd; # print $dir; # $dir =~ s/$ENV{'DOCUMENT_ROOT'}//g; # print $dir; # return($dir); # $wk = $0; # $wk =~ s/\/connector\.cgi//g; # if($wk) { # $current_dir = $wk; # } else { # $current_dir = `pwd`; # } # return($current_dir); use Cwd; if($ENV{'DOCUMENT_ROOT'}) { $dir = $ENV{'DOCUMENT_ROOT'}; } else { my $dir = getcwd; $workdir =~ s/\/connector\.cgi//g; $dir =~ s/$workdir//g; } return($dir); } 1; --- NEW FILE: basexml.pl --- ##### # FCKeditor - The text editor for internet # Copyright (C) 2003-2004 Frederico Caldeira Knabben # # Licensed under the terms of the GNU Lesser General Public License: # http://www.opensource.org/licenses/lgpl-license.php # # For further information visit: # http://www.fckeditor.net/ # # File Name: basexml.pl # This is the File Manager Connector for Perl. # # Version: 2.0 RC3 # Modified: 2005-02-28 17:06:22 # # File Authors: # Takashi Yamaguchi (ja...@om...) ##### sub CreateXmlHeader { local($command,$resourceType,$currentFolder) = @_; # Create the XML document header. print '<?xml version="1.0" encoding="utf-8" ?>'; # Create the main "Connector" node. print '<Connector command="' . $command . '" resourceType="' . $resourceType . '">'; # Add the current folder node. print '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute(GetUrlFromPath($resourceType,$currentFolder)) . '" />'; } sub CreateXmlFooter { print '</Connector>'; } 1; |