Captcha::reCAPTCHA is pure Perl and wouldn't require root access to use a local copy. Just install it into a local user directory and use 'use lib' so that your CGI script will find it.

I haven't found Captcha:reCAPTCHA to be the world's easiest software to use, but it's OK.

This example is derived from one of the posted examples; you may find it useful. Note that I'm assuming that your Captcha::reCAPTCHA library is installed into a local directory, and that you've situated your public and private key files appropriately. Note that for security reasons these key files (especially the private one) shouldn't be located within web-browsable disk space.

HTH ...

use lib '/home/myhomedir/myperllib'; use strict; use warnings; use Captcha::reCAPTCHA; use CGI; # Your reCAPTCHA keys from # https://admin.recaptcha.net/recaptcha/createsite/ my $pubpath = "/home/myhomedir/captcha/public.key"; my $privpath = "/home/myhomedir/captcha/private.key"; open INP,"<$pubpath" or die "Unable to open $pubpath"; my $pubkey = <INP>; chomp $pubkey; close INP; open INP,"<$privpath" or die "Unable to open $privpath"; my $privkey = <INP>; chomp $privkey; close INP; $| = 1; my $q = CGI->new; my $c = Captcha::reCAPTCHA->new; my $error = undef; print "Content-type: text/html\n\n"; print <<EOT; <html> <body> <form action="" method="post"> EOT # Check response if ( $q->param( 'recaptcha_response_field' ) ) { my $result = $c->check_answer( $privkey, $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( $pubkey, $error ); print <<EOT; <br/> <input type="submit" value="submit" /> </form> EOT print "<p>The special stuff here</p>\n"; print <<EOT; </body> </html> EOT

In reply to Re^2: Perl Captcha Solution by jae_63
in thread Perl Captcha Solution by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.