'', '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"); } $server = "http://api.recaptcha.net"; $options[] = "callback: Recaptcha.focus_response_field"; $options[] = "lang: \"" . Kohana::config("locale.root_locale") . "\""; $options[] = "theme: \"white\""; $options = implode(", ", $options); $html = "
"; $html .= ""; $html .= ""; return $html; } /** * 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); } }