# contact-forms/1.9.2/classes/Validation/Captcha2b.php

Contact Forms by Cimatti, version 1.9.2. 39 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/1.9.2/code/classes/Validation/Captcha2b.php
- Raw: https://pluginprobe.com/plugins/contact-forms/1.9.2/raw/classes/Validation/Captcha2b.php
- Modified: 2023-03-14T12:04:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/1.9.2/code/classes/Validation/Captcha2b.php#L10-L20`.

```php
<?php
class AccuaForm_Validation_Captcha2b extends Validation {
	protected $message = "Error: The reCATPCHA response provided was incorrect.  Please re-try.";
	protected $privateKey;
	
	public function isValid($value) {
	  if (!isset($_POST['g-recaptcha-response'])) {
	    return false;
	  }

	  $response = stripslashes_deep($_POST['g-recaptcha-response']);

	  if ($response === '') {
	    return false;
	  }

	  $url = 'https://www.google.com/recaptcha/api/siteverify'
	      .'?secret='.urlencode($this->privateKey)
	      .'&response='.urlencode($response)
	      .'&remoteip='.urlencode($_SERVER["REMOTE_ADDR"]);

	  $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    $res = curl_exec($ch);
    curl_close($ch);

    if ($res !== false) {
      @ $res = json_decode($res, true);
  		if (!empty($res['success'])) {
  			return true;
  		}
    }

	  return false;
	}
}

```
