upload_fck.pl
资源名称:MEIMS.rar [点击查看]
上传用户:ah_jiwei
上传日期:2022-07-24
资源大小:54044k
文件大小:18k
源码类别:
数据库编程
开发平台:
Visual C++
- #####
- # FCKeditor - The text editor for Internet - http://www.fckeditor.net
- # Copyright (C) 2003-2007 Frederico Caldeira Knabben
- #
- # == BEGIN LICENSE ==
- #
- # Licensed under the terms of any of the following licenses at your
- # choice:
- #
- # - GNU General Public License Version 2 or later (the "GPL")
- # http://www.gnu.org/licenses/gpl.html
- #
- # - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
- # http://www.gnu.org/licenses/lgpl.html
- #
- # - Mozilla Public License Version 1.1 or later (the "MPL")
- # http://www.mozilla.org/MPL/MPL-1.1.html
- #
- # == END LICENSE ==
- #
- # This is the File Manager Connector for Perl.
- #####
- # 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/x0Dx0A//;
- $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 .= $_;
- };
- $lastline = $_;
- $value =~s /x0Dx0A$//;
- 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,"$FileNamet$Extt$Lengtht$ImageWidtht$ImageHeightt$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} .= "