Return to the main RetroCapture page.
Try another RetroCapture Lite image.
#!/usr/local/bin/perl -w
use CGI qw(:standard escapeHTML);
# the RetroCapture Lite command used to generate these images was:
# java -jar retrocapture.jar -d capture-demo -m capture-demo/capture.map 1000:lite
# load the mapping table
my $imageDir = 'capture-demo/';
my %map = ();
open MAP, $imageDir.'capture.map';
while (my $line = <MAP>) {
my ($passphrase, $imageFile, $imageStyle) = split(/\t/, $line);
my ($imageName) = ($imageFile =~ /\/(\w+)\.gif/);
$map{$imageName} = $passphrase;
}
close MAP;
# get the image and passphrase from the submitted form
my $imageName;
my $passphrase;
if (param()) {
$imageName = param('name');
$passphrase = uc(param('passphrase'));
} else {
# or select an image at random
my @imageNames = keys(%map);
$imageName = $imageNames[int(rand(scalar(@imageNames)))];
$passphrase = $map{$imageName};
}
# print the form
my $correct = $passphrase eq $map{$imageName};
print header, start_html('A simple RetroCapture Lite form');
if (param() && !$correct) {
print h1('Passphrase incorrect, access is denied to your web application.');
}
if (param() && $correct) {
print h1('Passphrase is correct, access is granted to your web application.');
} else {
print h2('Type the passphrase from the image and hit Submit'),
start_form,
img{src=>$imageDir.$imageName.'.gif'},
hidden('name', $imageName),
textfield('passphrase'),
submit,
end_form;
}
print p(a({href=>'capture-main.html'}, 'Return to the main RetroCapture page.')),
p(a({href=>'capture.cgi'}, 'Try another RetroCapture Lite image.'));
print h2('Here is the example Perl CGI source code:'),
'<code><pre>';
open CGI, 'capture.cgi';
while (my $line = <CGI>) {
$line = escapeHTML($line);
print $line;
}
close CGI;
print '</pre></code>';
print end_html;
1;