diff --git a/captcha/background1.jpg b/captcha/background1.jpg deleted file mode 100644 index dd81850..0000000 Binary files a/captcha/background1.jpg and /dev/null differ diff --git a/captcha/background2.jpg b/captcha/background2.jpg deleted file mode 100644 index a4d81a9..0000000 Binary files a/captcha/background2.jpg and /dev/null differ diff --git a/captcha/background3.jpg b/captcha/background3.jpg deleted file mode 100644 index 62aa115..0000000 Binary files a/captcha/background3.jpg and /dev/null differ diff --git a/captcha/background4.jpg b/captcha/background4.jpg deleted file mode 100644 index e1dd76c..0000000 Binary files a/captcha/background4.jpg and /dev/null differ diff --git a/captcha/randomimage.php b/captcha/randomimage.php deleted file mode 100644 index 323693f..0000000 --- a/captcha/randomimage.php +++ /dev/null @@ -1,52 +0,0 @@ - \ No newline at end of file diff --git a/sendform.php b/sendform.php index 806b72a..cb1dd01 100644 --- a/sendform.php +++ b/sendform.php @@ -15,6 +15,10 @@ // $referals is a list of web site domains seperated by commas. Only requests originating from // these domains will be processed. $referals = "domain.com"; + + // Google reCaptcha v2 secret. Obtain your key from https://www.google.com/recaptcha/admin/create + // Enter your secret key below and be sure to integrate reCaptcha into your site with your site key. + $reCaptchaSecret = ""; // $excludeFields is a list of field names seperated by commas. Field names listed here will not // be included in the resulting email of this script. @@ -76,9 +80,30 @@ $theDomain = getdomain($_SERVER['HTTP_REFERER']); checkreferal(); - if(isset($_SESSION['image_random_value']) && strcasecmp(md5(strtoupper($_REQUEST['verification'])), $_SESSION['image_random_value']) != 0) { - die("Verification box did not match image"); - } + + // Google reCaptcha v2 + if(isset($reCaptchaSecret)){ + if(isset($_POST['g-recaptcha-response'])) $captcha=$_POST['g-recaptcha-response']; + else errormsg("Verification failed. Please try again."); + + // post request to server + $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($reCaptchaSecret) . '&response=' . urlencode($captcha); + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); + + $response = curl_exec($ch); + curl_close($ch); + + $responseKeys = json_decode($response,true); + // should return JSON with success as true + if(!$responseKeys["success"]) errormsg("Verification failed. Please try again."); + } + checkrequired(); if(!validemail($defaultFrom) && !isset($_POST['email'])) bademail($defaultFrom); fillrecipients();