function _recaptcha_replace in reCAPTCHA 6
Same name and namespace in other branches
- 8 recaptcha_mailhide/recaptcha_mailhide.module \_recaptcha_replace()
- 5.2 recaptcha_mailhide.module \_recaptcha_replace()
- 7 recaptcha_mailhide/recaptcha_mailhide.module \_recaptcha_replace()
Private reCAPTCHA function to replace an email regex match
1 string reference to '_recaptcha_replace'
- recaptcha_mailhide_filter in recaptcha_mailhide/
recaptcha_mailhide.module - Implements hook_filter().
File
- recaptcha_mailhide/
recaptcha_mailhide.module, line 103 - Protects email addresses using the reCAPTCHA web service.
Code
function _recaptcha_replace($match) {
global $_recaptcha_mailhide_public_key, $_recaptcha_mailhide_private_key, $_recaptcha_mailhide_nokey_warn;
// recaptchalib will die if we invoke without setting the keys. Fail gracefully in this case.
if (empty($_recaptcha_mailhide_public_key) || empty($_recaptcha_mailhide_private_key) || !function_exists('mcrypt_encrypt')) {
if ($_recaptcha_mailhide_nokey_warn != TRUE) {
if (!function_exists('mcrypt_encrypt')) {
drupal_set_message(t('Addresses cannot be hidden because Mcrypt is not installed.'), 'error');
}
else {
drupal_set_message(t('Addresses cannot be hidden because the administrator has not set the reCAPTCHA Mailhide keys.'), 'error');
}
$_recaptcha_mailhide_nokey_warn = TRUE;
}
$email = $match[2];
}
else {
$email = recaptcha_mailhide_html($_recaptcha_mailhide_public_key, $_recaptcha_mailhide_private_key, $match[2]);
}
return $match[1] . $email . $match[3];
}