diff options
author | jrayhawk+piny.be@omgwallhack.org <jrayhawk+piny.be@omgwallhack.org> | 2014-12-15 04:00:56 -0800 |
---|---|---|
committer | jrayhawk+piny.be@omgwallhack.org <jrayhawk+piny.be@omgwallhack.org> | 2014-12-15 04:00:56 -0800 |
commit | fce92f9222a9b863a0f1cbf5cc169ca0f9eb3788 (patch) | |
tree | 90e6df6e6871c9519217115415f973ebe5778b35 /pinyweb | |
parent | d68916ee9504714935793950df00709e15405e7d (diff) | |
download | piny-code-fce92f9222a9b863a0f1cbf5cc169ca0f9eb3788.tar.gz piny-code-fce92f9222a9b863a0f1cbf5cc169ca0f9eb3788.zip |
pinyweb: newuser.cgi: add recaptcha support
Diffstat (limited to 'pinyweb')
-rwxr-xr-x | pinyweb/cgi-bin/newuser.cgi | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pinyweb/cgi-bin/newuser.cgi b/pinyweb/cgi-bin/newuser.cgi index e4b955a..b54b1ec 100755 --- a/pinyweb/cgi-bin/newuser.cgi +++ b/pinyweb/cgi-bin/newuser.cgi @@ -10,6 +10,7 @@ use CGI; use Crypt::CBC; use IPC::Open2; use MIME::Base32 qw( RFC ); +use Captcha::reCAPTCHA; use Piny::Auth; @@ -21,6 +22,27 @@ $q = CGI->new; print( "Content-type: text/plain\n\n" ); +if ( -f "/etc/recaptcha/private.key" ) { + if ( $q->param('recaptcha_response_field') && $q->param('recaptcha_challenge_field') ) { + open(RECAPTCHA, '/etc/recaptcha/private.key') || ( print "Can't read recaptcha key: [$!]\n" && exit 0 ); + my $recaptchakey = <RECAPTCHA>; + close (RECAPTCHA); + chomp($recaptchakey); + my $c = Captcha::reCAPTCHA->new; + my $result = $c->check_answer( $recaptchakey, $ENV{'REMOTE_ADDR'}, $q->param( 'recaptcha_challenge_field' ), $q->param( 'recaptcha_response_field' ) ); + if ( $result->{is_valid} ) { + print "Good recaptcha submission.\n" + } else { + print "Bad recaptcha submission: $result->{error}\n"; + exit 0; + }; + } else { + print( "Missing recaptcha parameters." ); + exit 0; + }; + +}; + if( $q->param("n") && $q->param("a") && $q->param("p") ) { my $pass = $q->param("p"); |