# contact-forms/1.2/PFBC/Validation/Captcha.php

Contact Forms by Cimatti, version 1.2. 21 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/1.2/code/PFBC/Validation/Captcha.php
- Raw: https://pluginprobe.com/plugins/contact-forms/1.2/raw/PFBC/Validation/Captcha.php
- Modified: 2013-07-25T16:57:42+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.2/code/PFBC/Validation/Captcha.php#L10-L20`.

```php
<?php
class Validation_Captcha extends Validation {
	protected $message = "Error: The reCATPCHA response provided was incorrect.  Please re-try.";
	protected $privateKey;

	public function __construct($privateKey, $message = "") {
		$this->privateKey = $privateKey;
		if(!empty($message))
			$this->message = $message;
	}

	public function isValid($value) {
		require_once(dirname(__FILE__) . "/../Resources/recaptchalib.php");
		$resp = recaptcha_check_answer ($this->privateKey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
		if($resp->is_valid)
			return true;
		else	
			return false;
	}
}

```
