perlunity.de - PERL | JAVASCRIPT | PHP | MySQL | APACHE



#!/COMMUNITY

Members: 5310
davon online: 1
weitere User: 25
Click for quality!




10.09.2010 / 06:07

Community-Member werden   |   Paßwort vergessen   |   OnlineMonitor (1) Wer ist online ... OnlineMonitor starten !
     

 

Home


PERLscripts


PHPscripts


JAVAscripts


Hilfreiches


Links2www


Newscenter


Community


Interna




Community  »  CGI: Allgemeines Forum zur Themenübersicht Themensuche Themenansicht in Thread-Modus


BeitragBugfix eines cgi upload scriptes
Seitenanfang
Hallo,

ich suche gegen ein paar Euro Entgelt jemanden der die seite 'www.file-hopper.com' wieder zum upload anmieren kann.

Derzeit kommt im error.log:

Fri Jan 12 21:40:00 2007] [error] [client 82.100.219.2] Premature end of script headers: proc.cgi, referer: http://www.file-hopper.com/

----
conf.cgi


$filetmppath="/var/www/vhosts/file-hopper.com/httpdocs/tmp";

$|=1;

$max_upload = 250000000; # set this to whatever you feel suitable for you.

$sleepthrottle = "0.070"; # set to manage upload throttle, lower number allows faster upload optimize for server

# do not edit below here

$post_data_file = "$filetmppath/$sessionid"."_postdata";
$monitor_file = "$filetmppath/$sessionid"."_flength";
$signal_file = "$filetmppath/$sessionid"."_signal";
$qstring_file = "$filetmppath/$sessionid"."_qstring";

1;


------------------
proc.cgi


#! /usr/bin/perl --

$thisdir=$ENV{'SCRIPT_URL'};
@allpath=split(/\//,$thisdir);
$thisdir=~s/$allpath[$#allpath]//;
$thisdir=~s/\/$//;
chdir("./$thisdir");

print "Content-type: text/html\n\n";

use CGI;
use Fcntl qw(:DEFAULT :flock);
use File::Temp qw/ tempfile tempdir /;
#use Carp;

@qstring=split(/&/,$ENV{'QUERY_STRING'});
@p1 = split(/=/,$qstring[0]);
$sessionid = $p1[1];
$sessionid =~ s/[^a-zA-Z0-9]//g;

require("./conf.cgi");

$content_type = $ENV{'CONTENT_TYPE'};
$len = $ENV{'CONTENT_LENGTH'};
$bRead=0;
$|=1;

if($len > $max_upload)
{
close (STDIN);
err("The maximum upload size has been exceeded");
}

if (-e "$post_data_file") {
unlink("$post_data_file");
}

if (-e "$monitor_file") {
unlink("$monitor_file");
}

sysopen(FH, $monitor_file, O_RDWR | O_CREAT)
or die "can't open numfile: $!";

$ofh = select(FH); $| = 1; select ($ofh);
flock(FH, LOCK_EX)
or die "can't write-lock numfile: $!";
seek(FH, 0, 0)
or die "can't rewind numfile : $!";
print FH $len;
close(FH);

sleep(1);

open(TMP,">","$post_data_file") or &err ("can't open temp file");

#print "$post_data_file";

my $i=0;

$ofh = select(TMP); $| = 1; select ($ofh);

while (read (STDIN ,$LINE, 4096) && $bRead < $len )

{
$bRead += length $LINE;

select(undef, undef, undef,$sleepthrottle);

$i++;
print TMP $LINE;

}

close (TMP);

open(STDIN,"$post_data_file") or die "can't open temp file";

my $cg = new CGI();
my $qstring="";
my %vars = $cg->Vars;
my $j=0;

while(($key,$value) = each %vars)
{

$file_upload = $cg->param($key);

if(defined $value && $value ne '')
{

my $fh = $cg->upload($key);
if(defined $fh)
{
#carp $fh;
($tmp_fh, $tmp_filename) = tempfile();

while(<$fh>) {
print $tmp_fh $_;
}

close($tmp_fh);

$fsize =(-s $fh);

$fh =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$tmp_filename =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$qstring .= "file[name][$j]=$fh&file[size][$j]=$fsize&";
$qstring .= "file[tmp_name][$j]=$tmp_filename&";
$j++;
}
else
{
$value =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$qstring .= "$key=$value&" ;
}
}
}

# print "$qstring";

open (SIGNAL,">", $signal_file);
print SIGNAL "\n";
close (SIGNAL);

open (QSTR,">", "$qstring_file") or die "can't open output file";
print QSTR $qstring;
close (QSTR);

sub err {
$mes = shift;
print "Content-type: text/html\n\n";
print "<br>$mes<br>\n";

exit;
}


-----------

Datum: 04.03.2007-10:40

-






-
-