#!/usr/bin/perl use CGI qw/:html3 :standard/; use Fcntl qw/:flock/; # ################################################# # # # My Capcha # # # # Starting Date: April 20, 2017 # # Last Modified: May 21, 2017 # # # # Written by Troy Hammack # # Email: troylh@pacbell.net # # # ################################################# # # $ENV{"PATH"}=''; $ENV{"BASH_ENV"}=''; print "Content-type:text/html\n\n"; if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { print "Content-type: text/html\n\n"; print "
Use Post or Get";
}
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ 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;
$value =~s///g;
if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
#
# Test to see if Reset button was selected and clear all values in the keys
#
if ($formdata{'reset'} eq "Reset") {
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$formdata{$key} = "";
}
}
#
# The answer < -- If I use this it doesn't work!
#
my @chars = ("A".."Z", "a".."z");
my $answer;
$answer .= $chars[rand @chars] for 0..4;
#
# $answer = "ghRuE"; <-- If I use this it works fine.
#
print <