Captcha-reCAPTCHA-0.97/000755 000765 000765 00000000000 12041330055 014655 5ustar00phredphred000000 000000 Captcha-reCAPTCHA-0.97/Changes000644 000765 000765 00000003540 12041327765 016170 0ustar00phredphred000000 000000 Revision history for Captcha-reCAPTCHA 0.1 2007-05-25 Initial release. 0.2 2007-05-25 Added t/20.check_answer.t, minor doc fixes. 0.3 2007-05-26 Minor doc fixes 0.4 2007-05-26 Made LWP::UserAgent creation lazy Added Mailhide support 0.5 2007-05-27 Added better validation for keys to provide helpful diagnostics in the case where the wrong key is used. Improved test coverage. Added support for generation of RecaptchaOptions options hash. 0.6 2007-05-29 Remove key validation code: keys may change format in the future. Switched server error code to 'recaptcha-not-reachable' 0.7 2007-05-31 Switched to HTML::Tiny for markup generation. Split Captcha::reCAPTCHA::Mailhide into a separate module 0.8 2007-11-01 s/incorrect-challenge-sol/incorrect-captcha-sol/g #29693 Thanks to William Campbell for finding it. 0.9 2007-11-01 Code unchanged. Version bump because I packaged the last version with Leopard's tar - which likes to add Apple specific extended attrs. Grrr. 0.91 2007-11-07 Ditched use of version.pm. Sick of version number confusion. 0.92 2007-11-19 Split Captcha::reCAPTCHA::Mailhide into a separate distro so we don't have to depend on Crypt::Rijndael. 0.93 2010-07-03 Updated Perl plugin to use Google infrastructure. 0.94 2010-07-03 Updated Perl plugin to use Google infrastructure. 0.95 2012-08-05 RT 60940 https://rt.cpan.org/Ticket/Display.html?id=60940 0.96 2012-09-28 RT 70525 https://rt.cpan.org/Ticket/Display.html?id=70525 0.97 2012-10-22 RT 80326 https://rt.cpan.org/Ticket/Display.html?id=80326 Thanks to Bill Moseley (HANK) for the spot Captcha-reCAPTCHA-0.97/examples/000755 000765 000765 00000000000 12041330054 016472 5ustar00phredphred000000 000000 Captcha-reCAPTCHA-0.97/lib/000755 000765 000765 00000000000 12041330054 015422 5ustar00phredphred000000 000000 Captcha-reCAPTCHA-0.97/Makefile.PL000644 000765 000765 00000001230 10720312516 016627 0ustar00phredphred000000 000000 use strict; use warnings; use ExtUtils::MakeMaker; eval 'use ExtUtils::MakeMaker::Coverage'; WriteMakefile( ( MM->can( 'signature_target' ) ? ( SIGN => 1 ) : () ), NAME => 'Captcha::reCAPTCHA', AUTHOR => 'Andy Armstrong ', LICENSE => 'perl', VERSION_FROM => 'lib/Captcha/reCAPTCHA.pm', ABSTRACT_FROM => 'lib/Captcha/reCAPTCHA.pm', PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'LWP::UserAgent' => 0, 'HTML::Tiny' => '0.904', }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Captcha-reCAPTCHA-*' }, ); Captcha-reCAPTCHA-0.97/MANIFEST000644 000765 000765 00000000636 12041330055 016013 0ustar00phredphred000000 000000 Changes examples/captcha.pl lib/Captcha/reCAPTCHA.pm Makefile.PL MANIFEST README t/00.load.t t/10.get_html.t t/20.check_answer.t t/40.errors.t t/pod-coverage.t t/pod.t META.yml Module meta-data (added by MakeMaker) SIGNATURE Public-key signature (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Captcha-reCAPTCHA-0.97/META.json000644 000765 000765 00000001711 12041330055 016276 0ustar00phredphred000000 000000 { "abstract" : "A Perl implementation of the reCAPTCHA API", "author" : [ "Andy Armstrong " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Captcha-reCAPTCHA", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "HTML::Tiny" : "0.904", "LWP::UserAgent" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "version" : "0.97" } Captcha-reCAPTCHA-0.97/META.yml000644 000765 000765 00000001045 12041330054 016125 0ustar00phredphred000000 000000 --- abstract: 'A Perl implementation of the reCAPTCHA API' author: - 'Andy Armstrong ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Captcha-reCAPTCHA no_index: directory: - t - inc requires: HTML::Tiny: 0.904 LWP::UserAgent: 0 Test::More: 0 version: 0.97 Captcha-reCAPTCHA-0.97/README000644 000765 000765 00000000563 11413637433 015555 0ustar00phredphred000000 000000 Captcha-reCAPTCHA version 0.93 INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install DEPENDENCIES LWP::UserAgent HTML::Tiny COPYRIGHT AND LICENCE Copyright (C) 2007, Andy Armstrong This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Captcha-reCAPTCHA-0.97/SIGNATURE000644 000765 000765 00000003504 12041330055 016143 0ustar00phredphred000000 000000 This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.68. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 162b89b34d2ac431f3cf066d263edf7c323ba032 Changes SHA1 1f363e33489a19797f1c090eb00ee527ce74f467 MANIFEST SHA1 42ada803c572b410fb25140c13cf5cd3f1effe92 META.json SHA1 d99973b9d083a496e8afbaf6de5b474cb24f82e9 META.yml SHA1 334033f6e4a65e1d87f8e07d810416b7dad3457d Makefile.PL SHA1 51f95b312f1ec74f565588a929c5acb7fbbe0605 README SHA1 8698ba348a5fa7cb01cc99eda007d3500e45706c examples/captcha.pl SHA1 49971777eb6b2425d53b634c3a52cc9985ad1fe1 lib/Captcha/reCAPTCHA.pm SHA1 9f9bc14f8a6332889679c48a8c697a7fcea55a8a t/00.load.t SHA1 e4246491168fad2823ea2f199a42377d63454da5 t/10.get_html.t SHA1 d9bc53594200ef6c55d51622e4b6b2c1fbab080e t/20.check_answer.t SHA1 4d63f3b02bd00e1b7ad062c4f7f384bb71f6112a t/40.errors.t SHA1 aeaa691851a425f07ab6a8d4f825e2ad9d92b8ee t/pod-coverage.t SHA1 0190346d7072d458c8a10a45c19f86db641dcc48 t/pod.t -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.18 (Darwin) iQEcBAEBAgAGBQJQhbAtAAoJENYkdgqz5djj45gH/RegJ5XrazHvsjMS8nEHveQP jqnc3PVRNPtgAepRg2sbHO2wnWnUaaIH5hQ6FyJDK8h7y3lc2gM/+a91TYwu/97v VO+2QhBsvpqgw3r/CtTCTJYrG8TTQn8D38rVsMJc/D+zsT5+7mnRMaGbafhlQPJX XTjBWtduFxNkaBTqOkz/OUzYb4dQgE5/kmqW7a9jL8Z+jJGpOGW8u2Wdalr2BoSX fM4NV+MUdP1GREVBbArD3hQMKcxYFVoa8kdOMBWmaBGna3I84gV3yBRoDZs2Sab9 Bjz9h0+lu7PwUhReUQ4WZXaT9Nqv3Ec/lPEhCN3bVjkdxGLvKL53k77vPu+FDpQ= =gkP1 -----END PGP SIGNATURE----- Captcha-reCAPTCHA-0.97/t/000755 000765 000765 00000000000 12041330054 015117 5ustar00phredphred000000 000000 Captcha-reCAPTCHA-0.97/t/00.load.t000644 000765 000765 00000000214 11413637167 016457 0ustar00phredphred000000 000000 use Test::More tests => 1; BEGIN { use_ok( 'Captcha::reCAPTCHA' ); } diag( "Testing Captcha::reCAPTCHA $Captcha::reCAPTCHA::VERSION" ); Captcha-reCAPTCHA-0.97/t/10.get_html.t000644 000765 000765 00000007463 11413637170 017353 0ustar00phredphred000000 000000 use strict; use warnings; use Test::More; use Captcha::reCAPTCHA; # Looks real. Isn't. use constant PUBKEY => '6LdAAAkAwAAAFJj6ACG3Wlix_GuQJMNGjMQnw5UY'; my @schedule; BEGIN { my $pubkey = PUBKEY; @schedule = ( { name => 'Simple', args => [$pubkey], expect => qq{\n} . qq{\n} }, { name => 'Error', args => [ $pubkey, '<>' ], expect => qq{\n} . qq{\n} }, { name => 'Error in hash', args => [ $pubkey, { is_valid => 0, error => '<>' } ], expect => qq{\n} . qq{\n} }, { name => 'Secure', args => [ $pubkey, undef, 1 ], expect => qq{\n} . qq{\n} }, { name => 'Options', args => [ $pubkey, undef, 0, { theme => 'white', tabindex => 3 } ], expect => qq(\n) . qq{\n} . qq{\n} }, ); plan tests => 3 * @schedule; } for my $test ( @schedule ) { my $name = $test->{name}; ok my $captcha = Captcha::reCAPTCHA->new(), "$name: Created OK"; isa_ok $captcha, 'Captcha::reCAPTCHA'; my $args = $test->{args}; my $html = $captcha->get_html( @$args ); is $html, $test->{expect}, "$name: Generate HTML OK"; } Captcha-reCAPTCHA-0.97/t/20.check_answer.t000644 000765 000765 00000004557 12041327562 020205 0ustar00phredphred000000 000000 use strict; use warnings; use Test::More; use HTTP::Response; use Captcha::reCAPTCHA; use Data::Dumper; # Looks real. Isn't. use constant PRIVKEY => '6LdAAAkAwAAAix_GF6AMQnw5UCG3JjWluQJMNGjY'; my @schedule; BEGIN { # Looks real. Isn't. @schedule = ( { name => 'Simple correct', args => [ PRIVKEY, '192.168.0.1', '..challenge..', '..response..' ], response => "true\n", check_args => { privatekey => PRIVKEY, remoteip => '192.168.0.1', challenge => '..challenge..', response => '..response..' }, check_url => 'http://www.google.com/recaptcha/api/verify', expect => { is_valid => 1 }, }, { name => 'Simple incorrect', args => [ PRIVKEY, '192.168.0.1', '..challenge..', '..response..' ], response => "false\nincorrect-captcha-sol\n", check_args => { privatekey => PRIVKEY, remoteip => '192.168.0.1', challenge => '..challenge..', response => '..response..' }, check_url => 'http://www.google.com/recaptcha/api/verify', expect => { is_valid => 0, error => 'incorrect-captcha-sol' }, }, ); plan tests => 6 * @schedule; } package T::Captcha::reCAPTCHA; our @ISA = qw(Captcha::reCAPTCHA); use Captcha::reCAPTCHA; sub set_response { my $self = shift; my $response = shift; $self->{t_response} = $response; } sub _post_request { my $self = shift; my $url = shift; my $args = shift; # Just keep the args $self->{t_url} = $url; $self->{t_args} = $args; return HTTP::Response->new( 200, 'OK', [ 'Content-type' => 'text/plain' ], $self->{t_response} ); } sub get_url { shift->{t_url} } sub get_args { shift->{t_args} } package main; for my $test ( @schedule ) { my $name = $test->{name}; ok my $captcha = T::Captcha::reCAPTCHA->new(), "$name: Created OK"; isa_ok $captcha, 'Captcha::reCAPTCHA'; $captcha->set_response( $test->{response} ); ok my $resp = $captcha->check_answer( @{ $test->{args} } ), "$name: got response"; is $captcha->get_url, $test->{check_url}, "$name: URL OK"; is_deeply $captcha->get_args, $test->{check_args}, "$name: args OK"; unless ( is_deeply $resp, $test->{expect}, "$name: result OK" ) { diag( Data::Dumper->Dump( [ $test->{expect} ], ['$expected'] ) ); diag( Data::Dumper->Dump( [$resp], ['$got'] ) ); } } Captcha-reCAPTCHA-0.97/t/40.errors.t000644 000765 000765 00000004222 11413637172 017057 0ustar00phredphred000000 000000 use strict; use warnings; use Test::More; use Captcha::reCAPTCHA; use constant PUBKEY => '6LdAAAkAwAAAFJj6ACG3Wlix_GuQJMNGjMQnw5UY'; use constant PRIVKEY => '6LdAAAkAwAAAix_GF6AMQnw5UCG3JjWluQJMNGjY'; my @schedule; BEGIN { @schedule = ( { name => 'new: Bad args', class => 'T::Captcha::reCAPTCHA', try => sub { my $c = Captcha::reCAPTCHA->new( PUBKEY ); }, expect => qr/reference to a hash/ }, { name => 'get_html: No args', class => 'T::Captcha::reCAPTCHA', try => sub { my $c = shift; $c->get_html(); }, expect => qr/To use reCAPTCHA you must get an API key from/ }, { name => 'get_html: No key', class => 'T::Captcha::reCAPTCHA', try => sub { my $c = shift; $c->get_html( '' ); }, expect => qr/To use reCAPTCHA you must get an API key from/ }, { name => 'check_answer: No args', class => 'T::Captcha::reCAPTCHA', try => sub { my $c = shift; $c->check_answer(); }, expect => qr/To use reCAPTCHA you must get an API key from/ }, { name => 'check_answer: no ip', class => 'T::Captcha::reCAPTCHA', try => sub { my $c = shift; $c->check_answer( PRIVKEY ); }, expect => qr/you must pass the remote ip/ }, ); plan tests => 3 * @schedule; } package T::Captcha::reCAPTCHA; our @ISA = qw(Captcha::reCAPTCHA); use Captcha::reCAPTCHA; sub _post_request { my $self = shift; my $url = shift; my $args = shift; # Just keep the args $self->{t_url} = $url; $self->{t_args} = $args; return HTTP::Response->new( 200, 'OK', [ 'Content-type:' => 'text/plain' ], "true\n" ); } sub get_url { shift->{t_url} } sub get_args { shift->{t_args} } package main; for my $test ( @schedule ) { my $name = $test->{name}; my $class = $test->{class}; ok my $captcha = $class->new, "$name: create OK"; isa_ok $captcha, $class; eval { $test->{try}->( $captcha ); }; if ( my $expect = $test->{expect} ) { like $@, $expect, "$name: error OK"; } else { ok !$@, "$name: no error OK"; } } Captcha-reCAPTCHA-0.97/t/pod-coverage.t000644 000765 000765 00000000362 11413637174 017677 0ustar00phredphred000000 000000 #!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok( { private => [ qr{^BUILD|DEMOLISH|AUTOMETHOD|START$}, qr{^_} ] } ); Captcha-reCAPTCHA-0.97/t/pod.t000644 000765 000765 00000000214 11413637175 016103 0ustar00phredphred000000 000000 #!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Captcha-reCAPTCHA-0.97/lib/Captcha/000755 000765 000765 00000000000 12041330054 016765 5ustar00phredphred000000 000000 Captcha-reCAPTCHA-0.97/lib/Captcha/reCAPTCHA.pm000644 000765 000765 00000023606 12041330033 020721 0ustar00phredphred000000 000000 package Captcha::reCAPTCHA; use warnings; use strict; use Carp; use LWP::UserAgent; use HTML::Tiny; our $VERSION = '0.97'; use constant API_SERVER => 'http://www.google.com/recaptcha/api'; use constant API_SECURE_SERVER => 'https://www.google.com/recaptcha/api'; use constant API_VERIFY_SERVER => 'http://www.google.com'; use constant SERVER_ERROR => 'recaptcha-not-reachable'; sub new { my $class = shift; my $self = bless {}, $class; $self->_initialize( @_ ); return $self; } sub _initialize { my $self = shift; my $args = shift || {}; croak "new must be called with a reference to a hash of parameters" unless 'HASH' eq ref $args; } sub _html { shift->{_html} ||= HTML::Tiny->new } sub get_options_setter { my $self = shift; my $options = shift || return ''; croak "The argument to get_options_setter must be a hashref" unless 'HASH' eq ref $options; my $h = $self->_html; return $h->script( { type => 'text/javascript' }, "\n//json_encode( $options ) . ";\n//]]>\n" ) . "\n"; } sub get_html { my $self = shift; my ( $pubkey, $error, $use_ssl, $options ) = @_; croak "To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create" unless $pubkey; my $h = $self->_html; my $server = $use_ssl ? API_SECURE_SERVER : API_SERVER; my $query = { k => $pubkey }; if ( $error ) { # Handle the case where the result hash from check_answer # is passed. if ( 'HASH' eq ref $error ) { return '' if $error->{is_valid}; $error = $error->{error}; } $query->{error} = $error; } my $qs = $h->query_encode( $query ); return join( '', $self->get_options_setter( $options ), $h->script( { type => 'text/javascript', src => "$server/challenge?$qs", } ), "\n", $h->noscript( [ $h->iframe( { src => "$server/noscript?$qs", height => 300, width => 500, frameborder => 0 } ), $h->textarea( { name => 'recaptcha_challenge_field', rows => 3, cols => 40 } ), $h->input( { type => 'hidden', name => 'recaptcha_response_field', value => 'manual_challenge' } ) ] ), "\n" ); } sub _post_request { my $self = shift; my ( $url, $args ) = @_; my $ua = LWP::UserAgent->new(); $ua->env_proxy(); return $ua->post( $url, $args ); } sub check_answer { my $self = shift; my ( $privkey, $remoteip, $challenge, $response ) = @_; croak "To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create" unless $privkey; croak "For security reasons, you must pass the remote ip to reCAPTCHA" unless $remoteip; return { is_valid => 0, error => 'incorrect-captcha-sol' } unless $challenge && $response; my $resp = $self->_post_request( API_VERIFY_SERVER . '/recaptcha/api/verify', { privatekey => $privkey, remoteip => $remoteip, challenge => $challenge, response => $response } ); if ( $resp->is_success ) { my ( $answer, $message ) = split( /\n/, $resp->content, 2 ); if ( $answer =~ /true/ ) { return { is_valid => 1 }; } else { chomp $message; return { is_valid => 0, error => $message }; } } else { return { is_valid => 0, error => SERVER_ERROR }; } } 1; __END__ =head1 NAME Captcha::reCAPTCHA - A Perl implementation of the reCAPTCHA API =head1 VERSION This document describes Captcha::reCAPTCHA =head1 SYNOPSIS use Captcha::reCAPTCHA; my $c = Captcha::reCAPTCHA->new; # Output form print $c->get_html( 'your public key here' ); # Verify submission my $result = $c->check_answer( 'your private key here', $ENV{'REMOTE_ADDR'}, $challenge, $response ); if ( $result->{is_valid} ) { print "Yes!"; } else { # Error $error = $result->{error}; } For complete examples see the /examples subdirectory =head1 DESCRIPTION reCAPTCHA is a hybrid mechanical turk and captcha that allows visitors who complete the captcha to assist in the digitization of books. From L: reCAPTCHA improves the process of digitizing books by sending words that cannot be read by computers to the Web in the form of CAPTCHAs for humans to decipher. More specifically, each word that cannot be read correctly by OCR is placed on an image and used as a CAPTCHA. This is possible because most OCR programs alert you when a word cannot be read correctly. This Perl implementation is modelled on the PHP interface that can be found here: L To use reCAPTCHA you need to register your site here: L =head1 INTERFACE =over =item C<< new >> Create a new C<< Captcha::reCAPTCHA >>. =item C<< get_html( $pubkey, $error, $use_ssl, $options ) >> Generates HTML to display the captcha. print $captcha->get_html( $PUB, $err ); =over =item C<< $pubkey >> Your reCAPTCHA public key, from the API Signup Page =item C<< $error >> Optional. If set this should be either a string containing a reCAPTCHA status code or a result hash as returned by C<< check_answer >>. =item C<< $use_ssl >> Optional. Should the SSL-based API be used? If you are displaying a page to the user over SSL, be sure to set this to true so an error dialog doesn't come up in the user's browser. =item C<< $options >> Optional. A reference to a hash of options for the captcha. See C<< get_options_setter >> for more details. =back Returns a string containing the HTML that should be used to display the captcha. =item C<< get_options_setter( $options ) >> You can optionally customize the look of the reCAPTCHA widget with some JavaScript settings. C returns a block of Javascript wrapped in tags that will set the options to be used by the widget. C<$options> is a reference to a hash that may contain the following keys: =over =item C Defines which theme to use for reCAPTCHA. Possible values are 'red', 'white' or 'blackglass'. The default is 'red'. =item C Sets a tabindex for the reCAPTCHA text box. If other elements in the form use a tabindex, this should be set so that navigation is easier for the user. Default: 0. =back =item C<< check_answer >> After the user has filled out the HTML form, including their answer for the CAPTCHA, use C<< check_answer >> to check their answer when they submit the form. The user's answer will be in two form fields, recaptcha_challenge_field and recaptcha_response_field. The reCAPTCHA library will make an HTTP request to the reCAPTCHA server and verify the user's answer. =over =item C<< $privkey >> Your reCAPTCHA private key, from the API Signup Page. =item C<< $remoteip >> The user's IP address, in the format 192.168.0.1. =item C<< $challenge >> The value of the form field recaptcha_challenge_field =item C<< $response >> The value of the form field recaptcha_response_field. =back Returns a reference to a hash containing two fields: C and C. my $result = $c->check_answer( 'your private key here', $ENV{'REMOTE_ADDR'}, $challenge, $response ); if ( $result->{is_valid} ) { print "Yes!"; } else { # Error $error = $result->{error}; } See the /examples subdirectory for examples of how to call C. Note: this method will make an HTTP request to Google to verify the user input. If this request must be routed via a proxy in your environment, use the standard environment variable to specify the proxy address, e.g.: $ENV{http_proxy} = 'http://myproxy:3128'; =back =head1 CONFIGURATION AND ENVIRONMENT Captcha::reCAPTCHA requires no configuration files or environment variables. To use reCAPTCHA sign up for a key pair here: L =head1 DEPENDENCIES LWP::UserAgent, HTML::Tiny =head1 INCOMPATIBILITIES None reported . =head1 BUGS AND LIMITATIONS No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Andy Armstrong C<< >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Captcha-reCAPTCHA-0.97/examples/captcha.pl000755 000765 000765 00000001715 11413637166 020461 0ustar00phredphred000000 000000 #!/usr/bin/perl # Simple CGI Captcha use strict; use warnings; use Captcha::reCAPTCHA; use CGI::Simple; # Your reCAPTCHA keys from # https://www.google.com/recaptcha/admin/create use constant PUBLIC_KEY => ''; use constant PRIVATE_KEY => ''; $| = 1; my $q = CGI::Simple->new; my $c = Captcha::reCAPTCHA->new; my $error = undef; print "Content-type: text/html\n\n"; print <
EOT # Check response if ( $q->param( 'recaptcha_response_field' ) ) { my $result = $c->check_answer( PRIVATE_KEY, $ENV{'REMOTE_ADDR'}, $q->param( 'recaptcha_challenge_field' ), $q->param( 'recaptcha_response_field' ) ); if ( $result->{is_valid} ) { print "Yes!"; } else { $error = $result->{error}; } } # Generate the form print $c->get_html( PUBLIC_KEY, $error ); print < EOT