if($demo_mode){
print "Content-type: text/html\n\n";
print qq~
~;
}else{
use CGI;
&check_cookie;
&check_login;
open(TL,"$path_to_lang/$thislang/upload_file.txt");
while(){push(@LaNg,$_)}
&exec_lang;
$imagesizeKB = $imagesize*1000;
if ($^O =~ /MSWin32/i){
$temp = $ENV{'TEMP'} || $ENV{'TMP'} || $ENV{'WINDIR'};
if($temp =~ /Temp/i){
$TempFile::TMPDIRECTORY="$temp";
}else{
$temp=$temp."/Temp";
if(-e $temp){
$TempFile::TMPDIRECTORY="$temp";
}else{
$tmp="$path_to_domain/Temp";
mkdir($tmp,0755);
$TempFile::TMPDIRECTORY="$tmp";
}
}
}
$tmp="$path_to_domain/Temp";
#mkdir($tmp,0755);
#$TempFile::TMPDIRECTORY="$tmp";
my $cgi = new CGI;
my $file = $cgi->param('upload');
my $dir = $cgi->param('folder');
my $conv = $cgi->param('convert');
my $file_type = $cgi->param('file_type');
if (!$file) {&no_file}
$file =~ m!([^/:\\]*)$!; #capture file name
$short_name = $1;
$short_name=~m!\.(\w+)$!;$ext=$1;
if($file_type eq "binary"){if("@allowable_binary_extensions" !~ /$ext/i){alert("$ext $ini_text3")}}
if($file_type eq "ascii"){if("@allowable_ascii_extensions" !~ /$ext/i){alert("$ext $ini_text4")}}
$file_name = $dir.$short_name;
open (SAVE,">$file_name") || &cannotopen ;
binmode SAVE if $^O eq 'MSWin32';
while ($size = read($file,$data,1024)) {
print SAVE $data;
$total_size += $size;
}
close SAVE;
if ($total_size > 0) {} else{unlink($file_name);alert("$ini_text5")}
if($image_magick_check && $conv eq "yes"){&convertit}
if($image_magick_check && $max_img_size ne '' && $short_name =~ /jpg|jpe|jpeg|png$/){&resizeit}
if($imagesize ne "" && $short_name =~ /jpg|jpe|jpeg|png|gif$/ ){if($total_size > $imagesizeKB){unlink($file_name);$TS=$total_size/1000;$TS=sprintf("%1.2f",$TS);
alert("$ini_text6 $TS KB $ini_text7 $imagesize KB");
}}
if($usermb =~ /\d+/){
@sz=stat($file_name);
$SZ=$sz[7];
$szz=$SZ/100000;
$szz=sprintf("%1.2f",$szz);
&allocation;
$reMB=$uMB - $szz;
$aMB=$usermb-$uMB;
$aMB=sprintf("%1.2f",$aMB);
if($uMB > $usermb){
unlink($file_name);
$xMB=$uMB-$usermb;
$xMB=sprintf("%1.2f",$xMB);
$TS=sprintf("%1.2f",$total_size/100000);
$UMB=$uMB-$TS;
alert("$ini_text8 $TS - $ini_text9 $usermb $ini_text10 $xMB $ini_text11 $UMB $ini_text12 $usermb $ini_text13.");
}
$MB=qq~if(top.document.getElementById("MB_note")){top.document.getElementById("MB_note").innerHTML="($uMB $com_mb1 - $aMB $com_mb2 - $NuM $com_mb3)"}~;
}
chmod(0644,$file_name);
if($tmp){$tmp_fldr="$path_to_domain/Temp";opendir(TMPDIR,"$tmp_fldr");@tmp=readdir(TMPDIR);foreach $t (@tmp){if($t !~ /\.$/){$tmpfile=$tmp_fldr."/".$t;unlink($tmpfile)}}}
$file_name=~s!$path_to_domain!http://$host!;
if($xfile_name){unlink($xfile_name)}
print "Content-type: text/html\n\n";
print qq~
~;
}#else demo
sub resizeit{
if($file_name !~ /gif$/){
($ww,$hh)=split(/x/,$max_img_size);
use Image::Size;
($w, $h) = imgsize("$file_name");
if($w > $ww){
$W=$ww;
$wratio=$ww/$w;
$H=$h*$wratio;
}else{$H=$h;$W=$w}
if($H > $hh){
$hratio=$hh/$H;
$W=$W*$hratio;
$H=$hh;
}
if($w > $ww || $h > $hh){
$wh=$W."x".$H;
$img = Image::Magick->new;
$img -> Read ($file_name);
$img -> Resize($wh);
$img -> Write($file_name);
}
}
}##resizeit
sub convertit{
$nu_file_name=$file_name;$nu_file_name=~ s`bmp$`jpg`i;
$short_name=~s`bmp$`jpg`i;
$img = Image::Magick->new;
$img -> Read ($file_name);
$img -> Write($nu_file_name);
$xfile_name=$file_name;
$file_name=$nu_file_name;
@stat=stat($file_name);
$total_size=$stat[7];
}#convertit
sub cannotopen{
print "Content-type: text/html\n\n";
print qq~~;
exit
}#cannotopen
1;