'', 'value' => '', ); public function __construct($name) { parent::__construct($name); $this->error_messages("incorrect-captcha-sol", t("The values supplied to reCAPTCHA are incorrect.")); $this->error_messages("invalid-site-private-key", t("The site private key is incorrect.")); } public function render() { $public_key = module::get_var("recaptcha", "public_key"); if (empty($public_key)) { throw new Exception("@todo NEED KEY " . "http://recaptcha.net/api/getkey"); } $view = new View("form_recaptcha.html"); $view->public_key = $public_key; return $view; } /** * Validate this input based on the set rules. * * @return bool */ public function validate() { $input = Input::instance(); $challenge = $input->post("recaptcha_challenge_field", "", true); $response = $input->post("recaptcha_response_field", "", true); if (!empty($challenge)) { $this->_error = recaptcha::is_recaptcha_valid( $challenge, $response, module::get_var("recaptcha", "private_key")); if (!empty($this->_error)) { $this->add_error($this->_error, 1); } } $this->is_valid = empty($this->_error); return empty($this->_error); } }