Page 1 of 2

Mega upload in Xampp winxp

PostPosted: 01. October 2006 11:33
by Moki
hey.. why can't i get my xampp to work whit mega upload 1.45
on this site http://uzivo.com/megaupload/php/upload.php

the code is from http://www.raditha.com/megaupload/

how can i get this to work..
tanks
Moki

PostPosted: 01. October 2006 11:41
by Wiedmann
What is the problem? (error message, error_log...)

BTW:
They have their own support forum.

PostPosted: 01. October 2006 11:56
by Moki
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404
uzivo.com
09/26/54 21:35:55
Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6

PostPosted: 01. October 2006 12:06
by Wiedmann
And this error happens after submitting the upload form, or if you want access this script?

PostPosted: 01. October 2006 12:14
by Moki
after iwanna upload.. a file

PostPosted: 01. October 2006 12:20
by Wiedmann
OK, after the click on submit.

In this case a setting in the config file is wrong (if there is any config) or the script has a bug:
When the script output the upload form (1st access), the script writes a wrong action attribute to the html form tag.

PostPosted: 01. October 2006 12:29
by Moki
hm.. see here alle the files.. i don't know why it dos that..
http://uzivo.com/megaupload/txtphp/

it not gooo

PostPosted: 01. October 2006 12:36
by Wiedmann
hm.. see here alle the files.. i don't know why it dos that..

That's "correct". There are no PHP or HTML files. Only textfiles. And so you get a directory listing from Apache.

(Why have all files a ".txt" as extension?)

PostPosted: 01. October 2006 12:40
by Moki
nooo that too you too see in the files...
here is the real site name.
http://uzivo.com/megaupload/php/

PostPosted: 01. October 2006 13:20
by Wiedmann
ah, now.

The target from the form action is the file "/cgi-bin/upload.cgi". You must move the CGIs to the cgi-bin from XAMPP. (see the megaupload install instructions)

BTW:
In which language is the cgi script?

PostPosted: 01. October 2006 13:24
by Moki
hm i have install xampp in danish..... so it danish i think..

PostPosted: 01. October 2006 13:27
by Wiedmann
I mean:
PHP, Perl, Phyton, Ruby, Bash...

PostPosted: 01. October 2006 15:20
by Izzy
This is the content of the upload.cgi in the cgi-bin in the link you posted.
It is not a cgi script only an error message and it is what is being returned when clicking on the upload button in the upload.php file.
Code: Select all
<form  enctype="multipart/form-data" action="/cgi-bin/upload.cgi?sid=1905a17deb2e4a8fccd909027cf73d15" method="post">


Where is the real upload.cgi script?

The code of the upload.cgi:
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Server error!</title>
<link rev="made" href="mailto:mokigorila@hotmail.com" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
    body { color: #000000; background-color: #FFFFFF; }
    a:link { color: #0000CC; }
    p, address {margin-left: 3em;}
    span {font-size: smaller;}
/*]]>*/--></style>
</head>

<body>
<h1>Server error!</h1>
<p>


 

    The server encountered an internal error and was
    unable to complete your request.

    </p>
<p>


    Error message:
    <br />couldn't create child process: 720003: upload.cgi

 

</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:mokigorila@hotmail.com">webmaster</a>.

</p>

<h2>Error 500</h2>
<address>
  <a href="/">uzivo.com</a><br />
 
  <span>09/27/54 00:44:40<br />
  Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6</span>
</address>
</body>
</html>

The content of the progress.cgi is the same as the above upload.cgi

This is what the real upload.cgi looks like and will work if you replace the one you have in the links above you provided.
Code: Select all
#!/usr/local/bin/perl -w

# PHP File Uploader with progress bar Version 1.43
# Copyright (C) Raditha Dissanyake 2003
# http://www.raditha.com

# Licence:
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under this License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Initial Developer of the Original Code is Raditha Dissanayake.
# Portions created by Raditha are Copyright (C) 2003
# Raditha Dissanayake. All Rights Reserved.
#

# CHANGES:
# As of version 1.00 cookies were abolished!
# as of version 1.02 stdin is no longer set to non blocking.
# 1.40 - POST is no longer required and processing is more efficient.
#   Please refer online docs  for details.
# 1.42 - The temporary locations were changed, to make it easier to
#   clean up afterwards.   
# 1.45.
#   Changed the way in which the file list is passed to the php handler

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;  # sanitized as suggested by Terrence Johnson.


require("./header.cgi");



#carp "$post_data_file and $monitor_file";



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

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

   exit;
}


# see if we are within the allowed limit.

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


#
# The thing to watch out for is file locking. Only
# one thread may open a file for writing at any given time.
#

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: $!";

# autoflush FH
$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 &bye_bye ("can't open temp file");
 

#
# read and store the raw post data on a temporary file so that we can
# pass it though to a CGI instance later on.
#



my $i=0;

$ofh = select(TMP); $| = 1; select ($ofh);
         
while (read (STDIN ,$LINE, 4096) && $bRead < $len )
{
   $bRead += length $LINE;
   
   select(undef, undef, undef,0.35);   # sleep for 0.35 of a second.
   
   # Many thanx to Patrick Knoell who came up with the optimized value for
   # the duration of the sleep

   $i++;
   print TMP $LINE;
}

close (TMP);


#
# We don't want to decode the post data ourselves. That's like
# reinventing the wheel. If we handle the post data with the perl
# CGI module that means the PHP script does not get access to the
# files, but there is a way around this.
#
# We can ask the CGI module to save the files, then we can pass
# these filenames to the PHP script. In other words instead of
# giving the raw post data (which contains the 'bodies' of the
# files), we just send a list of file names.
#

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&" ;
      }
   }
}


