diff options
Diffstat (limited to 'pinyweb/cgi-bin/newuser.cgi')
-rwxr-xr-x | pinyweb/cgi-bin/newuser.cgi | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/pinyweb/cgi-bin/newuser.cgi b/pinyweb/cgi-bin/newuser.cgi index 9675a5e..159db63 100755 --- a/pinyweb/cgi-bin/newuser.cgi +++ b/pinyweb/cgi-bin/newuser.cgi @@ -9,8 +9,7 @@ use CGI; use Crypt::CBC; use IPC::Open2; -use MIME::Base32 qw( RFC ); -use Captcha::reCAPTCHA; +use MIME::Base32; use Piny::Auth; @@ -53,23 +52,20 @@ if( scalar( $q->param("n") ) && scalar( $q->param("a") ) && scalar( $q->param("p print( "I'm sorry, the link you followed is invalid.\n" ); }; } else { # No hash, they need one sent to their address - # CAPTCHA check - if ( -f "/etc/recaptcha/private.key" ) { - if ( scalar( $q->param('recaptcha_response_field') ) && scalar( $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'}, scalar( $q->param( 'recaptcha_challenge_field' ) ), scalar( $q->param( 'recaptcha_response_field' ) ) ); - if ( $result->{is_valid} ) { - print "Good recaptcha submission.\n" + if ( -f "/etc/piny/captcha" ) { + if ( scalar( $q->param('c') ) ) { + open(CAPTCHA, '/etc/piny/captcha') || ( print "Can't read captcha file: [$!]\n" && exit 0 ); + my $captcha = <CAPTCHA>; + close (CAPTCHA); + chomp( $captcha ); + if ( $captcha eq scalar( $q->param('c') ) ) { + print "Good captcha submission.\n" } else { - print "Bad recaptcha submission: $result->{error}\n"; + print "Bad captcha submission.\n"; exit 0; }; } else { - print( "Missing recaptcha parameters." ); + print( "Missing or incorrect \"c\" captcha parameter." ); exit 0; }; }; |