Click to See Complete Forum and Search --> : error>perl, permission or otherwise?


jane_262
09-23-2003, 08:00 PM
I'm writing a .pl script - basically, my first from scratch - designed to allow an html form to be processed, doesn't matter what it's supposed to process because I'm assuming that once it processes the first portion, it should display the user's INPUT and it doesnt even get that far. I've gotten free scripts to work, even after adding and deleting portions of it, so since they work, I've used some copy/paste/edit from there as well as from a detailed tutorial.

On Submit, result is Error 403, not authorized, however, the permissions for the file are set to 777.

##This one was supposed to display first, then write to .db, also at 777
#!/usr/bin/perl
require "/.../cgi-bin/config.pl";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
else { $INPUT{$name} = $value; }
$value =~ s/<!--(.|\n)*-->//g;
}
$cgiurl = $ENV{'SCRIPT_NAME'};
if ($INPUT{'process'}) { &sorder; }
else {&sorder;}##verifies required fields

print "Content-type: text/html\n\n";
&header;
print <<EOF;
<FORM ACTION="$cgiurl" METHOD="POST">
... ##$INPUT{'process'} at end of $INPUT display

##This one was supposed to write to the .db first, then display
#!/usr/bin/perl
require "/.../cgi-bin/config.pl";

read(STDIN, $buffer, ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
else { $INPUT{$name} = $value; }
$value =~ s/<!--(.|\n)*-->//g;
}

$cgiurl = $ENV{'SCRIPT_NAME'};
open (DAT2, ">>$orderinfo/orders.db");
if ($LOCK_EX) {
flock(DAT, $LOCK_EX);
}
foreach $item(%INPUT) {
@edit_array = split(/\:/,$item);
$edit_array[0] = $INPUT{'username'} if $INPUT{'username'};
... ##the username probably exists, but at this point, this script just needs to work whether it is an authorized user or not - I intend to continue troubleshooting my .htaccess problem with the login later.


I include only the beginning of the files because I believe that may be where the problem lies.

It all looks fine to me based on what I've seen and read, but I only have one set of inexperienced and tired eyes.

If I only think I understand and I really don't I'm trusting you complete strangers to set me straight and become a friend.

If I'm really right, yeah, but then the problem lies in how I'm dealing with select fields.

Much obliged.

Jeff Mott
09-24-2003, 10:51 AM
Your problem is probably in your require statement. Note that a leading slash means root directory, which your server may have denied you access.

I'd also note that parts of the code have bad programming practices or is buggy (e.g., the input variable parser). And so I don't have much faith in whatever tutorial you are currently using. For *real* information in Perl programming see http://learn.perl.org/library/beginning_perl/.

jane_262
09-24-2003, 03:36 PM
Thanks, Jeff. I'll check out Simon Cozen's Perl lessons. I appreciate your reply.