Skip to content

Commit

Permalink
fix something
Browse files Browse the repository at this point in the history
  • Loading branch information
tbsmcd committed Feb 1, 2011
1 parent 33645de commit 59b965b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions models/behaviors/validation.php
Expand Up @@ -2,18 +2,21 @@
class ValidationBehavior extends ModelBehavior {
function beforeValidate(&$model) {
$model->validate['recaptcha_response_field'] = array(
'confirmReCaptcha' => array(
'rule' => array('confirmReCaptcha', 'recaptcha_challenge_field'),
'checkRecaptcha' => array(
'rule' => array('checkRecaptcha', 'recaptcha_challenge_field'),
'message' => 'You did not enter the words correctly. Please try again.',
),
);
}

function confirmReCaptcha(&$model , $data, $target) {
function checkRecaptcha(&$model, $data, $target) {
App::import('Vendor', 'RecaptchaPlugin.recaptchalib');
Configure::load('RecaptchaPlugin.key');
$privatekey = Configure::read('Recaptcha.Private');
$res = recaptcha_check_answer($privatekey, $_SERVER['REMOTE_ADDR'], $model->data[$model->alias][$target], $data['recaptcha_response_field']);
$res = recaptcha_check_answer(
$privatekey, $_SERVER['REMOTE_ADDR'],
$model->data[$model->alias][$target], $data['recaptcha_response_field']
);
return $res->is_valid;
}
}

0 comments on commit 59b965b

Please sign in to comment.