| cgi password scripting problem on godaddy I have used this script successfully on another server, but get a server error pertaining to the path when I run it on my godaddy linux hosted site. It is preceded by an html page where the "test" password is entered. BTW - the folks at godaddy won't help me. But they do say it's OK to have the CGI file in the root directory (it doesn't have to reside in a folder called CGI or CGI-BIN).
Here's the code - the url's have been changed to something generic:
#!/usr/local/bin/perl
################################################## #########################
# Password Protection # Version 1.1 #
################################################## #########################
# FORM SETUP: #
# - The form can use both a GET and POST method. #
# - The input for the password must be named "pw". #
# - The input for the submit button can not have a name. #
# - There can be no other inputs inside the form. #
# EXAMPLE: #
# <FORM ACTION="password.cgi" METHOD="post"> #
# <INPUT NAME="pw" TYPE="password"> #
# <INPUT TYPE="submit"> #
# </FORM> #
################################################## #########################
# SCRIPT SETUP: #
# - This script must be uploaded in ASCII mode. #
# - The password is case insensitive. #
# - Your $page1 and $page2 pages must exist. #
# EXAMPLE: #
# $password = "the site rules"; #
# $page1 = "members_only.html"; #
# $page2 = "bad_password.html"; #
################################################## #########################
$password = "test";
$page1 = "http://www.abc.com/index.html";
$page2 = "http://www.abc/about.html";
################################################## #########################
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
($name, $value) = split(/=/, $buffer);
}
elsif ($ENV{'REQUEST_METHOD'} eq "GET") {
($name, $value) = split(/=/, $ENV{'QUERY_STRING'});
}
else {
print "Content-type:text/html\n\n";
print "The form method must be \"GET\" or \"POST\".";
exit;
}
$password =~ tr/[A-Z]/[a-z]/; # Delete these two lines if you want
$value =~ tr/[A-Z]/[a-z]/; # this script to be case sensitive.
$value =~ tr/+/ /;
$value =~ s/%([a-f0-9][a-f0-9])/pack("C", hex($1))/eg;
if ($value eq $password) {
print "Location: $page1\n\n";
}
else {
print "Location: $page2\n\n";
}
exit; |