my $url = $php_uploader . "?sid=$sessionid";


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);


print "Location: $url\n\n";

The language of the script is perl.

You will have to change this line at the top of all .cgi scripts to the path of your own perl.exe
Code: Select all
#!/usr/local/bin/perl -w

like this
Code: Select all
#!C:\xampp\perl\bin\perl.exe -w
or what ever your path to perl.exe is

PostPosted: 01. October 2006 20:00
by Moki
here is a zip file whit all the files.. you can cange them.. and send them to me ..
http://uzivo.com/megaupload/megaupload.zip


OKAY...
in the upload.php i have made this change
<form enctype="multipart/form-data" action="/cgi-bin/upload.cgi?sid=1905a17deb2e4a8fccd909027cf73d15" method="post">



in progress.cgi i have change it to this
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Server error!</title>
<link rev="made" href="mailto:mokigorila@hotmail.com" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
body { color: #000000; background-color: #FFFFFF; }
a:link { color: #0000CC; }
p, address {margin-left: 3em;}
span {font-size: smaller;}
/*]]>*/--></style>
</head>

<body>
<h1>Server error!</h1>
<p>




The server encountered an internal error and was
unable to complete your request.

</p>
<p>


Error message:
<br />couldn't create child process: 720003: upload.cgi



</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:mokigorila@hotmail.com">webmaster</a>.

</p>

<h2>Error 500</h2>
<address>
<a href="/">uzivo.com</a><br />

<span>09/27/54 00:44:40<br />
Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6</span>
</address>
</body>
</html>


this is the upload.cgi

#!C:\program\xampp\perl\bin\perl.exe -w

# PHP File Uploader with progress bar Version 1.43
# Copyright (C) Raditha Dissanyake 2003
# http://www.raditha.com

# Licence:
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under this License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Initial Developer of the Original Code is Raditha Dissanayake.
# Portions created by Raditha are Copyright (C) 2003
# Raditha Dissanayake. All Rights Reserved.
#

# CHANGES:
# As of version 1.00 cookies were abolished!
# as of version 1.02 stdin is no longer set to non blocking.
# 1.40 - POST is no longer required and processing is more efficient.
# Please refer online docs for details.
# 1.42 - The temporary locations were changed, to make it easier to
# clean up afterwards.
# 1.45.
# Changed the way in which the file list is passed to the php handler

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; # sanitized as suggested by Terrence Johnson.


require("./header.cgi");



#carp "$post_data_file and $monitor_file";



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

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

exit;
}


# see if we are within the allowed limit.

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


#
# The thing to watch out for is file locking. Only
# one thread may open a file for writing at any given time.
#

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: $!";

# autoflush FH
$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 &bye_bye ("can't open temp file");


#
# read and store the raw post data on a temporary file so that we can
# pass it though to a CGI instance later on.
#



my $i=0;

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

while (read (STDIN ,$LINE, 4096) && $bRead < $len )
{
$bRead += length $LINE;

select(undef, undef, undef,0.35); # sleep for 0.35 of a second.

# Many thanx to Patrick Knoell who came up with the optimized value for
# the duration of the sleep

$i++;
print TMP $LINE;
}

close (TMP);


#
# We don't want to decode the post data ourselves. That's like
# reinventing the wheel. If we handle the post data with the perl
# CGI module that means the PHP script does not get access to the
# files, but there is a way around this.
#
# We can ask the CGI module to save the files, then we can pass
# these filenames to the PHP script. In other words instead of
# giving the raw post data (which contains the 'bodies' of the
# files), we just send a list of file names.
#

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&" ;
}
}
}


my $url = $php_uploader . "?sid=$sessionid";


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);


print "Location: $url\n\n";

PostPosted: 01. October 2006 20:11
by Wiedmann
in the upload.php i have made this change

Why?

in progress.cgi i have change it to this

Why?

I have had only two simple questions in my last post...
a) have you moved the CGIs to the XAMPP cgi-bin directory?
b) the scripting language of the CGI.

Well, b) is answered. It's Perl. With Perl there a two additional questions:
c) what is the shebang
d) have you installed the XAMPP Perl AddOn or another Perl?

Well, c) is answered. Your shebang is:
#!C:\program\xampp\perl\bin\perl.exe -w

I think this is correct. Just look with your Explorer if this path is valid.

After all, two questions (a and d) are still open...