summaryrefslogtreecommitdiff
path: root/pinyweb/cgi-bin
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2015-07-02 15:33:04 -0700
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2015-07-02 15:33:04 -0700
commit5b8fd3bd5a45bcaf0d57c240c2df05b2dac1f255 (patch)
treefb7cfb7f144775d05bd3767ed4f6cf959b6959ae /pinyweb/cgi-bin
parent3ba6477b4f9d7a7e6d3768ab6a1c85ac74036c46 (diff)
downloadpiny-code-5b8fd3bd5a45bcaf0d57c240c2df05b2dac1f255.tar.gz
piny-code-5b8fd3bd5a45bcaf0d57c240c2df05b2dac1f255.zip
pinyweb: newuser.cgi: fix recaptcha logic
Diffstat (limited to 'pinyweb/cgi-bin')
-rwxr-xr-xpinyweb/cgi-bin/newuser.cgi41
1 files changed, 20 insertions, 21 deletions
diff --git a/pinyweb/cgi-bin/newuser.cgi b/pinyweb/cgi-bin/newuser.cgi
index b54b1ec..907b259 100755
--- a/pinyweb/cgi-bin/newuser.cgi
+++ b/pinyweb/cgi-bin/newuser.cgi
@@ -22,27 +22,6 @@ $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");
@@ -74,6 +53,26 @@ if( $q->param("n") && $q->param("a") && $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 ( $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;
+ };
+ };
print( "Dispatching email to " . $q->param("a") . "...\n" );
unless( open( MAIL, "|/usr/lib/sendmail -t" ) ) {
print "could not execute sendmail";