Hi,
I`m using math captcha in my forms, `cause the normal bf captcha is unreadable too often for users.
Now some users told me, that the form couldn`t be send even if the the right answer was given ( f.e. 4+1=5).
I modified the script a little bit, because not every german user understands the english written numbers (one, two...), so I changed the numbers into 1,2,3...
In my own test it worked.
Could this change `cause the problems?
Is it possible to implement something like "refresh"?
/ MATH CAPTCHA CODE, DO NOT CHANGE
// if a captcha solve request comes in
if( JRequest::getVar('answer', null) !== null ){
while (@ob_get_level() > 0) {
@ob_end_clean();
}
$math = JFactory::getSession()->get('breezingforms.captcha.math','');
if(trim($math) == ''){
echo 0;
} else {
eval('if('.$math.' == '.JRequest::getInt('answer').'){ echo 1; } else { echo 0; }');
}
exit;
}
$this->execPieceByName('ff_InitLib');
$left = mt_rand(1,10);
$right = mt_rand(1,10);
$left_name = '';
switch( $left ){
case 1: $left_name = '1'; break;
case 2: $left_name = '2'; break;
case 3: $left_name = '3'; break;
case 4: $left_name = '4'; break;
case 5: $left_name = '5'; break;
case 6: $left_name = '6'; break;
case 7: $left_name = '7'; break;
case 8: $left_name = '8'; break;
case 9: $left_name = '9'; break;
case 10: $left_name = '10'; break;
}
$right_name = '';
switch( $right ){
case 1: $right_name = '1'; break;
case 2: $right_name = '2'; break;
case 3: $right_name = '3'; break;
case 4: $right_name = '4'; break;
case 5: $right_name = '5'; break;
case 6: $right_name = '6'; break;
case 7: $right_name = '7'; break;
case 8: $right_name = '8'; break;
case 9: $right_name = '9'; break;
case 10: $right_name = '10'; break;
}
$operand = mt_rand(0,1); // 0 = +, 1 = -1
// used for server side check later
JFactory::getSession()->set('breezingforms.captcha.math', $left . ' ' . ( $operand == 0 ? '+' : '-' ) . ' ' . $right);
ff_setValue('question', $left_name . ' ' . ( $operand == 0 ? '+' : '-' ) . ' ' . $right_name . '?');
// MATH CAPTCHA CODE END
the validation script
function ff_answer_validation(element, message)
{
var myreturn = '';
JQuery.ajaxSetup({async:false});
JQuery.post('index.php', { option: 'com_breezingforms', ff_form: ff_processor.form, Itemid: 0, format: 'html', answer: element.value }, function(data){ if( data != '1' ){ message == '' ? myreturn = 'Please answer the question correctly!' : myreturn = message; } } );
return myreturn;
} // ff_captcha_validation
Regards
Ellen