| 1 |
<?php |
| 2 |
class Validation_Captcha extends Validation { |
| 3 |
protected $message = "Error: The reCATPCHA response provided was incorrect. Please re-try."; |
| 4 |
protected $privateKey; |
| 5 |
|
| 6 |
public function __construct($privateKey, $message = "") { |
| 7 |
$this->privateKey = $privateKey; |
| 8 |
if(!empty($message)) |
| 9 |
$this->message = $message; |
| 10 |
} |
| 11 |
|
| 12 |
public function isValid($value) { |
| 13 |
require_once(dirname(__FILE__) . "/../Resources/recaptchalib.php"); |
| 14 |
$resp = recaptcha_check_answer ($this->privateKey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); |
| 15 |
if($resp->is_valid) |
| 16 |
return true; |
| 17 |
else |
| 18 |
return false; |
| 19 |
} |
| 20 |
} |
| 21 |
|