From ff6c62dcb4b5f323172788d1d90c3c3492651da9 Mon Sep 17 00:00:00 2001
From: Joe Rayhawk <jrayhawk@omgwallhack.org>
Date: Tue, 27 Nov 2018 01:09:09 -0800
Subject: pinyweb: newuser: remove google's broken captcha api

---
 pinyweb/cgi-bin/newuser.cgi | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

(limited to 'pinyweb/cgi-bin/newuser.cgi')

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;
       };
     };
-- 
cgit v1.2.3