zURL/modules/recaptcha/classes/recaptcha.php
2010-02-26 12:53:37 +00:00

26 lines
727 B
PHP

<?php
defined('SYSPATH') or die('No direct script access.');
include Kohana::find_file('vendor', 'recaptchalib');
class Recaptcha
{
public static function get_html()
{
$config = Kohana::config('recaptcha');
return recaptcha_get_html($config['public_key']);
}
public static function validate(Validate $validate, $field)
{
$config = Kohana::config('recaptcha');
$response = recaptcha_check_answer($config['private_key'],
$_SERVER['REMOTE_ADDR'],
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']);
if (!$response->is_valid)
{
$validate->error('recaptcha_challenge_field', 'captcha');
}
}
}
?>