Koozali.org: home of the SME Server

CGI on SME

IceDizzy

CGI on SME
« on: January 07, 2006, 11:33:45 AM »
Problem: Want to upload demos from HLTV and WOW to my site.
Though PHP refuses to take larger files than 20M even if I tries to increase in /etc/php.ini or/and in /etc/e-smith/templates/etc/php.ini/60FileUploads
probably bacause i don,t know how the new value would get into effect or it maybe should be done in an other way.
I decided to test an simple CGI-script i thought...
Running SME 6.5
I think the line: print <<END_HTML; causes the error witout it i still dont get the file uploaded
The directory /myibay/html/downloads are chmodded to 777.

Is ther a friendly soul out ther with some help to teach me?

Regards:
The Noob with ideas /Ice.


==================================================
Error message in browser:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@kicks-ass.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

- I cant find anything as i understand related to this error in the log.

==================================================
Installed modules:
CGI -- 3.00
CGI::FormMagick -- 0.89
CGI::Persistent -- 0.22

==================================================

The html script:

<HTML>
 <HEAD></HEAD>
 <BODY>
 <FORM ACTION="/myibay/cgi-bin/test2.pl" METHOD="post" ENCTYPE="multipart/form-data">
 Photo to Upload: <INPUT TYPE="file" NAME="photo">
 <br><br>
 Your Email Address: <INPUT TYPE="text" NAME="email_address">
 <br><br>
 <INPUT TYPE="submit" NAME="Submit" VALUE="Submit Form">
 </FORM>
 </BODY>
</HTML>


==================================================

The perl script test2.pl:


#!/usr/bin/perl

use CGI;
$query = new CGI;
$upload_dir = "/myibay/html/downloads";
$filename = $query->param("photo");
$filename =~ s/.*[\/\\](.*)/$1/;
$email_address = $query->param("email_address");
$upload_filehandle = $query->upload("photo");
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
    print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;

==================================================

Offline kruhm

  • *
  • 680
  • +0/-0
CGI on SME
« Reply #1 on: January 08, 2006, 02:22:06 PM »
it looks like your paths are wrong.
../cgi-bin/test2.pl

IceDizzy

Something with the paths
« Reply #2 on: January 08, 2006, 03:49:40 PM »
All right you are, i've done some more tests and stripped it down a bit.

I want the script to run under the <my ibay>/cgi-bin but it only works from the primary/cgi-bin

Where do i configure wich cgi-bin to wich ibay?

Thanks for the tip it puted me on the right trac, things workes now but i would like ti store the script in the right place.
/files/big are stored in ibays/Primary/cgi-bin folder
/Ice

New stripped modified scripts below:

The demos.html script wich could be in primary or in the ibay:s html library and works any way.

<HTML>
 <HEAD></HEAD>
 <title>Micro:s game movies corner</title></head>
 <BODY>
 <FORM ACTION="/cgi-bin/test2.pl" METHOD="post" ENCTYPE="multipart/form-data">
 Demo to Upload: <INPUT TYPE="file" NAME="photo">
 <br><br>
  <INPUT TYPE="submit" NAME="Send your file" VALUE="Send your file">
 </FORM>
 </BODY>
</HTML>


And the script wich must be in the ibays/Primary/cgi-bin:

#!/usr/bin/perl

use CGI;
$query = new CGI;
$upload_dir = "./files/big";
$filename = $query->param("photo");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open UPLOADFILE, ">./files/big/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
    print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );

print "<html><head>\n";
print "<title>Micro:s game movies corner</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#800000\">\n";
print "<h1>Upload</h1>\n";
print "Thanks for sharing heroic moments in $filename";

print "</body></html>\n";