Hi,
I'm new to CGI, so go easy on me... All I want to do is set a simple password on the admin.cgi - should be easy right? What am I doing wrong?
I initially found all the references to .htaccess files - so I learnt all bout them... eventually I worked out that the reason they weren't working was that my server doesn't support them... so I'm trying this.. but have fallen victim to what appears to be a rather odd paradox:
I am passing a password from an HTML form (using POST) to the admin.cgi script... it works, I know it does... I have this running perfectly:
#!/usr/local/bin/perl
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
#===============================
if ($FORM{pwd} eq 'mrpants') {
print "Content-type: text/html\n\n";
print "<br><br><H1><center>Correct Password</center></H1>";
}
else
{
print "Content-type: text/html\n\n";
print "<br><br><H1><center>Access Denied</center></H1>";
}
Now all I need to do is insert the original admin.cgi script into the bit which would display "Correct Password"... You'd think! Doing this results in the server locking up and the eventual return of a timed-out error.
However, if the original admin.cgi script is left in here and I comment out the
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
line, replacing it with a line which 'artificially' assigns the $buffer variable... all works fine... The best way to describe this seems to be that it's a paradox... what's going on here... it all seems a bit odd (and excruciatingly frustrating) to me.
Many thanks for any help you can offer!
I'm new to CGI, so go easy on me... All I want to do is set a simple password on the admin.cgi - should be easy right? What am I doing wrong?
I initially found all the references to .htaccess files - so I learnt all bout them... eventually I worked out that the reason they weren't working was that my server doesn't support them... so I'm trying this.. but have fallen victim to what appears to be a rather odd paradox:
I am passing a password from an HTML form (using POST) to the admin.cgi script... it works, I know it does... I have this running perfectly:
#!/usr/local/bin/perl
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
#===============================
if ($FORM{pwd} eq 'mrpants') {
print "Content-type: text/html\n\n";
print "<br><br><H1><center>Correct Password</center></H1>";
}
else
{
print "Content-type: text/html\n\n";
print "<br><br><H1><center>Access Denied</center></H1>";
}
Now all I need to do is insert the original admin.cgi script into the bit which would display "Correct Password"... You'd think! Doing this results in the server locking up and the eventual return of a timed-out error.
However, if the original admin.cgi script is left in here and I comment out the
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
line, replacing it with a line which 'artificially' assigns the $buffer variable... all works fine... The best way to describe this seems to be that it's a paradox... what's going on here... it all seems a bit odd (and excruciatingly frustrating) to me.
Many thanks for any help you can offer!